first_run_helper_impl.cc revision f2477e01787aa58f445919b809d89e252beef54f
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. 4 5#include "ash/first_run/first_run_helper_impl.h" 6 7#include "ash/launcher/launcher.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/rect.h" 15#include "ui/views/view.h" 16#include "ui/views/widget/widget.h" 17 18namespace ash { 19 20namespace { 21 22views::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 = 29 Shell::GetContainer(Shell::GetPrimaryRootWindow(), 30 ash::internal::kShellWindowId_OverlayContainer); 31 views::Widget* window = new views::Widget; 32 window->Init(params); 33 return window; 34} 35 36} // anonymous namespace 37 38FirstRunHelperImpl::FirstRunHelperImpl() 39 : widget_(CreateFirstRunWindow()) { 40 Shell::GetInstance()->overlay_filter()->Activate(this); 41} 42 43FirstRunHelperImpl::~FirstRunHelperImpl() { 44 Shell::GetInstance()->overlay_filter()->Deactivate(); 45 widget_->Close(); 46} 47 48views::Widget* FirstRunHelperImpl::GetOverlayWidget() { 49 return widget_; 50} 51 52void FirstRunHelperImpl::OpenAppList() { 53 if (Shell::GetInstance()->GetAppListTargetVisibility()) 54 return; 55 Shell::GetInstance()->ToggleAppList(NULL); 56} 57 58void FirstRunHelperImpl::CloseAppList() { 59 if (!Shell::GetInstance()->GetAppListTargetVisibility()) 60 return; 61 Shell::GetInstance()->ToggleAppList(NULL); 62} 63 64gfx::Rect FirstRunHelperImpl::GetLauncherBounds() { 65 ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay(); 66 return launcher->GetVisibleItemsBoundsInScreen(); 67} 68 69gfx::Rect FirstRunHelperImpl::GetAppListButtonBounds() { 70 ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay(); 71 views::View* app_button = launcher->GetAppListButtonView(); 72 return app_button->GetBoundsInScreen(); 73} 74 75gfx::Rect FirstRunHelperImpl::GetAppListBounds() { 76 app_list::AppListView* view = Shell::GetInstance()->GetAppListView(); 77 return view->GetBoundsInScreen(); 78} 79 80void FirstRunHelperImpl::Cancel() { 81 NOTIMPLEMENTED(); 82} 83 84bool FirstRunHelperImpl::IsCancelingKeyEvent(ui::KeyEvent* event) { 85 return false; 86} 87 88aura::Window* FirstRunHelperImpl::GetWindow() { 89 return widget_->GetNativeWindow(); 90} 91 92void FirstRunHelperImpl::OpenTrayBubble() { 93 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray(); 94 tray->ShowPersistentDefaultView(); 95} 96 97void FirstRunHelperImpl::CloseTrayBubble() { 98 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray(); 99 DCHECK(tray->HasSystemBubble()) << "Tray bubble is closed already."; 100 tray->CloseSystemBubble(); 101} 102 103bool FirstRunHelperImpl::IsTrayBubbleOpened() { 104 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray(); 105 return tray->HasSystemBubble(); 106} 107 108gfx::Rect FirstRunHelperImpl::GetTrayBubbleBounds() { 109 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray(); 110 views::View* bubble = tray->GetSystemBubble()->bubble_view(); 111 return bubble->GetBoundsInScreen(); 112} 113 114gfx::Rect FirstRunHelperImpl::GetHelpButtonBounds() { 115 SystemTray* tray = Shell::GetInstance()->GetPrimarySystemTray(); 116 views::View* help_button = tray->GetHelpButtonView(); 117 return help_button->GetBoundsInScreen(); 118} 119 120} // namespace ash 121 122