Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / browser_process_platform_part_aurawin.cc
blobd1a00bcbe7474c65d31cdbdc856a0feaca64788e
1 // Copyright (c) 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/browser_process_platform_part_aurawin.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h"
10 #include "base/process/kill.h"
11 #include "base/win/windows_version.h"
12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/first_run/upgrade_util.h"
15 #include "chrome/browser/first_run/upgrade_util_win.h"
16 #include "chrome/browser/lifetime/application_lifetime.h"
17 #include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h"
18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h"
20 #include "content/public/browser/notification_service.h"
22 #include "ui/aura/remote_root_window_host_win.h"
24 BrowserProcessPlatformPart::BrowserProcessPlatformPart() {
25 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
26 // Tell metro viewer to close when we are shutting down.
27 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
28 content::NotificationService::AllSources());
32 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() {
35 void BrowserProcessPlatformPart::OnMetroViewerProcessTerminated() {
36 metro_viewer_process_host_.reset(NULL);
39 void BrowserProcessPlatformPart::PlatformSpecificCommandLineProcessing(
40 const CommandLine& command_line) {
41 // Check for Windows 8 specific commandlines requesting that this process
42 // either connect to an existing viewer or launch a new viewer and
43 // synchronously wait for it to connect.
44 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
45 bool launch = command_line.HasSwitch(switches::kViewerLaunchViaAppId);
46 bool connect = (launch ||
47 (command_line.HasSwitch(switches::kViewerConnect) &&
48 !metro_viewer_process_host_.get()));
49 if (connect) {
50 // Create a host to connect to the Metro viewer process over IPC.
51 metro_viewer_process_host_.reset(new ChromeMetroViewerProcessHost());
52 if (launch) {
53 CHECK(metro_viewer_process_host_->LaunchViewerAndWaitForConnection(
54 command_line.GetSwitchValueNative(
55 switches::kViewerLaunchViaAppId)));
61 void BrowserProcessPlatformPart::Observe(
62 int type,
63 const content::NotificationSource& source,
64 const content::NotificationDetails& details) {
66 DCHECK(type == chrome::NOTIFICATION_APP_TERMINATING);
67 PrefService* pref_service = g_browser_process->local_state();
68 bool is_relaunch = pref_service->GetBoolean(prefs::kWasRestarted);
69 if (is_relaunch) {
70 upgrade_util::RelaunchMode mode =
71 upgrade_util::RelaunchModeStringToEnum(
72 pref_service->GetString(prefs::kRelaunchMode));
73 if (metro_viewer_process_host_.get()) {
74 if (mode == upgrade_util::RELAUNCH_MODE_DESKTOP) {
75 // Metro -> Desktop
76 chrome::ActivateDesktopHelper(chrome::ASH_TERMINATE);
77 } else {
78 // Metro -> Metro
79 aura::HandleMetroExit();