Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / ash / launcher / chrome_launcher_controller_win.cc
blob29ec4ac1ed777b74b59734b9b64578d7553dcd52
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.
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
7 #include "base/path_service.h"
8 #include "base/strings/string16.h"
9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/host_desktop.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"
17 #include "ui/aura/remote_window_tree_host_win.h"
19 bool ChromeLauncherController::LaunchedInNativeDesktop(
20 const std::string& app_id) {
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
23 // Ash to relinquish foreground window status and trigger a switch to
24 // desktop mode.
25 extensions::AppWindow* any_existing_window =
26 extensions::AppWindowRegistry::Get(profile())
27 ->GetCurrentAppWindowForApp(app_id);
28 if (!any_existing_window ||
29 chrome::GetHostDesktopTypeForNativeWindow(
30 any_existing_window->GetNativeWindow())
31 != chrome::HOST_DESKTOP_TYPE_NATIVE) {
32 return false;
34 base::FilePath exe_path;
35 if (!PathService::Get(base::FILE_EXE, &exe_path)) {
36 NOTREACHED();
37 return false;
40 // Construct parameters for ShellExecuteEx that mimic a desktop shortcut
41 // for the app in the current Profile.
42 std::string spec = base::StringPrintf("\"--%s=%s\" \"--%s=%s\"",
43 switches::kProfileDirectory,
44 profile_->GetPath().BaseName().AsUTF8Unsafe().c_str(),
45 switches::kAppId,
46 app_id.c_str());
47 aura::RemoteWindowTreeHostWin::Instance()->HandleOpenURLOnDesktop(
48 exe_path, base::UTF8ToUTF16(spec));
49 return true;