Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: win8/delegate_execute/command_execute_impl.cc

Issue 10928172: Implement the persistent metro mode setting (win8) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/common/chrome_constants.cc ('K') | « win8/delegate_execute/chrome_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: win8/delegate_execute/command_execute_impl.cc
===================================================================
--- win8/delegate_execute/command_execute_impl.cc (revision 156164)
+++ win8/delegate_execute/command_execute_impl.cc (working copy)
@@ -10,6 +10,7 @@
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/utf_string_conversions.h"
+#include "base/win/registry.h"
#include "base/win/scoped_co_mem.h"
#include "base/win/scoped_handle.h"
#include "chrome/common/chrome_constants.h"
@@ -45,37 +46,23 @@
// Here we need to return AHE_IMMERSIVE or AHE_DESKTOP. That depends on:
// a) if run in high-integrity return AHE_DESKTOP
// b) if chrome is running return the AHE_ mode of chrome
-// c) if the current process is inmmersive return AHE_IMMERSIVE
-// d) if the protocol is file and IExecuteCommandHost::GetUIMode() is not
-// ECHUIM_DESKTOP then return AHE_IMMERSIVE
-// e) if none of the above return AHE_DESKTOP
+// c) 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) if IsMachineATablet() is true return AHE_IMMERSIVE
+// iv) else return AHE_DESKTOP
// 6- If we returned AHE_DESKTOP in step 5 then CommandExecuteImpl::Execute()
-// is called, here we call GetLaunchMode() which:
-// a) if chrome is running return the mode of chrome or
-// b) return IExecuteCommandHost::GetUIMode()
+// is called, here we call GetLaunchMode() which returns the cached answer
+// computed at step 5c.
// 7- If GetLaunchMode() returns
// a) ECHUIM_DESKTOP we call LaunchDestopChrome() that calls ::CreateProcess
// b) else we call one of the IApplicationActivationManager activation
// functions depending on the parameters passed in step 4.
//
-// Some examples will help clarify the common cases.
+// 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
+// mode again.
//
-// I - No chrome running, taskbar icon launch:
-// a) Scheme is 'file', Verb is 'open'
-// b) GetValue() returns at e) step : AHE_DESKTOP
-// c) Execute() calls LaunchDestopChrome()
-// --> desktop chrome runs
-// II- No chrome running, tile activation launch:
-// a) Scheme is 'file', Verb is 'open'
-// b) GetValue() returns at d) step : AHE_IMMERSIVE
-// c) Windows does not call us back and just activates chrome
-// --> metro chrome runs
-// III- No chrome running, url link click on metro app:
-// a) Scheme is 'http', Verb is 'open'
-// b) Getvalue() returns at e) step : AHE_DESKTOP
-// c) Execute() calls IApplicationActivationManager::ActivateForProtocol
-// --> metro chrome runs
-//
CommandExecuteImpl::CommandExecuteImpl()
: integrity_level_(base::INTEGRITY_UNKNOWN),
launch_scheme_(INTERNET_SCHEME_DEFAULT),
@@ -177,21 +164,8 @@
return S_OK;
}
- if (IsImmersiveProcess(GetCurrentProcess())) {
- AtlTrace("Current process is inmmersive, AHE_IMMERSIVE\n");
- *pahe = AHE_IMMERSIVE;
- return S_OK;
- }
-
- if ((launch_scheme_ == INTERNET_SCHEME_FILE) &&
- (GetLaunchMode() != ECHUIM_DESKTOP)) {
- AtlTrace("INTERNET_SCHEME_FILE, mode != ECHUIM_DESKTOP, AHE_IMMERSIVE\n");
- *pahe = AHE_IMMERSIVE;
- return S_OK;
- }
-
- AtlTrace("Fallback is AHE_DESKTOP\n");
- *pahe = AHE_DESKTOP;
+ EC_HOST_UI_MODE mode = GetLaunchMode();
+ *pahe = (mode == ECHUIM_DESKTOP) ? AHE_DESKTOP : AHE_IMMERSIVE;
return S_OK;
}
@@ -399,8 +373,7 @@
}
EC_HOST_UI_MODE CommandExecuteImpl::GetLaunchMode() {
- // We are to return chrome's mode if chrome exists else we query our embedder
- // IServiceProvider and learn the mode from them.
+ // See the header file for an explanation of the mode selection logic.
static bool launch_mode_determined = false;
static EC_HOST_UI_MODE launch_mode = ECHUIM_DESKTOP;
@@ -419,30 +392,45 @@
if (parameters_ == ASCIIToWide(switches::kForceImmersive)) {
launch_mode = ECHUIM_IMMERSIVE;
launch_mode_determined = true;
+ parameters_.clear();
} else if (parameters_ == ASCIIToWide(switches::kForceDesktop)) {
launch_mode = ECHUIM_DESKTOP;
launch_mode_determined = true;
+ parameters_.clear();
}
+ base::win::RegKey reg_key;
+ if (reg_key.Create(HKEY_CURRENT_USER,
+ chrome::kMetroRegistryPath,
+ KEY_ALL_ACCESS) != 0) {
grt (UTC plus 2) 2012/09/13 04:33:16 please use ERROR_SUCCESS rather than 0 for consist
cpu_(ooo_6.6-7.5) 2012/09/13 20:56:56 Done.
+ AtlTrace("Failed to open HKCU %ls key\n", chrome::kMetroRegistryPath);
grt (UTC plus 2) 2012/09/13 04:33:16 might be helpful to log the result of reg_key.Crea
cpu_(ooo_6.6-7.5) 2012/09/13 20:56:56 Done.
+ if (!launch_mode_determined) {
+ launch_mode = ECHUIM_DESKTOP;
+ launch_mode_determined = true;
+ }
+ return launch_mode;
+ }
+
if (launch_mode_determined) {
- parameters_.clear();
- AtlTrace("Launch mode forced to %s\n", modes[launch_mode]);
+ AtlTrace("Launch mode forced by cmdline to %s\n", modes[launch_mode]);
+ reg_key.WriteValue(chrome::kLaunchModeValue,
grt (UTC plus 2) 2012/09/13 04:33:16 please add code to chrome/installer/setup/uninstal
+ static_cast<DWORD>(launch_mode));
return launch_mode;
}
- CComPtr<IExecuteCommandHost> host;
- CComQIPtr<IServiceProvider> service_provider = m_spUnkSite;
- if (service_provider) {
- service_provider->QueryService(IID_IExecuteCommandHost, &host);
- if (host) {
- host->GetUIMode(&launch_mode);
- } else {
- AtlTrace("Failed to get IID_IExecuteCommandHost. Assuming desktop\n");
- }
+ DWORD reg_value;
+ if (reg_key.ReadValueDW(chrome::kLaunchModeValue, &reg_value) != 0) {
grt (UTC plus 2) 2012/09/13 04:33:16 please use ERROR_SUCCESS rather than 0
cpu_(ooo_6.6-7.5) 2012/09/13 20:56:56 Done.
+ launch_mode = delegate_execute::IsMachineATablet() ?
grt (UTC plus 2) 2012/09/13 04:33:16 i'm curious: is this ever called when chrome isn't
cpu_(ooo_6.6-7.5) 2012/09/13 20:56:56 I'' see if it does.
+ ECHUIM_IMMERSIVE : ECHUIM_DESKTOP;
+ AtlTrace("Launch mode forced by heuristics to %s\n", modes[launch_mode]);
+ } else if (reg_value > ECHUIM_SYSTEM_LAUNCHER) {
grt (UTC plus 2) 2012/09/13 04:33:16 should this be >=? is it valid for the launch mod
cpu_(ooo_6.6-7.5) 2012/09/13 20:56:56 I was thinking on using it experimentally but I'll
+ AtlTrace("Invalid registry launch mode value %u\n", reg_value);
+ launch_mode = ECHUIM_DESKTOP;
} else {
- AtlTrace("Failed to get IServiceProvider. Assuming desktop mode\n");
+ AtlTrace("Launch mode forced by registry to %s\n", modes[launch_mode]);
+ launch_mode = static_cast<EC_HOST_UI_MODE>(reg_value);
}
- AtlTrace("Launch mode is %s\n", modes[launch_mode]);
+
launch_mode_determined = true;
return launch_mode;
}
« chrome/common/chrome_constants.cc ('K') | « win8/delegate_execute/chrome_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698