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

Side by Side Diff: ceee/ie/common/ceee_module_util.cc

Issue 5720004: Added refreshing of elevation policy on first run of new version for all user... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // CEEE module-wide utilities. 5 // CEEE module-wide utilities.
6 6
7 #include "ceee/ie/common/ceee_module_util.h" 7 #include "ceee/ie/common/ceee_module_util.h"
8 8
9 #include <iepmapi.h>
10
9 #include "base/file_path.h" 11 #include "base/file_path.h"
10 #include "base/file_util.h" 12 #include "base/file_util.h"
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/path_service.h" 14 #include "base/path_service.h"
13 #include "base/stringize_macros.h" 15 #include "base/stringize_macros.h"
14 #include "base/win/registry.h" 16 #include "base/win/registry.h"
17 #include "ceee/common/com_utils.h"
15 #include "ceee/common/process_utils_win.h" 18 #include "ceee/common/process_utils_win.h"
19 #include "ceee/ie/common/ie_util.h"
16 #include "chrome/installer/util/google_update_constants.h" 20 #include "chrome/installer/util/google_update_constants.h"
17 21
18 #include "version.h" // NOLINT 22 #include "version.h" // NOLINT
19 23
20 namespace { 24 namespace {
21 25
22 const wchar_t* kRegistryPath = L"SOFTWARE\\Google\\CEEE"; 26 const wchar_t* kRegistryPath = L"SOFTWARE\\Google\\CEEE";
23 const wchar_t* kRegistryValueToolbandIsHidden = L"toolband_is_hidden"; 27 const wchar_t* kRegistryValueToolbandIsHidden = L"toolband_is_hidden";
24 const wchar_t* kRegistryValueToolbandPlaced = L"toolband_placed"; 28 const wchar_t* kRegistryValueToolbandPlaced = L"toolband_placed";
25 const wchar_t* kRegistryValueCrxInstalledPath = L"crx_installed_path"; 29 const wchar_t* kRegistryValueCrxInstalledPath = L"crx_installed_path";
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 base::win::RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ); 303 base::win::RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ);
300 DWORD value; 304 DWORD value;
301 if (!key.ReadValueDW(google_update::kRegUsageStatsField, &value)) { 305 if (!key.ReadValueDW(google_update::kRegUsageStatsField, &value)) {
302 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ); 306 base::win::RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ);
303 if (!hklm_key.ReadValueDW(google_update::kRegUsageStatsField, &value)) 307 if (!hklm_key.ReadValueDW(google_update::kRegUsageStatsField, &value))
304 return false; 308 return false;
305 } 309 }
306 return (1 == value); 310 return (1 == value);
307 } 311 }
308 312
313 bool RefreshElevationPolicyIfNeeded() {
314 if (ie_util::GetIeVersion() < ie_util::IEVERSION_IE7)
315 return false;
316
317 // This may access to InternetRegistry instead of real one. However this is
Sigurður Ásgeirsson 2010/12/11 01:03:58 access to -> access
Vitaly Buka (NO REVIEWS) 2010/12/11 01:17:44 Done.
318 // acceptable, we just refresh policy twice.
319 base::win::RegKey hkcu(HKEY_CURRENT_USER, kRegistryPath, KEY_ALL_ACCESS);
Sigurður Ásgeirsson 2010/12/11 01:03:58 is KEY_WRITE sufficient here?
Vitaly Buka (NO REVIEWS) 2010/12/11 01:17:44 KEY_WRITE does not allow read value.
Jói 2010/12/11 02:23:14 How about KEY_WRITE | KEY_QUERY_VALUE ?
Vitaly Buka (NO REVIEWS) 2010/12/11 08:26:24 Than may be KEY_READ | KEY_WRITE? KEY_READ | KEY_
Jói 2010/12/11 21:30:45 I agree it's unlikely, but as a general principle
Vitaly Buka (NO REVIEWS) 2010/12/11 23:58:14 Done.
320 LOG_IF(ERROR, !hkcu.Valid()) << "Failed to open reg key: " << kRegistryPath;
321 if (!hkcu.Valid())
322 return false;
323
324 std::wstring expected_version = TO_L_STRING(CHROME_VERSION_STRING);
325
326 static const wchar_t kValueName[] = L"last_elevation_refresh";
327 std::wstring last_elevation_refresh_version;
328 bool result = hkcu.ReadValue(kValueName, &last_elevation_refresh_version);
329 if (last_elevation_refresh_version == expected_version)
330 return false;
331
332 HRESULT hr = ::IERefreshElevationPolicy();
333 VLOG(1) << "Elevation policy refresh result: " << com::LogHr(hr);
334
335 // Write after refreshing because if two thread get here simultaneously
Sigurður Ásgeirsson 2010/12/11 01:03:58 two thread -> two threads
Vitaly Buka (NO REVIEWS) 2010/12/11 01:17:44 Done.
336 // better to refresh twice than pass one thread without refreshing.
Sigurður Ásgeirsson 2010/12/11 01:03:58 maybe rephrase to it's better to refresh twice, t
Vitaly Buka (NO REVIEWS) 2010/12/11 01:17:44 Done.
337 result = hkcu.WriteValue(kValueName, expected_version.c_str());
338 LOG_IF(ERROR, !result) << "Failed to write a registry value: " << kValueName;
339
340 return true;
341 }
342
309 } // namespace ceee_module_util 343 } // namespace ceee_module_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698