summaryrefslogtreecommitdiffstats
path: root/chrome/browser/google
diff options
context:
space:
mode:
authorpastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-11 16:19:39 +0000
committerpastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-11 16:19:39 +0000
commitbb1c7dac581b2a5d3ceae436b248064f3115591f (patch)
tree7754492fd71fc2411a24f38850ccc2c00e50ef09 /chrome/browser/google
parent402cf4ba9c7dc2a46e91ca4f49125bb13b04973c (diff)
downloadchromium_src-bb1c7dac581b2a5d3ceae436b248064f3115591f.zip
chromium_src-bb1c7dac581b2a5d3ceae436b248064f3115591f.tar.gz
chromium_src-bb1c7dac581b2a5d3ceae436b248064f3115591f.tar.bz2
Introduced better UI for the Omaha policy to disable updates for Chrome.
In case the policy is set the generic error message is replaced by a more concrete message stating that updates are disabled by the administrator. BUG=61056 TEST=Set the Omaha policy to disable updates, go the About Chrome box and check the message in the lower part of the window. Review URL: http://codereview.chromium.org/6482022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74606 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/google')
-rw-r--r--chrome/browser/google/google_update.cc50
-rw-r--r--chrome/browser/google/google_update.h2
2 files changed, 45 insertions, 7 deletions
diff --git a/chrome/browser/google/google_update.cc b/chrome/browser/google/google_update.cc
index f12192d..a218797 100644
--- a/chrome/browser/google/google_update.cc
+++ b/chrome/browser/google/google_update.cc
@@ -14,6 +14,7 @@
#include "base/string_util.h"
#include "base/task.h"
#include "base/threading/thread.h"
+#include "base/win/registry.h"
#include "base/win/windows_version.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -26,12 +27,40 @@
using views::Window;
namespace {
+
+// The registry location of the Google Update policies.
+const wchar_t kGUPolicyRegistrySubKey[] =
+ L"SOFTWARE\\Policies\\Google\\Update";
+const wchar_t kGUPolicyGlobalValue[] = L"UpdateDefault";
+const wchar_t kGUPolicyAppValuePrefix[] = L"Update";
+const DWORD kGUPolicyUpdatesDisabled = 0;
+
+// Checks if the updates have been disabled by policy.
+bool IsUpdateDisabledByPolicy(const std::wstring& guid) {
+#if !defined(GOOGLE_CHROME_BUILD)
+ return true;
+#else
+ std::wstring value_name(kGUPolicyAppValuePrefix);
+ value_name.append(guid);
+ DWORD value = 0;
+ base::win::RegKey policy(HKEY_LOCAL_MACHINE,
+ kGUPolicyRegistrySubKey, KEY_READ);
+ // Per application settings override global setting.
+ if ((policy.ReadValueDW(value_name.c_str(), &value) == ERROR_SUCCESS) ||
+ (policy.ReadValueDW(kGUPolicyGlobalValue, &value) == ERROR_SUCCESS)) {
+ return value == kGUPolicyUpdatesDisabled;
+ }
+ return false;
+#endif // defined(GOOGLE_CHROME_BUILD)
+}
+
// Check if the currently running instance can be updated by Google Update.
// Returns true only if the instance running is a Google Chrome
// distribution installed in a standard location.
-bool CanUpdateCurrentChrome(const std::wstring& chrome_exe_path) {
+GoogleUpdateErrorCode CanUpdateCurrentChrome(
+ const std::wstring& chrome_exe_path) {
#if !defined(GOOGLE_CHROME_BUILD)
- return false;
+ return CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY;
#else
// TODO(tommi): Check if using the default distribution is always the right
// thing to do.
@@ -50,10 +79,17 @@ bool CanUpdateCurrentChrome(const std::wstring& chrome_exe_path) {
<< L"non-standard location: " << chrome_exe_path.c_str()
<< L". The standard location is: " << user_exe_path.c_str()
<< L" or " << machine_exe_path.c_str() << L".";
- return false;
+ return CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY;
}
- return true;
+ std::wstring app_guid = installer::GetAppGuidForUpdates(
+ !InstallUtil::IsPerUserInstall(chrome_exe_path.c_str()));
+ DCHECK(!app_guid.empty());
+
+ if (IsUpdateDisabledByPolicy(app_guid))
+ return GOOGLE_UPDATE_DISABLED_BY_POLICY;
+
+ return GOOGLE_UPDATE_NO_ERROR;
#endif
}
@@ -241,10 +277,10 @@ bool GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer,
std::transform(chrome_exe.begin(), chrome_exe.end(),
chrome_exe.begin(), tolower);
- if (!CanUpdateCurrentChrome(chrome_exe)) {
+ GoogleUpdateErrorCode error_code = CanUpdateCurrentChrome(chrome_exe);
+ if (error_code != GOOGLE_UPDATE_NO_ERROR) {
main_loop->PostTask(FROM_HERE, NewRunnableMethod(this,
- &GoogleUpdate::ReportResults, UPGRADE_ERROR,
- CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY));
+ &GoogleUpdate::ReportResults, UPGRADE_ERROR, error_code));
return false;
}
diff --git a/chrome/browser/google/google_update.h b/chrome/browser/google/google_update.h
index 24ff093..bb810a1 100644
--- a/chrome/browser/google/google_update.h
+++ b/chrome/browser/google/google_update.h
@@ -57,6 +57,8 @@ enum GoogleUpdateErrorCode {
// An error occurred while upgrading (or while checking for update).
// Check the Google Update log in %TEMP% for more details.
GOOGLE_UPDATE_ERROR_UPDATING,
+ // Updates can not be downloaded because the administrator has disabled them.
+ GOOGLE_UPDATE_DISABLED_BY_POLICY,
};
// The GoogleUpdateStatusListener interface is used by components to receive