diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 00:44:35 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 00:44:35 +0000 |
commit | 74ecb5a48410545f8b52019e0466fa4ab4336740 (patch) | |
tree | 30c2965f1b3b03e54ae254ed396cf6e085b69839 /chrome_frame | |
parent | 236c3feac542f868d7f2ddc7f62e98f9bc3196c3 (diff) | |
download | chromium_src-74ecb5a48410545f8b52019e0466fa4ab4336740.zip chromium_src-74ecb5a48410545f8b52019e0466fa4ab4336740.tar.gz chromium_src-74ecb5a48410545f8b52019e0466fa4ab4336740.tar.bz2 |
Correct a problem whereby the prefetching experiment would never be scheduled for updates.
Review URL: http://codereview.chromium.org/3362001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58440 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/chrome_tab.cc | 9 | ||||
-rw-r--r-- | chrome_frame/utils.cc | 15 | ||||
-rw-r--r-- | chrome_frame/utils.h | 3 |
3 files changed, 26 insertions, 1 deletions
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index 8036536..5e712a22 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -298,8 +298,15 @@ HRESULT SetupRunOnce() { return S_OK; } + HKEY hive = HKEY_CURRENT_USER; + if (IsSystemProcess()) { + // For system installs, our updates will be running as SYSTEM which + // makes writing to a RunOnce key under HKCU not so terribly useful. + hive = HKEY_LOCAL_MACHINE; + } + RegKey run_once; - if (run_once.Create(HKEY_CURRENT_USER, kRunOnce, KEY_READ | KEY_WRITE)) { + if (run_once.Create(hive, kRunOnce, KEY_READ | KEY_WRITE)) { CommandLine run_once_command(chrome_launcher::GetChromeExecutablePath()); run_once_command.AppendSwitchASCII(switches::kAutomationClientChannelID, "0"); diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index e8dfb4b..31cf389 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -7,6 +7,8 @@ #include <shlobj.h> #include <wininet.h> +#include <atlsecurity.h> + #include "base/file_util.h" #include "base/file_version_info.h" #include "base/lazy_instance.h" @@ -1127,6 +1129,19 @@ bool IsIBrowserServicePatchEnabled() { return patch_method == PATCH_METHOD_IBROWSER; } +bool IsSystemProcess() { + bool is_system = false; + CAccessToken process_token; + if (process_token.GetProcessToken(TOKEN_QUERY, GetCurrentProcess())) { + CSid logon_sid; + if (process_token.GetUser(&logon_sid)) { + is_system = logon_sid == Sids::System(); + } + } + return is_system; +} + + std::string BindStatus2Str(ULONG bind_status) { std::string s; static const char* const bindstatus_txt[] = { diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h index 477084d..0587fdd 100644 --- a/chrome_frame/utils.h +++ b/chrome_frame/utils.h @@ -460,6 +460,9 @@ ProtocolPatchMethod GetPatchMethod(); // Returns true if the IMoniker patch is enabled. bool IsIBrowserServicePatchEnabled(); +// Returns true if we can detect that we are running as SYSTEM, false otherwise. +bool IsSystemProcess(); + // STL helper class that implements a functor to delete objects. // E.g: std::for_each(v.begin(), v.end(), utils::DeleteObject()); namespace utils { |