app_list_controller_ash.cc revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
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 25bool AppListControllerDelegateAsh::IsAppPinned( 26 const std::string& extension_id) { 27 return ChromeLauncherController::instance()->IsAppPinned(extension_id); 28} 29 30void AppListControllerDelegateAsh::PinApp(const std::string& extension_id) { 31 ChromeLauncherController::instance()->PinAppWithID(extension_id); 32} 33 34void AppListControllerDelegateAsh::UnpinApp(const std::string& extension_id) { 35 ChromeLauncherController::instance()->UnpinAppWithID(extension_id); 36} 37 38AppListControllerDelegate::Pinnable 39 AppListControllerDelegateAsh::GetPinnable() { 40 return ChromeLauncherController::instance()->CanPin() ? PIN_EDITABLE : 41 PIN_FIXED; 42} 43 44void AppListControllerDelegateAsh::CreateNewWindow(Profile* profile, 45 bool incognito) { 46 if (incognito) 47 ChromeLauncherController::instance()->CreateNewIncognitoWindow(); 48 else 49 ChromeLauncherController::instance()->CreateNewWindow(); 50} 51 52void AppListControllerDelegateAsh::ActivateApp( 53 Profile* profile, 54 const extensions::Extension* extension, 55 AppListSource source, 56 int event_flags) { 57 ChromeLauncherController::instance()->ActivateApp( 58 extension->id(), 59 AppListSourceToLaunchSource(source), 60 event_flags); 61 62 DismissView(); 63} 64 65void AppListControllerDelegateAsh::LaunchApp( 66 Profile* profile, 67 const extensions::Extension* extension, 68 AppListSource source, 69 int event_flags) { 70 ChromeLauncherController::instance()->LaunchApp( 71 extension->id(), 72 AppListSourceToLaunchSource(source), 73 event_flags); 74 DismissView(); 75} 76 77void AppListControllerDelegateAsh::ShowForProfileByPath( 78 const base::FilePath& profile_path) { 79 // Ash doesn't have profile switching. 80 NOTREACHED(); 81} 82 83bool AppListControllerDelegateAsh::ShouldShowUserIcon() { 84 return false; 85} 86 87ash::LaunchSource AppListControllerDelegateAsh::AppListSourceToLaunchSource( 88 AppListSource source) { 89 switch (source) { 90 case LAUNCH_FROM_APP_LIST: 91 return ash::LAUNCH_FROM_APP_LIST; 92 case LAUNCH_FROM_APP_LIST_SEARCH: 93 return ash::LAUNCH_FROM_APP_LIST_SEARCH; 94 default: 95 return ash::LAUNCH_FROM_UNKNOWN; 96 } 97} 98