Chromium Code Reviews| Index: chrome/browser/google/google_update_win.h |
| diff --git a/chrome/browser/google/google_update_win.h b/chrome/browser/google/google_update_win.h |
| index 659f3932caebfb087cb169da136583d94f10a1d6..02657e880373fd1b541410526ab4ea77dff975b0 100644 |
| --- a/chrome/browser/google/google_update_win.h |
| +++ b/chrome/browser/google/google_update_win.h |
| @@ -5,18 +5,18 @@ |
| #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |
| #define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |
| +#include <windows.h> |
| + |
| #include "base/basictypes.h" |
| +#include "base/callback_forward.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/strings/string16.h" |
| +#include "base/win/scoped_comptr.h" |
| #include "google_update/google_update_idl.h" |
| namespace base { |
| -class MessageLoop; |
| -} |
| - |
| -namespace views { |
| -class Widget; |
| -} |
| +class TaskRunner; |
| +} // namespace base |
| // The status of the upgrade. UPGRADE_STARTED and UPGRADE_CHECK_STARTED are |
| // internal states and will not be reported as results to the listener. |
| @@ -52,10 +52,10 @@ enum GoogleUpdateErrorCode { |
| // Google Update OnDemand COM class reported an error during a check for |
| // update (or while upgrading). |
| GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR = 4, |
| - // A call to GetResults failed. |
| - GOOGLE_UPDATE_GET_RESULT_CALL_FAILED = 5, |
| - // A call to GetVersionInfo failed. |
| - GOOGLE_UPDATE_GET_VERSION_INFO_FAILED = 6, |
| + // A call to GetResults failed. DEPRECATED. |
| + // GOOGLE_UPDATE_GET_RESULT_CALL_FAILED = 5, |
| + // A call to GetVersionInfo failed. DEPRECATED |
| + // GOOGLE_UPDATE_GET_VERSION_INFO_FAILED = 6, |
| // An error occurred while upgrading (or while checking for update). |
| // Check the Google Update log in %TEMP% for more details. |
| GOOGLE_UPDATE_ERROR_UPDATING = 7, |
| @@ -68,84 +68,43 @@ enum GoogleUpdateErrorCode { |
| NUM_ERROR_CODES |
| }; |
| -// The GoogleUpdateStatusListener interface is used by components to receive |
| -// notifications about the results of an Google Update operation. |
| -class GoogleUpdateStatusListener { |
| - public: |
| - // This function is called when Google Update has finished its operation and |
| - // wants to notify us about the results. |results| represents what the end |
| - // state is, |error_code| represents what error occurred, |error_message| is a |
| - // string version of the same (might be blank) and |version| specifies what |
| - // new version Google Update detected (or installed). This value can be a |
| - // blank string, if the version tag in the Update{} block (in Google Update's |
| - // server config for Chrome) is blank. |
| - virtual void OnReportResults(GoogleUpdateUpgradeResult results, |
| - GoogleUpdateErrorCode error_code, |
| - const base::string16& error_message, |
| - const base::string16& version) = 0; |
| -}; |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// |
| -// The Google Update class is responsible for communicating with Google Update |
| -// and get it to perform operations on our behalf (for example, CheckForUpdate). |
| -// This class will report back to its parent via the GoogleUpdateStatusListener |
| -// interface and will delete itself after reporting back. |
| -// |
| -//////////////////////////////////////////////////////////////////////////////// |
| -class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> { |
| - public: |
| - GoogleUpdate(); |
| - |
| - // Ask Google Update to see if a new version is available. If the parameter |
| - // |install_if_newer| is true then Google Update will also install that new |
| - // version. |
| - // |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, HWND window); |
| - |
| - // Pass NULL to clear the listener |
| - void set_status_listener(GoogleUpdateStatusListener* listener) { |
| - listener_ = listener; |
| - } |
| - |
| - private: |
| - friend class base::RefCountedThreadSafe<GoogleUpdate>; |
| - |
| - virtual ~GoogleUpdate(); |
| - |
| - // 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 base::string16& error_message, |
| - base::MessageLoop* main_loop); |
| - |
| - // 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 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, HWND window, |
| - base::MessageLoop* main_loop); |
| - |
| - // This function reports the results of the GoogleUpdate operation to the |
| - // listener. If results indicates an error, the |error_code| and |
| - // |error_message| will indicate which error occurred. |
| - // Note, after this function completes, this object will have deleted itself. |
| - void ReportResults(GoogleUpdateUpgradeResult results, |
| - GoogleUpdateErrorCode error_code, |
| - const base::string16& error_message); |
| - |
| - // Which version string Google Update found (if a new one was available). |
| - // Otherwise, this will be blank. |
| - base::string16 version_available_; |
| - |
| - // The listener who is interested in finding out the result of the operation. |
| - GoogleUpdateStatusListener* listener_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(GoogleUpdate); |
| -}; |
| +// A callback run when a check for updates has completed. |result| indicates the |
| +// end state of the operation. When |result| is UPGRADE_ERROR, |error_code| and |
| +// |error_message| indicate the the nature of the error. When |result| is |
| +// UPGRADE_IS_AVAILABLE or UPGRADE_SUCCESSFUL, |version| may indicate the new |
| +// version Google Update detected (it may, however, be empty). |
| +typedef base::Callback<void(GoogleUpdateUpgradeResult result, |
| + GoogleUpdateErrorCode error_code, |
| + const base::string16& error_message, |
| + const base::string16& version)> UpdateCheckCallback; |
| + |
| +// Initiates an update check on the FILE thread. If |install_if_newer| is true, |
| +// an update will be applied. |elevation_window| is the window which should own |
| +// any necessary elevation UI. |callback| will be run on the caller's thread |
| +// when the check completes. |
| +void CheckForUpdate(bool install_if_newer, |
| + HWND elevation_window, |
| + const UpdateCheckCallback& callback); |
| + |
| +namespace internal { |
|
Peter Kasting
2014/11/26 22:13:05
We also shouldn't be using an ad-hoc "internal" na
grt (UTC plus 2)
2014/11/27 04:44:57
I don't understand this suggestion, nor why it see
Peter Kasting
2014/11/27 08:07:34
Namespace usage in Chrome has been discussed on th
|
| + |
| +// A type of callback supplied by tests to provide a custom IGoogleUpdate |
| +// implementation. |
| +typedef base::Callback<HRESULT(base::win::ScopedComPtr<IGoogleUpdate>*)> |
| + OnDemandAppsClassFactory; |
| + |
| +// For use by tests that wish to provide a custom IGoogleUpdate implementation |
| +// independent of Google Update's. |
| +void SetGoogleUpdateFactory( |
| + const OnDemandAppsClassFactory& google_update_factory); |
| + |
| +// Runs the update check described in CheckForUpdate above on |task_runner|. |
| +// Exposed for unit testing. |
| +void CheckForUpdate(const scoped_refptr<base::TaskRunner>& task_runner, |
| + bool install_if_newer, |
| + HWND elevation_window, |
| + const UpdateCheckCallback& callback); |
| + |
| +} // namespace internal |
| #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |