1 // Copyright (c) 2012 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 "chrome/browser/ui/ash/app_list/app_list_controller_ash.h" 6 7 #include "ash/shell.h" 8 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 9 #include "extensions/common/extension.h" 10 #include "ui/app_list/views/app_list_view.h" 11 12 AppListControllerDelegateAsh::AppListControllerDelegateAsh() {} 13 14 AppListControllerDelegateAsh::~AppListControllerDelegateAsh() {} 15 16 void AppListControllerDelegateAsh::DismissView() { 17 DCHECK(ash::Shell::HasInstance()); 18 if (ash::Shell::GetInstance()->GetAppListTargetVisibility()) 19 ash::Shell::GetInstance()->ToggleAppList(NULL); 20 } 21 22 gfx::NativeWindow AppListControllerDelegateAsh::GetAppListWindow() { 23 DCHECK(ash::Shell::HasInstance()); 24 return ash::Shell::GetInstance()->GetAppListWindow(); 25 } 26 27 gfx::Rect AppListControllerDelegateAsh::GetAppListBounds() { 28 app_list::AppListView* app_list_view = 29 ash::Shell::GetInstance()->GetAppListView(); 30 if (app_list_view) 31 return app_list_view->GetBoundsInScreen(); 32 return gfx::Rect(); 33 } 34 35 gfx::ImageSkia AppListControllerDelegateAsh::GetWindowIcon() { 36 return gfx::ImageSkia(); 37 } 38 39 bool AppListControllerDelegateAsh::IsAppPinned( 40 const std::string& extension_id) { 41 return ChromeLauncherController::instance()->IsAppPinned(extension_id); 42 } 43 44 void AppListControllerDelegateAsh::PinApp(const std::string& extension_id) { 45 ChromeLauncherController::instance()->PinAppWithID(extension_id); 46 } 47 48 void AppListControllerDelegateAsh::UnpinApp(const std::string& extension_id) { 49 ChromeLauncherController::instance()->UnpinAppWithID(extension_id); 50 } 51 52 AppListControllerDelegate::Pinnable 53 AppListControllerDelegateAsh::GetPinnable() { 54 return ChromeLauncherController::instance()->CanPin() ? PIN_EDITABLE : 55 PIN_FIXED; 56 } 57 58 bool AppListControllerDelegateAsh::CanDoCreateShortcutsFlow() { 59 return false; 60 } 61 62 void AppListControllerDelegateAsh::DoCreateShortcutsFlow( 63 Profile* profile, 64 const std::string& extension_id) { 65 NOTREACHED(); 66 } 67 68 void AppListControllerDelegateAsh::CreateNewWindow(Profile* profile, 69 bool incognito) { 70 if (incognito) 71 ChromeLauncherController::instance()->CreateNewIncognitoWindow(); 72 else 73 ChromeLauncherController::instance()->CreateNewWindow(); 74 } 75 76 void AppListControllerDelegateAsh::ActivateApp( 77 Profile* profile, 78 const extensions::Extension* extension, 79 AppListSource source, 80 int event_flags) { 81 ChromeLauncherController::instance()->ActivateApp( 82 extension->id(), 83 AppListSourceToLaunchSource(source), 84 event_flags); 85 86 DismissView(); 87 } 88 89 void AppListControllerDelegateAsh::LaunchApp( 90 Profile* profile, 91 const extensions::Extension* extension, 92 AppListSource source, 93 int event_flags) { 94 ChromeLauncherController::instance()->LaunchApp( 95 extension->id(), 96 AppListSourceToLaunchSource(source), 97 event_flags); 98 DismissView(); 99 } 100 101 void AppListControllerDelegateAsh::ShowForProfileByPath( 102 const base::FilePath& profile_path) { 103 // Ash doesn't have profile switching. 104 NOTREACHED(); 105 } 106 107 bool AppListControllerDelegateAsh::ShouldShowUserIcon() { 108 return false; 109 } 110 111 ash::LaunchSource AppListControllerDelegateAsh::AppListSourceToLaunchSource( 112 AppListSource source) { 113 switch (source) { 114 case LAUNCH_FROM_APP_LIST: 115 return ash::LAUNCH_FROM_APP_LIST; 116 case LAUNCH_FROM_APP_LIST_SEARCH: 117 return ash::LAUNCH_FROM_APP_LIST_SEARCH; 118 default: 119 return ash::LAUNCH_FROM_UNKNOWN; 120 } 121 } 122