app_list_controller_ash.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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()->UnpinAppsWithID(extension_id);
36}
37
38bool AppListControllerDelegateAsh::CanPin() {
39  return ChromeLauncherController::instance()->CanPin();
40}
41
42bool AppListControllerDelegateAsh::CanShowCreateShortcutsDialog() {
43  return false;
44}
45
46void AppListControllerDelegateAsh::CreateNewWindow(Profile* profile,
47                                                   bool incognito) {
48  if (incognito)
49    ChromeLauncherController::instance()->CreateNewIncognitoWindow();
50  else
51    ChromeLauncherController::instance()->CreateNewWindow();
52}
53
54void AppListControllerDelegateAsh::ActivateApp(
55    Profile* profile, const extensions::Extension* extension, int event_flags) {
56  ChromeLauncherController::instance()->ActivateApp(extension->id(),
57                                                    event_flags);
58  DismissView();
59}
60
61void AppListControllerDelegateAsh::LaunchApp(
62    Profile* profile, const extensions::Extension* extension, int event_flags) {
63  ChromeLauncherController::instance()->LaunchApp(extension->id(),
64                                                  event_flags);
65  DismissView();
66}
67
68bool AppListControllerDelegateAsh::ShouldShowUserIcon() {
69  return false;
70}
71