app_list_controller_ash.cc revision 6e8cce623b6e4fe0c9e4af605d675dd9d0338c38
1c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// Use of this source code is governed by a BSD-style license that can be 3c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// found in the LICENSE file. 4c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant#include "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" 6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant 7c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant#include "ash/shell.h" 8c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 9c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant#include "extensions/common/extension.h" 10c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant#include "ui/app_list/views/app_list_view.h" 11c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 12c52f43e72dfcea03037729649da84c23b3beb04aHoward HinnantAppListControllerDelegateAsh::AppListControllerDelegateAsh() {} 13c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 14c52f43e72dfcea03037729649da84c23b3beb04aHoward HinnantAppListControllerDelegateAsh::~AppListControllerDelegateAsh() {} 15c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 16c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantvoid AppListControllerDelegateAsh::DismissView() { 17c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant DCHECK(ash::Shell::HasInstance()); 18c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant ash::Shell::GetInstance()->DismissAppList(); 19c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant} 20c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 21c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantgfx::NativeWindow AppListControllerDelegateAsh::GetAppListWindow() { 22c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant DCHECK(ash::Shell::HasInstance()); 23c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant return ash::Shell::GetInstance()->GetAppListWindow(); 24c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant} 25c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 26c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantgfx::Rect AppListControllerDelegateAsh::GetAppListBounds() { 27c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant app_list::AppListView* app_list_view = 28c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant ash::Shell::GetInstance()->GetAppListView(); 29c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant if (app_list_view) 30c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant return app_list_view->GetBoundsInScreen(); 31c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant return gfx::Rect(); 32c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant} 33c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 34c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantgfx::ImageSkia AppListControllerDelegateAsh::GetWindowIcon() { 35c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant return gfx::ImageSkia(); 36c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant} 37c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 38c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantbool AppListControllerDelegateAsh::IsAppPinned( 39c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant const std::string& extension_id) { 40c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant return ChromeLauncherController::instance()->IsAppPinned(extension_id); 41c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant} 42c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 43c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantvoid AppListControllerDelegateAsh::PinApp(const std::string& extension_id) { 44c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant ChromeLauncherController::instance()->PinAppWithID(extension_id); 45c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant} 46c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant 47c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantvoid AppListControllerDelegateAsh::UnpinApp(const std::string& extension_id) { 48c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant ChromeLauncherController::instance()->UnpinAppWithID(extension_id); 49c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant} 50 51AppListControllerDelegate::Pinnable 52 AppListControllerDelegateAsh::GetPinnable() { 53 return ChromeLauncherController::instance()->CanPin() ? PIN_EDITABLE : 54 PIN_FIXED; 55} 56 57void AppListControllerDelegateAsh::OnShowChildDialog() { 58 app_list::AppListView* app_list_view = 59 ash::Shell::GetInstance()->GetAppListView(); 60 if (app_list_view) 61 app_list_view->SetAppListOverlayVisible(true); 62} 63 64void AppListControllerDelegateAsh::OnCloseChildDialog() { 65 app_list::AppListView* app_list_view = 66 ash::Shell::GetInstance()->GetAppListView(); 67 if (app_list_view) 68 app_list_view->SetAppListOverlayVisible(false); 69} 70 71bool AppListControllerDelegateAsh::CanDoCreateShortcutsFlow() { 72 return false; 73} 74 75void AppListControllerDelegateAsh::DoCreateShortcutsFlow( 76 Profile* profile, 77 const std::string& extension_id) { 78 NOTREACHED(); 79} 80 81void AppListControllerDelegateAsh::CreateNewWindow(Profile* profile, 82 bool incognito) { 83 if (incognito) 84 ChromeLauncherController::instance()->CreateNewIncognitoWindow(); 85 else 86 ChromeLauncherController::instance()->CreateNewWindow(); 87} 88 89void AppListControllerDelegateAsh::ActivateApp( 90 Profile* profile, 91 const extensions::Extension* extension, 92 AppListSource source, 93 int event_flags) { 94 ChromeLauncherController::instance()->ActivateApp( 95 extension->id(), 96 AppListSourceToLaunchSource(source), 97 event_flags); 98 99 DismissView(); 100} 101 102void AppListControllerDelegateAsh::LaunchApp( 103 Profile* profile, 104 const extensions::Extension* extension, 105 AppListSource source, 106 int event_flags) { 107 ChromeLauncherController::instance()->LaunchApp( 108 extension->id(), 109 AppListSourceToLaunchSource(source), 110 event_flags); 111 DismissView(); 112} 113 114void AppListControllerDelegateAsh::ShowForProfileByPath( 115 const base::FilePath& profile_path) { 116 // Ash doesn't have profile switching. 117 NOTREACHED(); 118} 119 120bool AppListControllerDelegateAsh::ShouldShowUserIcon() { 121 return false; 122} 123 124ash::LaunchSource AppListControllerDelegateAsh::AppListSourceToLaunchSource( 125 AppListSource source) { 126 switch (source) { 127 case LAUNCH_FROM_APP_LIST: 128 return ash::LAUNCH_FROM_APP_LIST; 129 case LAUNCH_FROM_APP_LIST_SEARCH: 130 return ash::LAUNCH_FROM_APP_LIST_SEARCH; 131 default: 132 return ash::LAUNCH_FROM_UNKNOWN; 133 } 134} 135