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