Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / app_list / win / app_list_controller_delegate_win.cc
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/app_window.h"
8 #include "apps/app_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
17 AppListControllerDelegateWin::AppListControllerDelegateWin(
18     AppListServiceWin* service)
19     : AppListControllerDelegateImpl(service),
20       service_(service) {}
21
22 AppListControllerDelegateWin::~AppListControllerDelegateWin() {}
23
24 bool AppListControllerDelegateWin::ForceNativeDesktop() const {
25   return true;
26 }
27
28 void AppListControllerDelegateWin::ViewClosing() {
29   service_->OnAppListClosing();
30 }
31
32 gfx::ImageSkia AppListControllerDelegateWin::GetWindowIcon() {
33   gfx::ImageSkia* resource = ResourceBundle::GetSharedInstance().
34       GetImageSkiaNamed(GetAppListIconResourceId());
35   return *resource;
36 }
37
38 void AppListControllerDelegateWin::OnShowExtensionPrompt() {
39   service_->set_can_close(false);
40 }
41
42 void AppListControllerDelegateWin::OnCloseExtensionPrompt() {
43   service_->set_can_close(true);
44 }
45
46 bool AppListControllerDelegateWin::CanDoCreateShortcutsFlow() {
47   return true;
48 }
49
50 void AppListControllerDelegateWin::FillLaunchParams(AppLaunchParams* params) {
51   params->desktop_type = chrome::HOST_DESKTOP_TYPE_NATIVE;
52   apps::AppWindow* any_existing_window =
53       apps::AppWindowRegistry::Get(params->profile)
54           ->GetCurrentAppWindowForApp(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 }