diff options
author | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-14 15:49:42 +0000 |
---|---|---|
committer | mad@chromium.org <mad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-14 15:49:42 +0000 |
commit | 3e0aa504dcf64ca13812b5537a78427bc608e511 (patch) | |
tree | a5e86d034f314fc0bc6127ebe1119e0b4666c234 | |
parent | eccf8031b30e3f8cf85b1e0dc82e69966afa30d5 (diff) | |
download | chromium_src-3e0aa504dcf64ca13812b5537a78427bc608e511.zip chromium_src-3e0aa504dcf64ca13812b5537a78427bc608e511.tar.gz chromium_src-3e0aa504dcf64ca13812b5537a78427bc608e511.tar.bz2 |
Switch about box to web ui on Windows.
This CLs adds proper support for update check on Windows so that we can turn on the WebUI support and eventually remove the code for about box in a modal dialog.
BUG=115123
TEST=Make sure about works and properly checks for updates.
Review URL: https://chromiumcodereview.appspot.com/10698106
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146738 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/google/google_update_win.cc (renamed from chrome/browser/google/google_update.cc) | 36 | ||||
-rw-r--r-- | chrome/browser/google/google_update_win.h (renamed from chrome/browser/google/google_update.h) | 24 | ||||
-rw-r--r-- | chrome/browser/ui/chrome_pages.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/views/about_chrome_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/about_chrome_view.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/help/help_handler.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/webui/help/version_updater_chromeos.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/webui/help/version_updater_win.cc | 289 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 14 |
9 files changed, 323 insertions, 59 deletions
diff --git a/chrome/browser/google/google_update.cc b/chrome/browser/google/google_update_win.cc index b502f6b..83fa005 100644 --- a/chrome/browser/google/google_update.cc +++ b/chrome/browser/google/google_update_win.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/google/google_update.h" +#include "chrome/browser/google/google_update_win.h" #include <atlbase.h> #include <atlcom.h> @@ -77,7 +77,7 @@ HRESULT CoCreateInstanceAsAdmin(REFCLSID class_id, REFIID interface_id, if (!interface_ptr) return E_POINTER; - // For Vista we need to instantiate the COM server via the elevation + // For Vista, need to instantiate the COM server via the elevation // moniker. This ensures that the UAC dialog shows up. if (base::win::GetVersion() >= base::win::VERSION_VISTA) { wchar_t class_id_as_string[MAX_PATH] = {0}; @@ -106,14 +106,10 @@ HRESULT CoCreateInstanceAsAdmin(REFCLSID class_id, REFIID interface_id, } // namespace -//////////////////////////////////////////////////////////////////////////////// -// // The GoogleUpdateJobObserver COM class is responsible for receiving status -// reports from google Update. It keeps track of the progress as Google Update -// notifies us and ends the message loop we are spinning in once Google Update -// reports that it is done. -// -//////////////////////////////////////////////////////////////////////////////// +// reports from google Update. It keeps track of the progress as GoogleUpdate +// notifies this observer and ends the message loop that is spinning in once +// GoogleUpdate reports that it is done. class GoogleUpdateJobObserver : public CComObjectRootEx<CComSingleThreadModel>, public IJobObserver { @@ -177,7 +173,7 @@ class GoogleUpdateJobObserver event_sink_ = NULL; - // We no longer need to spin the message loop that we started spinning in + // No longer need to spin the message loop that started spinning in // InitiateGoogleUpdateCheck. MessageLoop::current()->Quit(); return S_OK; @@ -235,9 +231,8 @@ GoogleUpdate::GoogleUpdate() GoogleUpdate::~GoogleUpdate() { } -void GoogleUpdate::CheckForUpdate(bool install_if_newer, - views::Widget* window) { - // We need to shunt this request over to InitiateGoogleUpdateCheck and have +void GoogleUpdate::CheckForUpdate(bool install_if_newer, HWND window) { + // Need to shunt this request over to InitiateGoogleUpdateCheck and have // it run in the file thread. BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, @@ -249,7 +244,7 @@ void GoogleUpdate::CheckForUpdate(bool install_if_newer, // GoogleUpdate, private: void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, - views::Widget* window, + HWND window, MessageLoop* main_loop) { FilePath chrome_exe; if (!PathService::Get(base::DIR_EXE, &chrome_exe)) @@ -290,18 +285,13 @@ void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, hr = on_demand.CreateInstance(CLSID_OnDemandUserAppsClass); } else { // The Update operation needs Admin privileges for writing - // to %ProgramFiles%. On Vista we need to elevate before instantiating + // to %ProgramFiles%. On Vista, need to elevate before instantiating // the updater instance. if (!install_if_newer) { hr = on_demand.CreateInstance(CLSID_OnDemandMachineAppsClass); } else { - HWND foreground_hwnd = NULL; - if (window != NULL) { - foreground_hwnd = window->GetNativeWindow(); - } - hr = CoCreateInstanceAsAdmin(CLSID_OnDemandMachineAppsClass, - IID_IGoogleUpdate, foreground_hwnd, + IID_IGoogleUpdate, window, reinterpret_cast<void**>(on_demand.Receive())); } system_level = true; @@ -339,7 +329,7 @@ void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, return; } - // We need to spin the message loop while Google Update is running so that it + // Need to spin the message loop while Google Update is running so that it // can report back to us through GoogleUpdateJobObserver. This message loop // will terminate once Google Update sends us the completion status // (success/error). See OnComplete(). @@ -389,7 +379,7 @@ void GoogleUpdate::InitiateGoogleUpdateCheck(bool install_if_newer, void GoogleUpdate::ReportResults(GoogleUpdateUpgradeResult results, GoogleUpdateErrorCode error_code, const string16& error_message) { - // If we get an error, then error code must not be blank, and vice versa. + // If there is an error, then error code must not be blank, and vice versa. DCHECK(results == UPGRADE_ERROR ? error_code != GOOGLE_UPDATE_NO_ERROR : error_code == GOOGLE_UPDATE_NO_ERROR); if (listener_) { diff --git a/chrome/browser/google/google_update.h b/chrome/browser/google/google_update_win.h index 36fe697..67105a1 100644 --- a/chrome/browser/google/google_update.h +++ b/chrome/browser/google/google_update_win.h @@ -2,15 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_ -#define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_ +#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ +#define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/string16.h" -#if defined(OS_WIN) #include "google_update/google_update_idl.h" -#endif class MessageLoop; namespace views { @@ -28,7 +26,7 @@ enum GoogleUpdateUpgradeResult { UPGRADE_IS_AVAILABLE, // The upgrade happened successfully. UPGRADE_SUCCESSFUL, - // No need to upgrade, we are up to date. + // No need to upgrade, Chrome is up to date. UPGRADE_ALREADY_UP_TO_DATE, // An error occurred. UPGRADE_ERROR, @@ -94,7 +92,7 @@ class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> { // |window| should point to a foreground window. This is needed to ensure // that Vista/Windows 7 UAC prompts show up in the foreground. It may also // be null. - void CheckForUpdate(bool install_if_newer, views::Widget* window); + void CheckForUpdate(bool install_if_newer, HWND window); // Pass NULL to clear the listener void set_status_listener(GoogleUpdateStatusListener* listener) { @@ -106,24 +104,18 @@ class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> { virtual ~GoogleUpdate(); -// The chromeos implementation is in browser/chromeos/google_update.cpp - -#if defined(OS_WIN) - // This function reports failure from the Google Update operation to the // listener. // Note, after this function completes, this object will have deleted itself. bool ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code, const string16& error_message, MessageLoop* main_loop); -#endif - - // We need to run the update check on another thread than the main thread, and + // The update check needs to run on another thread than the main thread, and // therefore CheckForUpdate will delegate to this function. |main_loop| points - // to the message loop that we want the response to come from. + // to the message loop that the response must come from. // |window| should point to a foreground window. This is needed to ensure that // Vista/Windows 7 UAC prompts show up in the foreground. It may also be null. - void InitiateGoogleUpdateCheck(bool install_if_newer, views::Widget* window, + void InitiateGoogleUpdateCheck(bool install_if_newer, HWND window, MessageLoop* main_loop); // This function reports the results of the GoogleUpdate operation to the @@ -144,4 +136,4 @@ class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> { DISALLOW_COPY_AND_ASSIGN(GoogleUpdate); }; -#endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_ +#endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ diff --git a/chrome/browser/ui/chrome_pages.cc b/chrome/browser/ui/chrome_pages.cc index 549d267..d1eab0e 100644 --- a/chrome/browser/ui/chrome_pages.cc +++ b/chrome/browser/ui/chrome_pages.cc @@ -158,15 +158,10 @@ void ShowInstantConfirmDialog(Browser* browser) { void ShowAboutChrome(Browser* browser) { content::RecordAction(UserMetricsAction("AboutChrome")); -#if !defined(OS_WIN) NavigateParams params( GetSingletonTabNavigateParams(browser, GURL(kChromeUIUberURL))); params.path_behavior = NavigateParams::IGNORE_AND_NAVIGATE; ShowSingletonTabOverwritingNTP(browser, params); -#else - // crbug.com/115123. - browser->window()->ShowAboutChromeDialog(); -#endif } void ShowSearchEngineSettings(Browser* browser) { diff --git a/chrome/browser/ui/views/about_chrome_view.cc b/chrome/browser/ui/views/about_chrome_view.cc index ab306e3..4bd8065 100644 --- a/chrome/browser/ui/views/about_chrome_view.cc +++ b/chrome/browser/ui/views/about_chrome_view.cc @@ -528,7 +528,7 @@ void AboutChromeView::ViewHierarchyChanged(bool is_add, !base::win::UserAccountControlIsEnabled())) { UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR, string16()); // CheckForUpdate(false, ...) means don't upgrade yet. - google_updater_->CheckForUpdate(false, GetWidget()); + google_updater_->CheckForUpdate(false, GetWidget()->GetNativeWindow()); } #endif } else { @@ -681,7 +681,7 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result, google_updater_->set_status_listener(this); UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, string16()); // CheckForUpdate(true,...) means perform upgrade if new version found. - google_updater_->CheckForUpdate(true, GetWidget()); + google_updater_->CheckForUpdate(true, GetWidget()->GetNativeWindow()); // TODO(seanparent): Need to see if this code needs to change to // force a machine restart. return; diff --git a/chrome/browser/ui/views/about_chrome_view.h b/chrome/browser/ui/views/about_chrome_view.h index b239883..bd3f20f 100644 --- a/chrome/browser/ui/views/about_chrome_view.h +++ b/chrome/browser/ui/views/about_chrome_view.h @@ -16,7 +16,7 @@ #include "ui/views/window/dialog_delegate.h" #if defined(OS_WIN) && !defined(USE_AURA) -#include "chrome/browser/google/google_update.h" +#include "chrome/browser/google/google_update_win.h" #endif namespace views { diff --git a/chrome/browser/ui/webui/help/help_handler.cc b/chrome/browser/ui/webui/help/help_handler.cc index 6ee5566..45c4407 100644 --- a/chrome/browser/ui/webui/help/help_handler.cc +++ b/chrome/browser/ui/webui/help/help_handler.cc @@ -143,8 +143,8 @@ void HelpHandler::GetLocalizedValues(DictionaryValue* localized_strings) { { "upToDate", IDS_UPGRADE_UP_TO_DATE }, { "updating", IDS_UPGRADE_UPDATING }, { "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH }, - { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME }, - { "reportAnIssue", IDS_REPORT_AN_ISSUE }, + { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME }, + { "reportAnIssue", IDS_REPORT_AN_ISSUE }, #if defined(OS_CHROMEOS) { "platform", IDS_PLATFORM_LABEL }, { "firmware", IDS_ABOUT_PAGE_FIRMWARE }, diff --git a/chrome/browser/ui/webui/help/version_updater_chromeos.cc b/chrome/browser/ui/webui/help/version_updater_chromeos.cc index 4adf8fa..502776f 100644 --- a/chrome/browser/ui/webui/help/version_updater_chromeos.cc +++ b/chrome/browser/ui/webui/help/version_updater_chromeos.cc @@ -12,7 +12,6 @@ #include "chrome/browser/chromeos/cros_settings_names.h" #include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/login/wizard_controller.h" -#include "chrome/browser/google/google_update.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power_manager_client.h" #include "grit/generated_resources.h" @@ -101,8 +100,7 @@ void VersionUpdaterCros::UpdateStatusChanged( case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: my_status = FAILED; // TODO(derat): More-detailed error info if UpdateEngineClient exposes it. - message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, - GOOGLE_UPDATE_ERROR_UPDATING); + message = l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, 0); break; case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: my_status = CHECKING; diff --git a/chrome/browser/ui/webui/help/version_updater_win.cc b/chrome/browser/ui/webui/help/version_updater_win.cc new file mode 100644 index 0000000..ecf6448 --- /dev/null +++ b/chrome/browser/ui/webui/help/version_updater_win.cc @@ -0,0 +1,289 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" +#include "base/memory/weak_ptr.h" +#include "base/string16.h" +#include "base/version.h" +#include "base/win/windows_version.h" +#include "base/win/win_util.h" +#include "chrome/browser/google/google_update_win.h" +#include "chrome/browser/lifetime/application_lifetime.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/webui/help/version_updater.h" +#include "chrome/common/chrome_version_info.h" +#include "chrome/installer/util/browser_distribution.h" +#include "chrome/installer/util/install_util.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/user_metrics.h" +#include "grit/chromium_strings.h" +#include "grit/generated_resources.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/views/widget/widget.h" + +using content::BrowserThread; +using content::UserMetricsAction; + +namespace { + +// Windows implementation of version update functionality, used by the WebUI +// About/Help page. +class VersionUpdaterWin : public VersionUpdater, + public GoogleUpdateStatusListener { + private: + friend class VersionReader; + friend class VersionUpdater; + + // Clients must use VersionUpdater::Create(). + VersionUpdaterWin(); + virtual ~VersionUpdaterWin(); + + // VersionUpdater implementation. + virtual void CheckForUpdate(const StatusCallback& callback) OVERRIDE; + virtual void RelaunchBrowser() const OVERRIDE; + + // GoogleUpdateStatusListener implementation. + virtual void OnReportResults(GoogleUpdateUpgradeResult result, + GoogleUpdateErrorCode error_code, + const string16& error_message, + const string16& version) OVERRIDE; + + // Update the UI to show the status of the upgrade. + void UpdateStatus(GoogleUpdateUpgradeResult result, + GoogleUpdateErrorCode error_code, + const string16& error_message); + + // Got the intalled version so the handling of the UPGRADE_ALREADY_UP_TO_DATE + // result case can now be completeb on the UI thread. + void GotInstalledVersion(const Version& version); + + // Little helper function to reset google_updater_. + void SetGoogleUpdater(); + + // Returns a window that can be used for elevation. + HWND GetElevationParent(); + + // The class that communicates with Google Update to find out if an update is + // available and asks it to start an upgrade. + scoped_refptr<GoogleUpdate> google_updater_; + + // Used for callbacks. + base::WeakPtrFactory<VersionUpdaterWin> weak_factory_; + + // Callback used to communicate update status to the client. + StatusCallback callback_; + + DISALLOW_COPY_AND_ASSIGN(VersionUpdaterWin); +}; + +// This class is used to read the version on the FILE thread and then call back +// the version updater in the UI thread. Using a class helps better control +// the lifespan of the Version independently of the lifespan of the version +// updater, which may die while asynchonicity is happening, thus the usage of +// the WeakPtr, which can only be used from the thread that created it. +class VersionReader + : public base::RefCountedThreadSafe<VersionReader> { + public: + explicit VersionReader( + const base::WeakPtr<VersionUpdaterWin>& version_updater) + : version_updater_(version_updater) { + } + + void GetVersionFromFileThread() { + BrowserDistribution* dist = BrowserDistribution::GetDistribution(); + InstallUtil::GetChromeVersion(dist, false, &installed_version_); + if (!installed_version_.IsValid()) { + // User-level Chrome is not installed, check system-level. + InstallUtil::GetChromeVersion(dist, true, &installed_version_); + } + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( + &VersionReader::SetVersionInUIThread, this)); + } + + void SetVersionInUIThread() { + if (version_updater_.get() != NULL) + version_updater_->GotInstalledVersion(installed_version_); + } + + private: + friend class base::RefCountedThreadSafe<VersionReader>; + + // The version updater that must be called back when we are done. + // We use a weak pointer in case the updater gets destroyed while waiting. + base::WeakPtr<VersionUpdaterWin> version_updater_; + + // This is the version that gets read in the FILE thread and set on the + // the updater in the UI thread. + Version installed_version_; +}; + +VersionUpdaterWin::VersionUpdaterWin() + : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { + SetGoogleUpdater(); +} + +VersionUpdaterWin::~VersionUpdaterWin() { + // The Google Updater will hold a pointer to the listener until it reports + // status, so that pointer must be cleared when the listener is destoyed. + if (google_updater_) + google_updater_->set_status_listener(NULL); +} + +void VersionUpdaterWin::CheckForUpdate(const StatusCallback& callback) { + callback_ = callback; + + // On-demand updates for Chrome don't work in Vista RTM when UAC is turned + // off. So, in this case, the version updater must not mention + // on-demand updates. Silent updates (in the background) should still + // work as before - enabling UAC or installing the latest service pack + // for Vista is another option. + if (!(base::win::GetVersion() == base::win::VERSION_VISTA && + (base::win::OSInfo::GetInstance()->service_pack().major == 0) && + !base::win::UserAccountControlIsEnabled())) { + // This could happen if the page got refreshed after results were returned. + if (!google_updater_) + SetGoogleUpdater(); + UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR, string16()); + // Specify false to not upgrade yet. + google_updater_->CheckForUpdate(false, GetElevationParent()); + } +} + +void VersionUpdaterWin::RelaunchBrowser() const { + browser::AttemptRestart(); +} + +void VersionUpdaterWin::OnReportResults( + GoogleUpdateUpgradeResult result, GoogleUpdateErrorCode error_code, + const string16& error_message, const string16& version) { + // Drop the last reference to the object so that it gets cleaned up here. + google_updater_ = NULL; + UpdateStatus(result, error_code, error_message); +} + +void VersionUpdaterWin::UpdateStatus(GoogleUpdateUpgradeResult result, + GoogleUpdateErrorCode error_code, + const string16& error_message) { + // For Chromium builds it would show an error message. + // But it looks weird because in fact there is no error, + // just the update server is not available for non-official builds. +#if defined(GOOGLE_CHROME_BUILD) + Status status = UPDATED; + string16 message; + + switch (result) { + case UPGRADE_CHECK_STARTED: { + content::RecordAction(UserMetricsAction("UpgradeCheck_Started")); + status = CHECKING; + break; + } + case UPGRADE_STARTED: { + content::RecordAction(UserMetricsAction("Upgrade_Started")); + status = UPDATING; + break; + } + case UPGRADE_IS_AVAILABLE: { + content::RecordAction( + UserMetricsAction("UpgradeCheck_UpgradeIsAvailable")); + DCHECK(!google_updater_); // Should have been nulled out already. + SetGoogleUpdater(); + UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, string16()); + // Specify true to upgrade now. + google_updater_->CheckForUpdate(true, GetElevationParent()); + return; + } + case UPGRADE_ALREADY_UP_TO_DATE: { + // Google Update reported that Chrome is up-to-date. + // To confirm the updated version is running, the reading + // must be done on the file thread. The rest of this case + // will be handled within GotInstalledVersion. + BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, base::Bind( + &VersionReader::GetVersionFromFileThread, + new VersionReader(weak_factory_.GetWeakPtr()))); + return; + } + case UPGRADE_SUCCESSFUL: { + content::RecordAction(UserMetricsAction("UpgradeCheck_Upgraded")); + status = NEARLY_UPDATED; + break; + } + case UPGRADE_ERROR: { + content::RecordAction(UserMetricsAction("UpgradeCheck_Error")); + status = FAILED; + if (error_code != GOOGLE_UPDATE_DISABLED_BY_POLICY) { + message = + l10n_util::GetStringFUTF16Int(IDS_UPGRADE_ERROR, error_code); + } else { + message = + l10n_util::GetStringUTF16(IDS_UPGRADE_DISABLED_BY_POLICY); + } + if (!error_message.empty()) { + message += + l10n_util::GetStringFUTF16(IDS_ABOUT_BOX_ERROR_DURING_UPDATE_CHECK, + error_message); + } + break; + } + } + + // TODO(mad): Get proper progress value instead of passing 0. + // http://crbug.com/136117 + callback_.Run(status, 0, message); +#endif // defined(GOOGLE_CHROME_BUILD) +} + +void VersionUpdaterWin::GotInstalledVersion(const Version& version) { + // This must be called on the UI thread so that callback_ can be called. + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + + // Make sure that the latest version is running and if not, + // notify the user by setting the status to NEARLY_UPDATED. + // + // The extra version check is necessary on Windows because the application + // may be already up to date on disk though the running app is still + // out of date. + chrome::VersionInfo version_info; + Version running_version(version_info.Version()); + if (!version.IsValid() || version.CompareTo(running_version) <= 0) { + content::RecordAction( + UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); + callback_.Run(UPDATED, 0, string16()); + } else { + content::RecordAction(UserMetricsAction("UpgradeCheck_AlreadyUpgraded")); + callback_.Run(NEARLY_UPDATED, 0, string16()); + } +} + +void VersionUpdaterWin::SetGoogleUpdater() { + google_updater_ = new GoogleUpdate(); + google_updater_->set_status_listener(this); +} + +BOOL CALLBACK WindowEnumeration(HWND window, LPARAM param) { + if (IsWindowVisible(window)) { + HWND* returned_window = reinterpret_cast<HWND*>(param); + *returned_window = window; + return FALSE; + } + return TRUE; +} + +HWND VersionUpdaterWin::GetElevationParent() { + // Look for a visible window belonging to the UI thread. + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + HWND window = NULL; + EnumThreadWindows(GetCurrentThreadId(), + WindowEnumeration, + reinterpret_cast<LPARAM>(&window)); + DCHECK(window != NULL) << "Failed to find a valid window handle on thread: " + << GetCurrentThreadId(); + return window; +} + +} // namespace + +VersionUpdater* VersionUpdater::Create() { + return new VersionUpdaterWin; +} diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index b001200..cd82fe6 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1096,9 +1096,9 @@ 'browser/google/google_search_counter.h', 'browser/google/google_search_metrics.cc', 'browser/google/google_search_metrics.h', - 'browser/google/google_update.cc', - 'browser/google/google_update.h', 'browser/google/google_update_settings_posix.cc', + 'browser/google/google_update_win.cc', + 'browser/google/google_update_win.h', 'browser/google/google_url_tracker.cc', 'browser/google/google_url_tracker.h', 'browser/google/google_url_tracker_factory.cc', @@ -3969,6 +3969,7 @@ 'browser/ui/webui/help/version_updater_chromeos.h', 'browser/ui/webui/help/version_updater_mac.mm', 'browser/ui/webui/help/version_updater_mac.h', + 'browser/ui/webui/help/version_updater_win.cc', 'browser/ui/webui/history_ui.cc', 'browser/ui/webui/history_ui.h', 'browser/ui/webui/inspect_ui.cc', @@ -4610,8 +4611,8 @@ ['exclude', '^browser/automation/testing_automation_provider_win.cc'], ['exclude', '^browser/first_run/try_chrome_dialog_view.cc'], ['exclude', '^browser/first_run/try_chrome_dialog_view.h'], - ['exclude', '^browser/google/google_update.cc'], - ['exclude', '^browser/google/google_update.h'], + ['exclude', '^browser/google/google_update_win.cc'], + ['exclude', '^browser/google/google_update_win.h'], ['exclude', '^browser/hang_monitor/hung_plugin_action.cc'], ['exclude', '^browser/hang_monitor/hung_plugin_action.h'], ['exclude', '^browser/hang_monitor/hung_window_detector.cc'], @@ -5128,6 +5129,8 @@ 'browser/ui/views/keyboard_overlay_delegate.cc', 'browser/ui/views/keyboard_overlay_dialog_view.cc', 'browser/ui/views/simple_message_box_views.cc', + 'browser/ui/webui/help/version_updater_basic.cc', + 'browser/ui/webui/help/version_updater_basic.h', 'browser/ui/webui/tab_modal_confirm_dialog_webui.cc', 'browser/ui/webui/tab_modal_confirm_dialog_webui.h', ], @@ -5143,7 +5146,6 @@ # Exclude files that should be excluded for all non-Windows platforms. ['exclude', '^browser/first_run/try_chrome_dialog_view.cc'], ['exclude', '^browser/first_run/try_chrome_dialog_view.h'], - ['exclude', '^browser/google/google_update.cc'], ['exclude', '^browser/importer/ie_importer.cc'], ['exclude', '^browser/ui/network_profile_bubble.cc'], ['exclude', '^browser/ui/network_profile_bubble.h'], @@ -5170,8 +5172,6 @@ '<(INTERMEDIATE_DIR)/chrome', ], 'sources/': [ - ['exclude', '^browser/google/google_update.cc'], - ['exclude', '^browser/google/google_update.h'], ['exclude', '^browser/platform_util_common_linux.cc'], ['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.cc'], ['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.h'], |