Update V8 to version 4.6.72.
[chromium-blink-merge.git] / ash / first_run / first_run_helper_impl.cc
blob19d107fd0a8c51f79e1b3af2d7448e77f62f1c8a
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/first_run/first_run_helper_impl.h"
7 #include "ash/shelf/shelf.h"
8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h"
10 #include "ash/system/tray/system_tray.h"
11 #include "base/logging.h"
12 #include "ui/app_list/views/app_list_view.h"
13 #include "ui/aura/window.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/views/view.h"
16 #include "ui/views/widget/widget.h"
18 namespace ash {
20 namespace {
22 views::Widget* CreateFirstRunWindow() {
23 views::Widget::InitParams params(
24 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
25 params.bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds();
26 params.show_state = ui::SHOW_STATE_FULLSCREEN;
27 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
28 params.parent = Shell::GetContainer(Shell::GetPrimaryRootWindow(),
29 ash::kShellWindowId_OverlayContainer);
30 views::Widget* window = new views::Widget;
31 window->Init(params);
32 return window;
35 } // anonymous namespace
37 FirstRunHelperImpl::FirstRunHelperImpl()
38 : widget_(CreateFirstRunWindow()) {
39 Shell::GetInstance()->overlay_filter()->Activate(this);
42 FirstRunHelperImpl::~FirstRunHelperImpl() {
43 Shell::GetInstance()->overlay_filter()->Deactivate(this);
44 if (IsTrayBubbleOpened())
45 CloseTrayBubble();
46 widget_->Close();
49 views::Widget* FirstRunHelperImpl::GetOverlayWidget() {
50 return widget_;
53 void FirstRunHelperImpl::OpenAppList() {
54 Shell::GetInstance()->ShowAppList(NULL);
57 void FirstRunHelperImpl::CloseAppList() {
58 Shell::GetInstance()->DismissAppList();
61 gfx::Rect FirstRunHelperImpl::GetLauncherBounds() {
62 Shelf* shelf = Shelf::ForPrimaryDisplay();
63 return shelf->GetVisibleItemsBoundsInScreen();
66 gfx::Rect FirstRunHelperImpl::GetAppListButtonBounds() {
67 Shelf* shelf = Shelf::ForPrimaryDisplay();
68 views::View* app_button = shelf->GetAppListButtonView();
69 return app_button->GetBoundsInScreen();
72 gfx::Rect FirstRunHelperImpl::GetAppListBounds() {
73 app_list::AppListView* view = Shell::GetInstance()->GetAppListView();
74 return view->GetBoundsInScreen();
77 void FirstRunHelperImpl::Cancel() {
78 FOR_EACH_OBSERVER(Observer, observers(), OnCancelled());
81 bool FirstRunHelperImpl::IsCancelingKeyEvent(ui::KeyEvent* event) {
82 return event->key_code() == ui::VKEY_ESCAPE;
85 aura::Window* FirstRunHelperImpl::GetWindow() {
86 return widget_->GetNativeWindow();
89 void FirstRunHelperImpl::OpenTrayBubble() {
90 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray();
91 tray->ShowPersistentDefaultView();
94 void FirstRunHelperImpl::CloseTrayBubble() {
95 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray();
96 DCHECK(tray->HasSystemBubble()) << "Tray bubble is closed already.";
97 tray->CloseSystemBubble();
100 bool FirstRunHelperImpl::IsTrayBubbleOpened() {
101 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray();
102 return tray->HasSystemBubble();
105 gfx::Rect FirstRunHelperImpl::GetTrayBubbleBounds() {
106 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray();
107 views::View* bubble = tray->GetSystemBubble()->bubble_view();
108 return bubble->GetBoundsInScreen();
111 gfx::Rect FirstRunHelperImpl::GetHelpButtonBounds() {
112 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray();
113 views::View* help_button = tray->GetHelpButtonView();
114 return help_button->GetBoundsInScreen();
117 } // namespace ash