Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / ash / launcher / chrome_launcher_controller_win.cc
blob393ffaa98e9d893bb63c90c246accdf2e8f7b6e7
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 "apps/shell_window.h"
8 #include "apps/shell_window_registry.h"
9 #include "base/path_service.h"
10 #include "base/strings/string16.h"
11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/host_desktop.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "extensions/common/constants.h"
17 #include "ui/aura/remote_root_window_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 apps::ShellWindow* any_existing_window =
26 apps::ShellWindowRegistry::Get(profile())->
27 GetCurrentShellWindowForApp(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;