app_list_controller_ash.cc revision 68043e1e95eeb07d5cae7aca370b26518b0867d6
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
38bool AppListControllerDelegateAsh::CanPin() {
39  return ChromeLauncherController::instance()->CanPin();
40}
41
42bool AppListControllerDelegateAsh::CanDoCreateShortcutsFlow(
43    bool is_platform_app) {
44  return false;
45}
46
47void AppListControllerDelegateAsh::CreateNewWindow(Profile* profile,
48                                                   bool incognito) {
49  if (incognito)
50    ChromeLauncherController::instance()->CreateNewIncognitoWindow();
51  else
52    ChromeLauncherController::instance()->CreateNewWindow();
53}
54
55void AppListControllerDelegateAsh::ActivateApp(
56    Profile* profile,
57    const extensions::Extension* extension,
58    AppListSource source,
59    int event_flags) {
60  ChromeLauncherController::instance()->ActivateApp(
61      extension->id(),
62      AppListSourceToLaunchSource(source),
63      event_flags);
64
65  DismissView();
66}
67
68void AppListControllerDelegateAsh::LaunchApp(
69    Profile* profile,
70    const extensions::Extension* extension,
71    AppListSource source,
72    int event_flags) {
73  ChromeLauncherController::instance()->LaunchApp(
74      extension->id(),
75      AppListSourceToLaunchSource(source),
76      event_flags);
77  DismissView();
78}
79
80void AppListControllerDelegateAsh::ShowForProfileByPath(
81    const base::FilePath& profile_path) {
82  // Ash doesn't have profile switching.
83  NOTREACHED();
84}
85
86bool AppListControllerDelegateAsh::ShouldShowUserIcon() {
87  return false;
88}
89
90ash::LaunchSource AppListControllerDelegateAsh::AppListSourceToLaunchSource(
91    AppListSource source) {
92  switch (source) {
93    case LAUNCH_FROM_APP_LIST:
94      return ash::LAUNCH_FROM_APP_LIST;
95    case LAUNCH_FROM_APP_LIST_SEARCH:
96      return ash::LAUNCH_FROM_APP_LIST_SEARCH;
97    default:
98      return ash::LAUNCH_FROM_UNKNOWN;
99  }
100}
101