summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzturner@chromium.org <zturner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-07 09:14:53 +0000
committerzturner@chromium.org <zturner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-07 09:14:53 +0000
commit077b34bc2416ba9a9c443f5e78de31f3fbb9f090 (patch)
treeecaeb2dce9850eab07695c0facd3f832bfad95a3
parentfae06bc06542c92a5b9c2a59697c57140a8460d3 (diff)
downloadchromium_src-077b34bc2416ba9a9c443f5e78de31f3fbb9f090.zip
chromium_src-077b34bc2416ba9a9c443f5e78de31f3fbb9f090.tar.gz
chromium_src-077b34bc2416ba9a9c443f5e78de31f3fbb9f090.tar.bz2
Make delegate_execute GetLaunchMode() check for default browser.
BUG=350078 Review URL: https://codereview.chromium.org/189113002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255562 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/installer/util/shell_util.cc54
-rw-r--r--chrome/installer/util/shell_util.h5
-rw-r--r--win8/delegate_execute/command_execute_impl.cc36
3 files changed, 66 insertions, 29 deletions
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index 96ab1e6..10a968b 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -1048,6 +1048,7 @@ bool ShortNameFromPath(const base::FilePath& path, base::string16* short_path) {
// did not perform validation on the ProgID registered as the current default.
// As a result, stale ProgIDs could be returned, leading to false positives.
ShellUtil::DefaultState ProbeCurrentDefaultHandlers(
+ const base::FilePath& chrome_exe,
const wchar_t* const* protocols,
size_t num_protocols) {
base::win::ScopedComPtr<IApplicationAssociationRegistration> registration;
@@ -1057,11 +1058,6 @@ ShellUtil::DefaultState ProbeCurrentDefaultHandlers(
return ShellUtil::UNKNOWN_DEFAULT;
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- base::FilePath chrome_exe;
- if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
- NOTREACHED();
- return ShellUtil::UNKNOWN_DEFAULT;
- }
base::string16 prog_id(dist->GetBrowserProgIdPrefix());
prog_id += ShellUtil::GetCurrentInstallationSuffix(dist, chrome_exe.value());
@@ -1079,6 +1075,7 @@ ShellUtil::DefaultState ProbeCurrentDefaultHandlers(
// Probe using IApplicationAssociationRegistration::QueryAppIsDefault (Vista and
// Windows 7); see ProbeProtocolHandlers.
ShellUtil::DefaultState ProbeAppIsDefaultHandlers(
+ const base::FilePath& chrome_exe,
const wchar_t* const* protocols,
size_t num_protocols) {
base::win::ScopedComPtr<IApplicationAssociationRegistration> registration;
@@ -1088,11 +1085,6 @@ ShellUtil::DefaultState ProbeAppIsDefaultHandlers(
return ShellUtil::UNKNOWN_DEFAULT;
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- base::FilePath chrome_exe;
- if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
- NOTREACHED();
- return ShellUtil::UNKNOWN_DEFAULT;
- }
base::string16 app_name(
ShellUtil::GetApplicationName(dist, chrome_exe.value()));
@@ -1111,18 +1103,12 @@ ShellUtil::DefaultState ProbeAppIsDefaultHandlers(
// Probe the current commands registered to handle the shell "open" verb for
// |protocols| (Windows XP); see ProbeProtocolHandlers.
ShellUtil::DefaultState ProbeOpenCommandHandlers(
+ const base::FilePath& chrome_exe,
const wchar_t* const* protocols,
size_t num_protocols) {
- // Get the path to the current exe (Chrome).
- base::FilePath app_path;
- if (!PathService::Get(base::FILE_EXE, &app_path)) {
- LOG(ERROR) << "Error getting app exe path";
- return ShellUtil::UNKNOWN_DEFAULT;
- }
-
// Get its short (8.3) form.
base::string16 short_app_path;
- if (!ShortNameFromPath(app_path, &short_app_path))
+ if (!ShortNameFromPath(chrome_exe, &short_app_path))
return ShellUtil::UNKNOWN_DEFAULT;
const HKEY root_key = HKEY_CLASSES_ROOT;
@@ -1158,6 +1144,7 @@ ShellUtil::DefaultState ProbeOpenCommandHandlers(
// Chrome is the default handler for |protocols|. Returns IS_DEFAULT
// only if Chrome is the default for all specified protocols.
ShellUtil::DefaultState ProbeProtocolHandlers(
+ const base::FilePath& chrome_exe,
const wchar_t* const* protocols,
size_t num_protocols) {
DCHECK(!num_protocols || protocols);
@@ -1169,11 +1156,11 @@ ShellUtil::DefaultState ProbeProtocolHandlers(
const base::win::Version windows_version = base::win::GetVersion();
if (windows_version >= base::win::VERSION_WIN8)
- return ProbeCurrentDefaultHandlers(protocols, num_protocols);
+ return ProbeCurrentDefaultHandlers(chrome_exe, protocols, num_protocols);
else if (windows_version >= base::win::VERSION_VISTA)
- return ProbeAppIsDefaultHandlers(protocols, num_protocols);
+ return ProbeAppIsDefaultHandlers(chrome_exe, protocols, num_protocols);
- return ProbeOpenCommandHandlers(protocols, num_protocols);
+ return ProbeOpenCommandHandlers(chrome_exe, protocols, num_protocols);
}
// (Windows 8+) Finds and stores an app shortcuts folder path in *|path|.
@@ -1771,6 +1758,17 @@ base::string16 ShellUtil::BuildAppModelId(
}
ShellUtil::DefaultState ShellUtil::GetChromeDefaultState() {
+ base::FilePath app_path;
+ if (!PathService::Get(base::FILE_EXE, &app_path)) {
+ NOTREACHED();
+ return ShellUtil::UNKNOWN_DEFAULT;
+ }
+
+ return GetChromeDefaultStateFromPath(app_path);
+}
+
+ShellUtil::DefaultState ShellUtil::GetChromeDefaultStateFromPath(
+ const base::FilePath& chrome_exe) {
BrowserDistribution* distribution = BrowserDistribution::GetDistribution();
if (distribution->GetDefaultBrowserControlPolicy() ==
BrowserDistribution::DEFAULT_BROWSER_UNSUPPORTED) {
@@ -1786,7 +1784,9 @@ ShellUtil::DefaultState ShellUtil::GetChromeDefaultState() {
// flag. There is doubtless some other key we can hook into to cause "Repair"
// to show up in Add/Remove programs for us.
static const wchar_t* const kChromeProtocols[] = { L"http", L"https" };
- return ProbeProtocolHandlers(kChromeProtocols, arraysize(kChromeProtocols));
+ return ProbeProtocolHandlers(chrome_exe,
+ kChromeProtocols,
+ arraysize(kChromeProtocols));
}
ShellUtil::DefaultState ShellUtil::GetChromeDefaultProtocolClientState(
@@ -1800,8 +1800,16 @@ ShellUtil::DefaultState ShellUtil::GetChromeDefaultProtocolClientState(
if (protocol.empty())
return UNKNOWN_DEFAULT;
+ base::FilePath chrome_exe;
+ if (!PathService::Get(base::FILE_EXE, &chrome_exe)) {
+ NOTREACHED();
+ return ShellUtil::UNKNOWN_DEFAULT;
+ }
+
const wchar_t* const protocols[] = { protocol.c_str() };
- return ProbeProtocolHandlers(protocols, arraysize(protocols));
+ return ProbeProtocolHandlers(chrome_exe,
+ protocols,
+ arraysize(protocols));
}
// static
diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h
index d8b4073..bf0f218 100644
--- a/chrome/installer/util/shell_util.h
+++ b/chrome/installer/util/shell_util.h
@@ -412,6 +412,11 @@ class ShellUtil {
// Returns the DefaultState of Chrome for HTTP and HTTPS.
static DefaultState GetChromeDefaultState();
+ // Returns the DefaultState of the Chrome instance with the specified path
+ // for HTTP and HTTPs.
+ static DefaultState GetChromeDefaultStateFromPath(
+ const base::FilePath& chrome_exe);
+
// Returns the DefaultState of Chrome for |protocol|.
static DefaultState GetChromeDefaultProtocolClientState(
const base::string16& protocol);
diff --git a/win8/delegate_execute/command_execute_impl.cc b/win8/delegate_execute/command_execute_impl.cc
index 0d05dc5..405b24f 100644
--- a/win8/delegate_execute/command_execute_impl.cc
+++ b/win8/delegate_execute/command_execute_impl.cc
@@ -116,7 +116,7 @@ bool CommandExecuteImpl::path_provider_initialized_ = false;
// If chrome is running then focus/activation is given to the existing one
// regarless of what launch point the user used.
//
-// The general flow when chrome is the default browser is as follows:
+// The general flow for activation is as follows:
//
// 1- User interacts with launch point (icon, tile, search, shellexec, etc)
// 2- Windows finds the appid for launch item and resolves it to chrome
@@ -133,11 +133,12 @@ bool CommandExecuteImpl::path_provider_initialized_ = false;
// the launch scheme (or url) and the activation verb.
// 5- Windows calls CommandExecuteImpl::Getvalue()
// Here we need to return AHE_IMMERSIVE or AHE_DESKTOP. That depends on:
-// a) if run in high-integrity return AHE_DESKTOP
+// a) if run in high-integrity return AHE_DESKTOP.
// b) else we return what GetLaunchMode() tells us, which is:
-// i) if the command line --force-xxx is present return that
-// ii) if the registry 'launch_mode' exists return that
-// iii) else return AHE_DESKTOP
+// i) if chrome is not the default browser, return AHE_DESKTOP
+// ii) if the command line --force-xxx is present return that
+// iii) if the registry 'launch_mode' exists return that
+// iv) else return AHE_DESKTOP
// 6- If we returned AHE_IMMERSIVE in step 5 windows might not call us back
// and simply activate chrome in metro by itself, however in some cases
// it might proceed at step 7.
@@ -150,7 +151,13 @@ bool CommandExecuteImpl::path_provider_initialized_ = false;
// b) else we call one of the IApplicationActivationManager activation
// functions depending on the parameters passed in step 4.
// c) If the activation returns E_APPLICATION_NOT_REGISTERED, then we fall
-// back to launching chrome on the desktop via LaunchDestopChrome().
+// back to launching chrome on the desktop via LaunchDestopChrome(). Note
+// that this case can lead to strange behavior, because at this point we
+// have pre-launched the browser with --silent-launch --viewer-connect.
+// E_APPLICATION_NOT_REGISTERED is always returned if Chrome is not the
+// default browser (this case will have already been checked for by
+// GetLaunchMode() and AHE_DESKTOP returned), but we don't know if it can
+// be returned for other reasons.
//
// Note that if a command line --force-xxx is present we write that launch mode
// in the registry so next time the logic reaches 5c-ii it will use the same
@@ -209,6 +216,12 @@ STDMETHODIMP CommandExecuteImpl::GetValue(enum AHE_TYPE* pahe) {
EC_HOST_UI_MODE mode = GetLaunchMode();
*pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE;
+ // If we're going to return AHE_IMMERSIVE, then both the browser process and
+ // the metro viewer need to launch and connect before the user can start
+ // browsing. However we must not launch the metro viewer until we get a
+ // call to CommandExecuteImpl::Execute(). If we wait until then to launch
+ // the browser process as well, it will appear laggy while they connect to
+ // each other, so we pre-launch the browser process now.
if (*pahe == AHE_IMMERSIVE && verb_ != win8::kMetroViewerConnectVerb)
LaunchChromeBrowserProcess();
return S_OK;
@@ -415,6 +428,17 @@ EC_HOST_UI_MODE CommandExecuteImpl::GetLaunchMode() {
launch_mode_determined = true;
return launch_mode;
}
+
+ base::FilePath chrome_exe;
+ if (!FindChromeExe(&chrome_exe) ||
+ ShellUtil::GetChromeDefaultStateFromPath(chrome_exe) !=
+ ShellUtil::DefaultState::IS_DEFAULT) {
+ AtlTrace("Chrome is not default: launching in desktop mode\n");
+ launch_mode = ECHUIM_DESKTOP;
+ launch_mode_determined = true;
+ return launch_mode;
+ }
+
if (GetAsyncKeyState(VK_SHIFT) && GetAsyncKeyState(VK_F11)) {
AtlTrace("Hotkey: launching in immersive mode\n");
launch_mode = ECHUIM_IMMERSIVE;