Commit 069fc881 authored by ananta's avatar ananta Committed by Commit bot

Ensure that on Windows 7, relaunching the browser via chrome://restart or...

Ensure that on Windows 7, relaunching the browser via chrome://restart or changing about:flags relaunches into Chrome OS mode.

There were two problems here.
1. The viewer process on Windows 7 would not die : Fixed by destroying the window when we get a
   signal from the browser process that the viewer needs to die.

2. Relaunching on Windows 7 would relaunch the existing browser process with the same command line.
   On Windows 8 relaunch launches back into Windows 8 mode as delegate execute has code to launch back
   into the previous mode. On Windows 7 we don't have that luxury. The current approach is to detect
   that we are in Windows 7 in a browser launched to service the viewer process and return that we
   need to launch into Chrome OS mode. Additionally we set the corresponding pref to ensure that
   this is honored.

BUG=413101

Review URL: https://codereview.chromium.org/568623002

Cr-Commit-Position: refs/heads/master@{#294721}
parent 0d1c4968
......@@ -18,6 +18,7 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
#include "base/process/launch.h"
#include "base/process/process_handle.h"
#include "base/strings/string_number_conversions.h"
......@@ -27,16 +28,19 @@
#include "base/win/registry.h"
#include "base/win/scoped_comptr.h"
#include "base/win/windows_version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/first_run/upgrade_util_win.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/shell_util.h"
#include "chrome/installer/util/util_constants.h"
#include "google_update/google_update_idl.h"
#include "ui/base/ui_base_switches.h"
namespace {
......@@ -110,6 +114,21 @@ RelaunchMode RelaunchModeStringToEnum(const std::string& relaunch_mode) {
if (relaunch_mode == kRelaunchModeDesktop)
return RELAUNCH_MODE_DESKTOP;
// On Windows 7 if the current browser is in Chrome OS mode, then restart
// into Chrome OS mode.
if ((base::win::GetVersion() == base::win::VERSION_WIN7) &&
CommandLine::ForCurrentProcess()->HasSwitch(switches::kViewerConnect) &&
g_browser_process->local_state()->HasPrefPath(prefs::kRelaunchMode)) {
// TODO(ananta)
// On Windows 8, the delegate execute process looks up the previously
// launched mode from the registry and relaunches into that mode. We need
// something similar on Windows 7. For now, set the pref to ensure that
// we get relaunched into Chrome OS mode.
g_browser_process->local_state()->SetString(
prefs::kRelaunchMode, upgrade_util::kRelaunchModeMetro);
return RELAUNCH_MODE_METRO;
}
return RELAUNCH_MODE_DEFAULT;
}
......
......@@ -971,6 +971,9 @@ void ChromeAppViewAsh::OnMetroExit(MetroTerminateMethod method) {
if (ui_channel_)
ui_channel_->Close();
HWND core_window = core_window_hwnd();
::PostMessage(core_window, WM_CLOSE, 0, 0);
globals.app_exit->Exit();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment