OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |
6 #define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ | 6 #define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/weak_ptr.h" | |
11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
12 #include "base/win/scoped_comptr.h" | 13 #include "base/win/scoped_comptr.h" |
13 #include "google_update/google_update_idl.h" | 14 #include "google_update/google_update_idl.h" |
14 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class TaskRunner; | 18 class SingleThreadTaskRunner; |
18 } // namespace base | 19 } // namespace base |
19 | 20 |
20 // The status of the upgrade. UPGRADE_STARTED and UPGRADE_CHECK_STARTED are | |
21 // internal states and will not be reported as results to the listener. | |
22 // These values are used for a histogram. Do not reorder. | |
23 enum GoogleUpdateUpgradeResult { | |
24 // The upgrade has started. | |
25 UPGRADE_STARTED = 0, | |
26 // A check for upgrade has been initiated. | |
27 UPGRADE_CHECK_STARTED = 1, | |
28 // An update is available. | |
29 UPGRADE_IS_AVAILABLE = 2, | |
30 // The upgrade happened successfully. | |
31 UPGRADE_SUCCESSFUL = 3, | |
32 // No need to upgrade, Chrome is up to date. | |
33 UPGRADE_ALREADY_UP_TO_DATE = 4, | |
34 // An error occurred. | |
35 UPGRADE_ERROR = 5, | |
36 NUM_UPGRADE_RESULTS | |
37 }; | |
38 | |
39 // These values are used for a histogram. Do not reorder. | 21 // These values are used for a histogram. Do not reorder. |
40 enum GoogleUpdateErrorCode { | 22 enum GoogleUpdateErrorCode { |
41 // The upgrade completed successfully (or hasn't been started yet). | 23 // The upgrade completed successfully (or hasn't been started yet). |
42 GOOGLE_UPDATE_NO_ERROR = 0, | 24 GOOGLE_UPDATE_NO_ERROR = 0, |
43 // Google Update only supports upgrading if Chrome is installed in the default | 25 // Google Update only supports upgrading if Chrome is installed in the default |
44 // location. This error will appear for developer builds and with | 26 // location. This error will appear for developer builds and with |
45 // installations unzipped to random locations. | 27 // installations unzipped to random locations. |
46 CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY = 1, | 28 CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY = 1, |
47 // Failed to create Google Update JobServer COM class. | 29 // Failed to create Google Update JobServer COM class. DEPRECATED. |
48 GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED = 2, | 30 // GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED = 2, |
49 // Failed to create Google Update OnDemand COM class. | 31 // Failed to create Google Update OnDemand COM class. |
50 GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND = 3, | 32 GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND = 3, |
51 // Google Update OnDemand COM class reported an error during a check for | 33 // Google Update OnDemand COM class reported an error during a check for |
52 // update (or while upgrading). | 34 // update (or while upgrading). |
53 GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR = 4, | 35 GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR = 4, |
54 // A call to GetResults failed. DEPRECATED. | 36 // A call to GetResults failed. DEPRECATED. |
55 // GOOGLE_UPDATE_GET_RESULT_CALL_FAILED = 5, | 37 // GOOGLE_UPDATE_GET_RESULT_CALL_FAILED = 5, |
56 // A call to GetVersionInfo failed. DEPRECATED | 38 // A call to GetVersionInfo failed. DEPRECATED |
57 // GOOGLE_UPDATE_GET_VERSION_INFO_FAILED = 6, | 39 // GOOGLE_UPDATE_GET_VERSION_INFO_FAILED = 6, |
58 // An error occurred while upgrading (or while checking for update). | 40 // An error occurred while upgrading (or while checking for update). |
59 // Check the Google Update log in %TEMP% for more details. | 41 // Check the Google Update log in %TEMP% for more details. |
60 GOOGLE_UPDATE_ERROR_UPDATING = 7, | 42 GOOGLE_UPDATE_ERROR_UPDATING = 7, |
61 // Updates can not be downloaded because the administrator has disabled all | 43 // Updates can not be downloaded because the administrator has disabled all |
62 // types of updating. | 44 // types of updating. |
63 GOOGLE_UPDATE_DISABLED_BY_POLICY = 8, | 45 GOOGLE_UPDATE_DISABLED_BY_POLICY = 8, |
64 // Updates can not be downloaded because the administrator has disabled | 46 // Updates can not be downloaded because the administrator has disabled |
65 // manual (on-demand) updates. Automatic background updates are allowed. | 47 // manual (on-demand) updates. Automatic background updates are allowed. |
66 GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY = 9, | 48 // DEPRECATED. |
49 // GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY = 9, | |
67 NUM_ERROR_CODES | 50 NUM_ERROR_CODES |
68 }; | 51 }; |
69 | 52 |
70 // A callback run when a check for updates has completed. |result| indicates the | 53 // A delegate by which a caller of BeginUpdateCheck is notified of the status |
71 // end state of the operation. When |result| is UPGRADE_ERROR, |error_code| and | 54 // and results of an update check. |
72 // |error_message| indicate the the nature of the error. When |result| is | 55 class UpdateCheckDelegate { |
73 // UPGRADE_IS_AVAILABLE or UPGRADE_SUCCESSFUL, |version| may indicate the new | 56 public: |
74 // version Google Update detected (it may, however, be empty). | 57 virtual ~UpdateCheckDelegate() {} |
75 typedef base::Callback<void(GoogleUpdateUpgradeResult result, | |
76 GoogleUpdateErrorCode error_code, | |
77 const base::string16& error_message, | |
78 const base::string16& version)> UpdateCheckCallback; | |
79 | 58 |
80 // Begins an asynchronous update check on |task_runner|, which must run a | 59 // Invoked following a successful update check. |new_version|, if not empty, |
81 // TYPE_UI message loop. If |install_if_newer| is true, an update will be | 60 // indicates the new version that is available. Otherwise (if |new_version| is |
82 // applied. |elevation_window| is the window which should own any necessary | 61 // empty), Chrome is up to date. This method will only be invoked when |
83 // elevation UI. |callback| will be run on the caller's thread when the check | 62 // BeginUpdateCheck is called with |install_update_if_possible| == false. |
84 // completes. | 63 virtual void OnUpdateCheckComplete(const base::string16& new_version) = 0; |
85 void BeginUpdateCheck(const scoped_refptr<base::TaskRunner>& task_runner, | |
86 bool install_if_newer, | |
87 gfx::AcceleratedWidget elevation_window, | |
88 const UpdateCheckCallback& callback); | |
89 | 64 |
90 // A type of callback supplied by tests to provide a custom IGoogleUpdate | 65 // Invoked zero or more times during an upgrade. |progress|, a number between |
91 // implementation. | 66 // 0 and 100 (inclusive), is an estimation as to what percent of the upgrade |
Peter Kasting
2015/05/12 22:04:34
Nit: percentage
grt (UTC plus 2)
2015/05/13 13:04:05
Done.
| |
92 typedef base::Callback<HRESULT(base::win::ScopedComPtr<IGoogleUpdate>*)> | 67 // has completed. |new_version| indicates the version that is being download |
93 OnDemandAppsClassFactory; | 68 // and installed. This method will only be invoked when BeginUpdateCheck is |
69 // called with |install_update_if_possible| == true. | |
70 virtual void OnUpgradeProgress(int progress, | |
71 const base::string16& new_version) = 0; | |
94 | 72 |
95 // For use by tests that wish to provide a custom IGoogleUpdate implementation | 73 // Invoked following a successful upgrade. |new_version| indicates the version |
96 // independent of Google Update's. | 74 // to which Chrome was updated. This method will only be invoked when |
75 // BeginUpdateCheck is called with |install_update_if_possible| == true. | |
76 virtual void OnUpgradeComplete(const base::string16& new_version) = 0; | |
77 | |
78 // Invoked following an unrecoverable error, indicated by |error_code|. | |
79 // |error_message|, if not empty, contains a localized string that may be | |
80 // presented to the user explaining the nature of the error. |new_version|, if | |
81 // not empty, indicates the version to which an upgrade attempt was made. | |
82 virtual void OnError(GoogleUpdateErrorCode error_code, | |
83 const base::string16& error_message, | |
84 const base::string16& new_version) = 0; | |
85 | |
86 protected: | |
87 UpdateCheckDelegate() {} | |
88 }; | |
89 | |
90 // Begins an asynchronous update check on |task_runner|. If a new version is | |
91 // available and |install_update_if_possible| is true, the new version will be | |
92 // automatically downloaded and installed. |elevation_window| is the window | |
93 // which should own any necessary elevation UI. Methods on |delegate| will be | |
94 // invoked on the caller's thread to provide feedback on the operation, with | |
95 // messages localized to |locale| if possible. | |
96 void BeginUpdateCheck( | |
97 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | |
98 const std::string& locale, | |
99 bool install_update_if_possible, | |
100 gfx::AcceleratedWidget elevation_window, | |
101 const base::WeakPtr<UpdateCheckDelegate>& delegate); | |
102 | |
103 // A type of callback supplied by tests to provide a custom IGoogleUpdate3Web | |
104 // implementation (see src/google_update/google_update_idl.idl). | |
105 typedef base::Callback<HRESULT(base::win::ScopedComPtr<IGoogleUpdate3Web>*)> | |
106 GoogleUpdate3ClassFactory; | |
107 | |
108 // For use by tests that wish to provide a custom IGoogleUpdateWeb3 | |
Peter Kasting
2015/05/12 22:04:34
IGoogleUpdate3Web?
grt (UTC plus 2)
2015/05/13 13:04:05
Done.
| |
109 // implementation independent of Google Update's. | |
97 void SetGoogleUpdateFactoryForTesting( | 110 void SetGoogleUpdateFactoryForTesting( |
98 const OnDemandAppsClassFactory& google_update_factory); | 111 const GoogleUpdate3ClassFactory& google_update_factory); |
99 | 112 |
100 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ | 113 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |
OLD | NEW |