app_list_controller_ash.cc revision 116680a4aac90f2aa7413d9095a592090648e557
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 12AppListControllerDelegateAsh::AppListControllerDelegateAsh() {} 13 14AppListControllerDelegateAsh::~AppListControllerDelegateAsh() {} 15 16void AppListControllerDelegateAsh::DismissView() { 17 DCHECK(ash::Shell::HasInstance()); 18 if (ash::Shell::GetInstance()->GetAppListTargetVisibility()) 19 ash::Shell::GetInstance()->ToggleAppList(NULL); 20} 21 22gfx::NativeWindow AppListControllerDelegateAsh::GetAppListWindow() { 23 DCHECK(ash::Shell::HasInstance()); 24 return ash::Shell::GetInstance()->GetAppListWindow(); 25} 26 27gfx::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 35gfx::ImageSkia AppListControllerDelegateAsh::GetWindowIcon() { 36 return gfx::ImageSkia(); 37} 38 39bool AppListControllerDelegateAsh::IsAppPinned( 40 const std::string& extension_id) { 41 return ChromeLauncherController::instance()->IsAppPinned(extension_id); 42} 43 44void AppListControllerDelegateAsh::PinApp(const std::string& extension_id) { 45 ChromeLauncherController::instance()->PinAppWithID(extension_id); 46} 47 48void AppListControllerDelegateAsh::UnpinApp(const std::string& extension_id) { 49 ChromeLauncherController::instance()->UnpinAppWithID(extension_id); 50} 51 52AppListControllerDelegate::Pinnable 53 AppListControllerDelegateAsh::GetPinnable() { 54 return ChromeLauncherController::instance()->CanPin() ? PIN_EDITABLE : 55 PIN_FIXED; 56} 57 58void AppListControllerDelegateAsh::OnShowChildDialog() { 59 app_list::AppListView* app_list_view = 60 ash::Shell::GetInstance()->GetAppListView(); 61 if (app_list_view) 62 app_list_view->SetAppListOverlayVisible(true); 63} 64 65void AppListControllerDelegateAsh::OnCloseChildDialog() { 66 app_list::AppListView* app_list_view = 67 ash::Shell::GetInstance()->GetAppListView(); 68 if (app_list_view) 69 app_list_view->SetAppListOverlayVisible(false); 70} 71 72bool AppListControllerDelegateAsh::CanDoCreateShortcutsFlow() { 73 return false; 74} 75 76void AppListControllerDelegateAsh::DoCreateShortcutsFlow( 77 Profile* profile, 78 const std::string& extension_id) { 79 NOTREACHED(); 80} 81 82void AppListControllerDelegateAsh::CreateNewWindow(Profile* profile, 83 bool incognito) { 84 if (incognito) 85 ChromeLauncherController::instance()->CreateNewIncognitoWindow(); 86 else 87 ChromeLauncherController::instance()->CreateNewWindow(); 88} 89 90void AppListControllerDelegateAsh::ActivateApp( 91 Profile* profile, 92 const extensions::Extension* extension, 93 AppListSource source, 94 int event_flags) { 95 ChromeLauncherController::instance()->ActivateApp( 96 extension->id(), 97 AppListSourceToLaunchSource(source), 98 event_flags); 99 100 DismissView(); 101} 102 103void AppListControllerDelegateAsh::LaunchApp( 104 Profile* profile, 105 const extensions::Extension* extension, 106 AppListSource source, 107 int event_flags) { 108 ChromeLauncherController::instance()->LaunchApp( 109 extension->id(), 110 AppListSourceToLaunchSource(source), 111 event_flags); 112 DismissView(); 113} 114 115void AppListControllerDelegateAsh::ShowForProfileByPath( 116 const base::FilePath& profile_path) { 117 // Ash doesn't have profile switching. 118 NOTREACHED(); 119} 120 121bool AppListControllerDelegateAsh::ShouldShowUserIcon() { 122 return false; 123} 124 125ash::LaunchSource AppListControllerDelegateAsh::AppListSourceToLaunchSource( 126 AppListSource source) { 127 switch (source) { 128 case LAUNCH_FROM_APP_LIST: 129 return ash::LAUNCH_FROM_APP_LIST; 130 case LAUNCH_FROM_APP_LIST_SEARCH: 131 return ash::LAUNCH_FROM_APP_LIST_SEARCH; 132 default: 133 return ash::LAUNCH_FROM_UNKNOWN; 134 } 135} 136