app_list_controller_delegate_win.cc revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
1// Copyright 2013 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/views/app_list/win/app_list_controller_delegate_win.h"
6
7#include "apps/shell_window.h"
8#include "apps/shell_window_registry.h"
9#include "chrome/browser/metro_utils/metro_chrome_win.h"
10#include "chrome/browser/ui/app_list/app_list_icon_win.h"
11#include "chrome/browser/ui/extensions/application_launch.h"
12#include "chrome/browser/ui/host_desktop.h"
13#include "chrome/browser/ui/views/app_list/win/app_list_service_win.h"
14#include "extensions/common/extension.h"
15#include "ui/base/resource/resource_bundle.h"
16
17AppListControllerDelegateWin::AppListControllerDelegateWin(
18    AppListServiceWin* service)
19    : AppListControllerDelegateImpl(service),
20      service_(service) {}
21
22AppListControllerDelegateWin::~AppListControllerDelegateWin() {}
23
24bool AppListControllerDelegateWin::ForceNativeDesktop() const {
25  return true;
26}
27
28void AppListControllerDelegateWin::ViewClosing() {
29  service_->OnAppListClosing();
30}
31
32gfx::ImageSkia AppListControllerDelegateWin::GetWindowIcon() {
33  gfx::ImageSkia* resource = ResourceBundle::GetSharedInstance().
34      GetImageSkiaNamed(GetAppListIconResourceId());
35  return *resource;
36}
37
38void AppListControllerDelegateWin::OnShowExtensionPrompt() {
39  service_->set_can_close(false);
40}
41
42void AppListControllerDelegateWin::OnCloseExtensionPrompt() {
43  service_->set_can_close(true);
44}
45
46bool AppListControllerDelegateWin::CanDoCreateShortcutsFlow() {
47  return true;
48}
49
50void AppListControllerDelegateWin::FillLaunchParams(AppLaunchParams* params) {
51  params->desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE;
52  apps::ShellWindow* any_existing_window =
53      apps::ShellWindowRegistry::Get(params->profile)->
54          GetCurrentShellWindowForApp(params->extension->id());
55  if (any_existing_window &&
56      chrome::GetHostDesktopTypeForNativeWindow(
57          any_existing_window->GetNativeWindow())
58      != chrome::HOST_DESKTOP_TYPE_NATIVE) {
59    params->desktop_type = chrome::HOST_DESKTOP_TYPE_ASH;
60    chrome::ActivateMetroChrome();
61  }
62}
63