OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include "apps/app_window.h" | |
8 #include "apps/app_window_registry.h" | |
9 #include "base/path_service.h" | 7 #include "base/path_service.h" |
10 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
11 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/host_desktop.h" | 12 #include "chrome/browser/ui/host_desktop.h" |
15 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "extensions/browser/app_window/app_window.h" |
| 15 #include "extensions/browser/app_window/app_window_registry.h" |
16 #include "extensions/common/constants.h" | 16 #include "extensions/common/constants.h" |
17 #include "ui/aura/remote_window_tree_host_win.h" | 17 #include "ui/aura/remote_window_tree_host_win.h" |
18 | 18 |
19 bool ChromeLauncherController::LaunchedInNativeDesktop( | 19 bool ChromeLauncherController::LaunchedInNativeDesktop( |
20 const std::string& app_id) { | 20 const std::string& app_id) { |
21 // If an app has any existing windows on the native desktop, funnel the | 21 // If an app has any existing windows on the native desktop, funnel the |
22 // launch request through the viewer process to desktop Chrome. This allows | 22 // launch request through the viewer process to desktop Chrome. This allows |
23 // Ash to relinquish foreground window status and trigger a switch to | 23 // Ash to relinquish foreground window status and trigger a switch to |
24 // desktop mode. | 24 // desktop mode. |
25 apps::AppWindow* any_existing_window = | 25 extensions::AppWindow* any_existing_window = |
26 apps::AppWindowRegistry::Get(profile()) | 26 extensions::AppWindowRegistry::Get(profile()) |
27 ->GetCurrentAppWindowForApp(app_id); | 27 ->GetCurrentAppWindowForApp(app_id); |
28 if (!any_existing_window || | 28 if (!any_existing_window || |
29 chrome::GetHostDesktopTypeForNativeWindow( | 29 chrome::GetHostDesktopTypeForNativeWindow( |
30 any_existing_window->GetNativeWindow()) | 30 any_existing_window->GetNativeWindow()) |
31 != chrome::HOST_DESKTOP_TYPE_NATIVE) { | 31 != chrome::HOST_DESKTOP_TYPE_NATIVE) { |
32 return false; | 32 return false; |
33 } | 33 } |
34 base::FilePath exe_path; | 34 base::FilePath exe_path; |
35 if (!PathService::Get(base::FILE_EXE, &exe_path)) { | 35 if (!PathService::Get(base::FILE_EXE, &exe_path)) { |
36 NOTREACHED(); | 36 NOTREACHED(); |
37 return false; | 37 return false; |
38 } | 38 } |
39 | 39 |
40 // Construct parameters for ShellExecuteEx that mimic a desktop shortcut | 40 // Construct parameters for ShellExecuteEx that mimic a desktop shortcut |
41 // for the app in the current Profile. | 41 // for the app in the current Profile. |
42 std::string spec = base::StringPrintf("\"--%s=%s\" \"--%s=%s\"", | 42 std::string spec = base::StringPrintf("\"--%s=%s\" \"--%s=%s\"", |
43 switches::kProfileDirectory, | 43 switches::kProfileDirectory, |
44 profile_->GetPath().BaseName().AsUTF8Unsafe().c_str(), | 44 profile_->GetPath().BaseName().AsUTF8Unsafe().c_str(), |
45 switches::kAppId, | 45 switches::kAppId, |
46 app_id.c_str()); | 46 app_id.c_str()); |
47 aura::RemoteWindowTreeHostWin::Instance()->HandleOpenURLOnDesktop( | 47 aura::RemoteWindowTreeHostWin::Instance()->HandleOpenURLOnDesktop( |
48 exe_path, base::UTF8ToUTF16(spec)); | 48 exe_path, base::UTF8ToUTF16(spec)); |
49 return true; | 49 return true; |
50 } | 50 } |
OLD | NEW |