[email protected] | cec9984 | 2012-02-10 03:24:23 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 3e0aa504 | 2012-07-14 15:49:42 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |
| 6 | #define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 7 | |
Robert Liao | b2bc703d | 2017-10-17 20:52:35 | [diff] [blame] | 8 | #include <wrl/client.h> |
| 9 | |
grt | 5a83109 | 2014-12-02 18:40:44 | [diff] [blame] | 10 | #include "base/callback_forward.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 11 | #include "base/memory/ref_counted.h" |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 12 | #include "base/memory/weak_ptr.h" |
[email protected] | d883056 | 2013-06-10 22:01:54 | [diff] [blame] | 13 | #include "base/strings/string16.h" |
[email protected] | cec9984 | 2012-02-10 03:24:23 | [diff] [blame] | 14 | #include "google_update/google_update_idl.h" |
grt | 5a83109 | 2014-12-02 18:40:44 | [diff] [blame] | 15 | #include "ui/gfx/native_widget_types.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | |
[email protected] | 5e9e96a | 2013-03-31 02:29:20 | [diff] [blame] | 17 | namespace base { |
Greg Thompson | c9c18a6d6 | 2017-07-28 09:14:30 | [diff] [blame] | 18 | class SingleThreadTaskRunner; |
grt | 5a83109 | 2014-12-02 18:40:44 | [diff] [blame] | 19 | } // namespace base |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 20 | |
grt | 0fed985 | 2014-10-18 16:16:49 | [diff] [blame] | 21 | // These values are used for a histogram. Do not reorder. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 22 | enum GoogleUpdateErrorCode { |
| 23 | // The upgrade completed successfully (or hasn't been started yet). |
| 24 | GOOGLE_UPDATE_NO_ERROR = 0, |
| 25 | // Google Update only supports upgrading if Chrome is installed in the default |
| 26 | // location. This error will appear for developer builds and with |
| 27 | // installations unzipped to random locations. |
grt | 0fed985 | 2014-10-18 16:16:49 | [diff] [blame] | 28 | CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY = 1, |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 29 | // Failed to create Google Update JobServer COM class. DEPRECATED. |
| 30 | // GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED = 2, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 31 | // Failed to create Google Update OnDemand COM class. |
grt | 0fed985 | 2014-10-18 16:16:49 | [diff] [blame] | 32 | GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND = 3, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 33 | // Google Update OnDemand COM class reported an error during a check for |
| 34 | // update (or while upgrading). |
grt | 0fed985 | 2014-10-18 16:16:49 | [diff] [blame] | 35 | GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR = 4, |
grt | 5a83109 | 2014-12-02 18:40:44 | [diff] [blame] | 36 | // A call to GetResults failed. DEPRECATED. |
| 37 | // GOOGLE_UPDATE_GET_RESULT_CALL_FAILED = 5, |
| 38 | // A call to GetVersionInfo failed. DEPRECATED |
| 39 | // GOOGLE_UPDATE_GET_VERSION_INFO_FAILED = 6, |
[email protected] | 287a019 | 2008-07-31 18:49:32 | [diff] [blame] | 40 | // An error occurred while upgrading (or while checking for update). |
| 41 | // Check the Google Update log in %TEMP% for more details. |
grt | 0fed985 | 2014-10-18 16:16:49 | [diff] [blame] | 42 | GOOGLE_UPDATE_ERROR_UPDATING = 7, |
[email protected] | 970749f | 2013-06-21 09:41:12 | [diff] [blame] | 43 | // Updates can not be downloaded because the administrator has disabled all |
| 44 | // types of updating. |
grt | 0fed985 | 2014-10-18 16:16:49 | [diff] [blame] | 45 | GOOGLE_UPDATE_DISABLED_BY_POLICY = 8, |
[email protected] | 970749f | 2013-06-21 09:41:12 | [diff] [blame] | 46 | // Updates can not be downloaded because the administrator has disabled |
| 47 | // manual (on-demand) updates. Automatic background updates are allowed. |
grt | 9196d6c9 | 2015-08-22 02:15:01 | [diff] [blame] | 48 | GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY = 9, |
grt | 0fed985 | 2014-10-18 16:16:49 | [diff] [blame] | 49 | NUM_ERROR_CODES |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 50 | }; |
| 51 | |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 52 | // A delegate by which a caller of BeginUpdateCheck is notified of the status |
| 53 | // and results of an update check. |
| 54 | class UpdateCheckDelegate { |
| 55 | public: |
| 56 | virtual ~UpdateCheckDelegate() {} |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 57 | |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 58 | // Invoked following a successful update check. |new_version|, if not empty, |
| 59 | // indicates the new version that is available. Otherwise (if |new_version| is |
| 60 | // empty), Chrome is up to date. This method will only be invoked when |
| 61 | // BeginUpdateCheck is called with |install_update_if_possible| == false. |
| 62 | virtual void OnUpdateCheckComplete(const base::string16& new_version) = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 63 | |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 64 | // Invoked zero or more times during an upgrade. |progress|, a number between |
| 65 | // 0 and 100 (inclusive), is an estimation as to what percentage of the |
| 66 | // upgrade has completed. |new_version| indicates the version that is being |
| 67 | // download and installed. This method will only be invoked when |
| 68 | // BeginUpdateCheck is called with |install_update_if_possible| == true. |
| 69 | virtual void OnUpgradeProgress(int progress, |
| 70 | const base::string16& new_version) = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 71 | |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 72 | // Invoked following a successful upgrade. |new_version| indicates the version |
| 73 | // to which Chrome was updated. This method will only be invoked when |
| 74 | // BeginUpdateCheck is called with |install_update_if_possible| == true. |
| 75 | virtual void OnUpgradeComplete(const base::string16& new_version) = 0; |
| 76 | |
| 77 | // Invoked following an unrecoverable error, indicated by |error_code|. |
bcwhite | 5895b19 | 2015-07-10 12:43:27 | [diff] [blame] | 78 | // |html_error_message|, if not empty, must be a localized string containing |
| 79 | // all information required by users to act on the error as well as for |
| 80 | // support staff to diagnose it (i.e. |error_code| and any other related |
| 81 | // state information). |new_version|, if not empty, indicates the version |
| 82 | // to which an upgrade attempt was made. |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 83 | virtual void OnError(GoogleUpdateErrorCode error_code, |
bcwhite | 5895b19 | 2015-07-10 12:43:27 | [diff] [blame] | 84 | const base::string16& html_error_message, |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 85 | const base::string16& new_version) = 0; |
| 86 | |
| 87 | protected: |
| 88 | UpdateCheckDelegate() {} |
| 89 | }; |
| 90 | |
calamity | c59edd8 | 2017-07-20 07:20:42 | [diff] [blame] | 91 | // Begins an asynchronous update check. If a new version is |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 92 | // available and |install_update_if_possible| is true, the new version will be |
| 93 | // automatically downloaded and installed. |elevation_window| is the window |
| 94 | // which should own any necessary elevation UI. Methods on |delegate| will be |
grt | 9f391dd8 | 2016-09-07 12:49:32 | [diff] [blame] | 95 | // invoked on the caller's thread to provide feedback on the operation, with |
| 96 | // messages localized to |locale| if possible. |
| 97 | void BeginUpdateCheck( |
grt | 9f391dd8 | 2016-09-07 12:49:32 | [diff] [blame] | 98 | const std::string& locale, |
| 99 | bool install_update_if_possible, |
| 100 | gfx::AcceleratedWidget elevation_window, |
| 101 | const base::WeakPtr<UpdateCheckDelegate>& delegate); |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 102 | |
| 103 | // A type of callback supplied by tests to provide a custom IGoogleUpdate3Web |
| 104 | // implementation (see src/google_update/google_update_idl.idl). |
Robert Liao | b2bc703d | 2017-10-17 20:52:35 | [diff] [blame] | 105 | typedef base::Callback<HRESULT(Microsoft::WRL::ComPtr<IGoogleUpdate3Web>*)> |
grt | 9f391dd8 | 2016-09-07 12:49:32 | [diff] [blame] | 106 | GoogleUpdate3ClassFactory; |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 107 | |
grt | 9f391dd8 | 2016-09-07 12:49:32 | [diff] [blame] | 108 | // For use by tests that wish to provide a custom IGoogleUpdate3Web |
| 109 | // implementation independent of Google Update's. |
| 110 | void SetGoogleUpdateFactoryForTesting( |
grt | 1294c74 | 2015-05-13 14:30:15 | [diff] [blame] | 111 | const GoogleUpdate3ClassFactory& google_update_factory); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 112 | |
calamity | c59edd8 | 2017-07-20 07:20:42 | [diff] [blame] | 113 | void SetUpdateDriverTaskRunnerForTesting( |
Greg Thompson | c9c18a6d6 | 2017-07-28 09:14:30 | [diff] [blame] | 114 | base::SingleThreadTaskRunner* task_runner); |
calamity | c59edd8 | 2017-07-20 07:20:42 | [diff] [blame] | 115 | |
[email protected] | 3e0aa504 | 2012-07-14 15:49:42 | [diff] [blame] | 116 | #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |