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_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |
6 #define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
11 #if defined(OS_WIN) | |
12 #include "google_update/google_update_idl.h" | 11 #include "google_update/google_update_idl.h" |
13 #endif | |
14 | 12 |
15 class MessageLoop; | 13 class MessageLoop; |
16 namespace views { | 14 namespace views { |
17 class Widget; | 15 class Widget; |
18 } | 16 } |
19 | 17 |
20 // The status of the upgrade. UPGRADE_STARTED and UPGRADE_CHECK_STARTED are | 18 // 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. | 19 // internal states and will not be reported as results to the listener. |
22 enum GoogleUpdateUpgradeResult { | 20 enum GoogleUpdateUpgradeResult { |
23 // The upgrade has started. | 21 // The upgrade has started. |
24 UPGRADE_STARTED = 0, | 22 UPGRADE_STARTED = 0, |
25 // A check for upgrade has been initiated. | 23 // A check for upgrade has been initiated. |
26 UPGRADE_CHECK_STARTED, | 24 UPGRADE_CHECK_STARTED, |
27 // An update is available. | 25 // An update is available. |
28 UPGRADE_IS_AVAILABLE, | 26 UPGRADE_IS_AVAILABLE, |
29 // The upgrade happened successfully. | 27 // The upgrade happened successfully. |
30 UPGRADE_SUCCESSFUL, | 28 UPGRADE_SUCCESSFUL, |
31 // No need to upgrade, we are up to date. | 29 // No need to upgrade, Chrome is up to date. |
32 UPGRADE_ALREADY_UP_TO_DATE, | 30 UPGRADE_ALREADY_UP_TO_DATE, |
33 // An error occurred. | 31 // An error occurred. |
34 UPGRADE_ERROR, | 32 UPGRADE_ERROR, |
35 }; | 33 }; |
36 | 34 |
37 enum GoogleUpdateErrorCode { | 35 enum GoogleUpdateErrorCode { |
38 // The upgrade completed successfully (or hasn't been started yet). | 36 // The upgrade completed successfully (or hasn't been started yet). |
39 GOOGLE_UPDATE_NO_ERROR = 0, | 37 GOOGLE_UPDATE_NO_ERROR = 0, |
40 // Google Update only supports upgrading if Chrome is installed in the default | 38 // Google Update only supports upgrading if Chrome is installed in the default |
41 // location. This error will appear for developer builds and with | 39 // location. This error will appear for developer builds and with |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> { | 85 class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> { |
88 public: | 86 public: |
89 GoogleUpdate(); | 87 GoogleUpdate(); |
90 | 88 |
91 // Ask Google Update to see if a new version is available. If the parameter | 89 // Ask Google Update to see if a new version is available. If the parameter |
92 // |install_if_newer| is true then Google Update will also install that new | 90 // |install_if_newer| is true then Google Update will also install that new |
93 // version. | 91 // version. |
94 // |window| should point to a foreground window. This is needed to ensure | 92 // |window| should point to a foreground window. This is needed to ensure |
95 // that Vista/Windows 7 UAC prompts show up in the foreground. It may also | 93 // that Vista/Windows 7 UAC prompts show up in the foreground. It may also |
96 // be null. | 94 // be null. |
97 void CheckForUpdate(bool install_if_newer, views::Widget* window); | 95 void CheckForUpdate(bool install_if_newer, HWND window); |
98 | 96 |
99 // Pass NULL to clear the listener | 97 // Pass NULL to clear the listener |
100 void set_status_listener(GoogleUpdateStatusListener* listener) { | 98 void set_status_listener(GoogleUpdateStatusListener* listener) { |
101 listener_ = listener; | 99 listener_ = listener; |
102 } | 100 } |
103 | 101 |
104 private: | 102 private: |
105 friend class base::RefCountedThreadSafe<GoogleUpdate>; | 103 friend class base::RefCountedThreadSafe<GoogleUpdate>; |
106 | 104 |
107 virtual ~GoogleUpdate(); | 105 virtual ~GoogleUpdate(); |
108 | 106 |
109 // The chromeos implementation is in browser/chromeos/google_update.cpp | |
110 | |
111 #if defined(OS_WIN) | |
112 | |
113 // This function reports failure from the Google Update operation to the | 107 // This function reports failure from the Google Update operation to the |
114 // listener. | 108 // listener. |
115 // Note, after this function completes, this object will have deleted itself. | 109 // Note, after this function completes, this object will have deleted itself. |
116 bool ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code, | 110 bool ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code, |
117 const string16& error_message, MessageLoop* main_loop); | 111 const string16& error_message, MessageLoop* main_loop); |
118 | 112 |
119 #endif | 113 // The update check needs to run on another thread than the main thread, and |
120 | |
121 // We need to run the update check on another thread than the main thread, and | |
122 // therefore CheckForUpdate will delegate to this function. |main_loop| points | 114 // therefore CheckForUpdate will delegate to this function. |main_loop| points |
123 // to the message loop that we want the response to come from. | 115 // to the message loop that the response must come from. |
124 // |window| should point to a foreground window. This is needed to ensure that | 116 // |window| should point to a foreground window. This is needed to ensure that |
125 // Vista/Windows 7 UAC prompts show up in the foreground. It may also be null. | 117 // Vista/Windows 7 UAC prompts show up in the foreground. It may also be null. |
126 void InitiateGoogleUpdateCheck(bool install_if_newer, views::Widget* window, | 118 void InitiateGoogleUpdateCheck(bool install_if_newer, HWND window, |
127 MessageLoop* main_loop); | 119 MessageLoop* main_loop); |
128 | 120 |
129 // This function reports the results of the GoogleUpdate operation to the | 121 // This function reports the results of the GoogleUpdate operation to the |
130 // listener. If results indicates an error, the |error_code| and | 122 // listener. If results indicates an error, the |error_code| and |
131 // |error_message| will indicate which error occurred. | 123 // |error_message| will indicate which error occurred. |
132 // Note, after this function completes, this object will have deleted itself. | 124 // Note, after this function completes, this object will have deleted itself. |
133 void ReportResults(GoogleUpdateUpgradeResult results, | 125 void ReportResults(GoogleUpdateUpgradeResult results, |
134 GoogleUpdateErrorCode error_code, | 126 GoogleUpdateErrorCode error_code, |
135 const string16& error_message); | 127 const string16& error_message); |
136 | 128 |
137 // Which version string Google Update found (if a new one was available). | 129 // Which version string Google Update found (if a new one was available). |
138 // Otherwise, this will be blank. | 130 // Otherwise, this will be blank. |
139 string16 version_available_; | 131 string16 version_available_; |
140 | 132 |
141 // The listener who is interested in finding out the result of the operation. | 133 // The listener who is interested in finding out the result of the operation. |
142 GoogleUpdateStatusListener* listener_; | 134 GoogleUpdateStatusListener* listener_; |
143 | 135 |
144 DISALLOW_COPY_AND_ASSIGN(GoogleUpdate); | 136 DISALLOW_COPY_AND_ASSIGN(GoogleUpdate); |
145 }; | 137 }; |
146 | 138 |
147 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_ | 139 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_ |
OLD | NEW |