summaryrefslogtreecommitdiffstats
path: root/win8
diff options
context:
space:
mode:
authorananta <ananta@chromium.org>2014-08-28 14:37:55 -0700
committerCommit bot <commit-bot@chromium.org>2014-08-28 21:38:57 +0000
commit196db19755cd25d7da5371442c2394e1510051ad (patch)
treeb1da263f36a2ca5bed8ee9cb9436d74aa195032a /win8
parent421cc21a251e4828fe3065884a9fdf1a47b49d07 (diff)
downloadchromium_src-196db19755cd25d7da5371442c2394e1510051ad.zip
chromium_src-196db19755cd25d7da5371442c2394e1510051ad.tar.gz
chromium_src-196db19755cd25d7da5371442c2394e1510051ad.tar.bz2
Add relaunch into ASH and desktop support for Chrome on Windows 7.
This is on similar lines as Windows 8. The difference being launching into ASH on Windows 8 launches ASH into Windows 8 metro environment. Reused the existing tunneling we have via delegate_execute to ensure that the calling process is terminated before launching the browser into the other environment. Removed the erstshile Open Ash Desktop and Close Ash Desktop menu options as they are no longer needed and they don't work correctly anyways. BUG=356475 Review URL: https://codereview.chromium.org/498573003 Cr-Commit-Position: refs/heads/master@{#292464}
Diffstat (limited to 'win8')
-rw-r--r--win8/delegate_execute/command_execute_impl.h3
-rw-r--r--win8/delegate_execute/delegate_execute.cc68
-rw-r--r--win8/delegate_execute/delegate_execute_operation.cc19
3 files changed, 68 insertions, 22 deletions
diff --git a/win8/delegate_execute/command_execute_impl.h b/win8/delegate_execute/command_execute_impl.h
index 0fffd4f..f45bcc9 100644
--- a/win8/delegate_execute/command_execute_impl.h
+++ b/win8/delegate_execute/command_execute_impl.h
@@ -81,9 +81,10 @@ class ATL_NO_VTABLE DECLSPEC_UUID("071BB5F2-85A4-424F-BFE7-5F1609BE4C2C")
// IForegroundTransfer
STDMETHOD(AllowForegroundTransfer)(void* reserved);
- private:
static bool FindChromeExe(base::FilePath* chrome_exe);
+ private:
+
static bool path_provider_initialized_;
bool GetLaunchScheme(base::string16* display_name, INTERNET_SCHEME* scheme);
diff --git a/win8/delegate_execute/delegate_execute.cc b/win8/delegate_execute/delegate_execute.cc
index 3bd1ef1..d78210b 100644
--- a/win8/delegate_execute/delegate_execute.cc
+++ b/win8/delegate_execute/delegate_execute.cc
@@ -17,6 +17,7 @@
#include "base/win/scoped_com_initializer.h"
#include "base/win/scoped_comptr.h"
#include "base/win/scoped_handle.h"
+#include "base/win/windows_version.h"
#include "breakpad/src/client/windows/handler/exception_handler.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -117,21 +118,58 @@ int RelaunchChrome(const DelegateExecuteOperation& operation) {
AtlTrace("No relaunch mutex found\n");
}
- base::win::ScopedCOMInitializer com_initializer;
-
- base::string16 relaunch_flags(operation.relaunch_flags());
- SHELLEXECUTEINFO sei = { sizeof(sei) };
- sei.fMask = SEE_MASK_FLAG_LOG_USAGE;
- sei.nShow = SW_SHOWNORMAL;
- sei.lpFile = operation.shortcut().value().c_str();
- sei.lpParameters = relaunch_flags.c_str();
-
- AtlTrace(L"Relaunching Chrome via shortcut [%ls]\n", sei.lpFile);
-
- if (!::ShellExecuteExW(&sei)) {
- int error = HRESULT_FROM_WIN32(::GetLastError());
- AtlTrace("ShellExecute returned 0x%08X\n", error);
- return error;
+ // On Windows 8+ to launch Chrome we rely on Windows to use the
+ // IExecuteCommand interface exposed by delegate_execute to launch Chrome
+ // into Windows 8 metro mode or desktop.
+ // On Windows 7 we don't use delegate_execute and instead use plain vanilla
+ // ShellExecute to launch Chrome into ASH or desktop.
+ if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
+ base::win::ScopedCOMInitializer com_initializer;
+
+ base::string16 relaunch_flags(operation.relaunch_flags());
+ SHELLEXECUTEINFO sei = { sizeof(sei) };
+ sei.fMask = SEE_MASK_FLAG_LOG_USAGE;
+ sei.nShow = SW_SHOWNORMAL;
+ sei.lpFile = operation.shortcut().value().c_str();
+ sei.lpParameters = relaunch_flags.c_str();
+
+ AtlTrace(L"Relaunching Chrome via shortcut [%ls]\n", sei.lpFile);
+
+ if (!::ShellExecuteExW(&sei)) {
+ int error = HRESULT_FROM_WIN32(::GetLastError());
+ AtlTrace("ShellExecute returned 0x%08X\n", error);
+ return error;
+ }
+ } else {
+ base::FilePath chrome_exe_path;
+ bool found_exe = CommandExecuteImpl::FindChromeExe(&chrome_exe_path);
+ DCHECK(found_exe);
+ if (found_exe) {
+ bool launch_ash = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kForceImmersive);
+ if (launch_ash) {
+ AtlTrace(L"Relaunching Chrome into Windows ASH on Windows 7\n");
+ } else {
+ AtlTrace(L"Relaunching Chrome into Desktop From ASH on Windows 7\n");
+ }
+ SHELLEXECUTEINFO sei = { sizeof(sei) };
+ sei.fMask = SEE_MASK_FLAG_LOG_USAGE;
+ sei.nShow = SW_SHOWNORMAL;
+ // No point in using the shortcut if we are launching into ASH as any
+ // additonal command line switches specified in the shortcut will be
+ // ignored. This is because we don't have a good way to send the command
+ // line switches from the viewer to the browser process.
+ sei.lpFile = (launch_ash || operation.shortcut().empty()) ?
+ chrome_exe_path.value().c_str() :
+ operation.shortcut().value().c_str();
+ sei.lpParameters =
+ launch_ash ? L"-ServerName:DefaultBrowserServer" : NULL;
+ if (!::ShellExecuteExW(&sei)) {
+ int error = HRESULT_FROM_WIN32(::GetLastError());
+ AtlTrace("ShellExecute returned 0x%08X\n", error);
+ return error;
+ }
+ }
}
return S_OK;
}
diff --git a/win8/delegate_execute/delegate_execute_operation.cc b/win8/delegate_execute/delegate_execute_operation.cc
index 91e5eff..ac36427 100644
--- a/win8/delegate_execute/delegate_execute_operation.cc
+++ b/win8/delegate_execute/delegate_execute_operation.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
+#include "base/win/windows_version.h"
#include "chrome/common/chrome_switches.h"
#include "win8/delegate_execute/delegate_execute_util.h"
@@ -20,13 +21,19 @@ DelegateExecuteOperation::~DelegateExecuteOperation() {
}
bool DelegateExecuteOperation::Init(const CommandLine* cmd_line) {
- base::FilePath shortcut(
- cmd_line->GetSwitchValuePath(switches::kRelaunchShortcut));
- if (shortcut.empty()) {
- operation_type_ = DELEGATE_EXECUTE;
- return true;
+ if (base::win::GetVersion() >= base::win::VERSION_WIN7) {
+ base::FilePath shortcut(
+ cmd_line->GetSwitchValuePath(switches::kRelaunchShortcut));
+ // On Windows 7 the command line coming in may not have a path to the
+ // shortcut to launch Chrome. We ignore the shortcut and just do a regular
+ // ShellExecute of chrome.exe in this case.
+ if (shortcut.empty() &&
+ base::win::GetVersion() >= base::win::VERSION_WIN8) {
+ operation_type_ = DELEGATE_EXECUTE;
+ return true;
+ }
+ relaunch_shortcut_ = shortcut;
}
- relaunch_shortcut_ = shortcut;
mutex_ = cmd_line->GetSwitchValueNative(switches::kWaitForMutex);
if (mutex_.empty())
return false;