OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_UPDATE_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_UPDATE_H_ |
6 #define CHROME_BROWSER_GOOGLE_UPDATE_H_ | 6 #define CHROME_BROWSER_GOOGLE_UPDATE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "google_update_idl.h" | 12 #include "google_update_idl.h" |
13 | 13 |
14 class MessageLoop; | 14 class MessageLoop; |
| 15 namespace views { |
| 16 class Window; |
| 17 } |
15 | 18 |
16 // The status of the upgrade. UPGRADE_STARTED and UPGRADE_CHECK_STARTED are | 19 // The status of the upgrade. UPGRADE_STARTED and UPGRADE_CHECK_STARTED are |
17 // internal states and will not be reported as results to the listener. | 20 // internal states and will not be reported as results to the listener. |
18 enum GoogleUpdateUpgradeResult { | 21 enum GoogleUpdateUpgradeResult { |
19 // The upgrade has started. | 22 // The upgrade has started. |
20 UPGRADE_STARTED = 0, | 23 UPGRADE_STARTED = 0, |
21 // A check for upgrade has been initiated. | 24 // A check for upgrade has been initiated. |
22 UPGRADE_CHECK_STARTED, | 25 UPGRADE_CHECK_STARTED, |
23 // An update is available. | 26 // An update is available. |
24 UPGRADE_IS_AVAILABLE, | 27 UPGRADE_IS_AVAILABLE, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // | 80 // |
78 //////////////////////////////////////////////////////////////////////////////// | 81 //////////////////////////////////////////////////////////////////////////////// |
79 class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> { | 82 class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> { |
80 public: | 83 public: |
81 GoogleUpdate(); | 84 GoogleUpdate(); |
82 virtual ~GoogleUpdate(); | 85 virtual ~GoogleUpdate(); |
83 | 86 |
84 // Ask Google Update to see if a new version is available. If the parameter | 87 // Ask Google Update to see if a new version is available. If the parameter |
85 // |install_if_newer| is true then Google Update will also install that new | 88 // |install_if_newer| is true then Google Update will also install that new |
86 // version. | 89 // version. |
87 void CheckForUpdate(bool install_if_newer); | 90 // |window| should point to a foreground window. This is needed to ensure |
| 91 // that Vista/Windows 7 UAC prompts show up in the foreground. It may also |
| 92 // be null. |
| 93 void CheckForUpdate(bool install_if_newer, views::Window* window); |
88 | 94 |
89 // Adds/removes a listener to report status back to. Only one listener is | 95 // Adds/removes a listener to report status back to. Only one listener is |
90 // maintained at the moment. | 96 // maintained at the moment. |
91 void AddStatusChangeListener(GoogleUpdateStatusListener* listener); | 97 void AddStatusChangeListener(GoogleUpdateStatusListener* listener); |
92 void RemoveStatusChangeListener(); | 98 void RemoveStatusChangeListener(); |
93 | 99 |
94 private: | 100 private: |
95 // We need to run the update check on another thread than the main thread, and | 101 // We need to run the update check on another thread than the main thread, and |
96 // therefore CheckForUpdate will delegate to this function. |main_loop| points | 102 // therefore CheckForUpdate will delegate to this function. |main_loop| points |
97 // to the message loop that we want the response to come from. | 103 // to the message loop that we want the response to come from. |
98 bool InitiateGoogleUpdateCheck(bool install_if_newer, MessageLoop* main_loop); | 104 // |window| should point to a foreground window. This is needed to ensure that |
| 105 // Vista/Windows 7 UAC prompts show up in the foreground. It may also be null. |
| 106 bool InitiateGoogleUpdateCheck(bool install_if_newer, views::Window* window, |
| 107 MessageLoop* main_loop); |
99 | 108 |
100 // This function reports the results of the GoogleUpdate operation to the | 109 // This function reports the results of the GoogleUpdate operation to the |
101 // listener. If results indicates an error, the error_code will indicate which | 110 // listener. If results indicates an error, the error_code will indicate which |
102 // error occurred. | 111 // error occurred. |
103 // Note, after this function completes, this object will have deleted itself. | 112 // Note, after this function completes, this object will have deleted itself. |
104 void ReportResults(GoogleUpdateUpgradeResult results, | 113 void ReportResults(GoogleUpdateUpgradeResult results, |
105 GoogleUpdateErrorCode error_code); | 114 GoogleUpdateErrorCode error_code); |
106 | 115 |
107 // This function reports failure from the Google Update operation to the | 116 // This function reports failure from the Google Update operation to the |
108 // listener. | 117 // listener. |
109 // Note, after this function completes, this object will have deleted itself. | 118 // Note, after this function completes, this object will have deleted itself. |
110 bool ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code, | 119 bool ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code, |
111 MessageLoop* main_loop); | 120 MessageLoop* main_loop); |
112 | 121 |
113 // The listener who is interested in finding out the result of the operation. | 122 // The listener who is interested in finding out the result of the operation. |
114 GoogleUpdateStatusListener* listener_; | 123 GoogleUpdateStatusListener* listener_; |
115 | 124 |
116 // Which version string Google Update found (if a new one was available). | 125 // Which version string Google Update found (if a new one was available). |
117 // Otherwise, this will be blank. | 126 // Otherwise, this will be blank. |
118 std::wstring version_available_; | 127 std::wstring version_available_; |
119 | 128 |
120 DISALLOW_EVIL_CONSTRUCTORS(GoogleUpdate); | 129 DISALLOW_EVIL_CONSTRUCTORS(GoogleUpdate); |
121 }; | 130 }; |
122 | 131 |
123 #endif // CHROME_BROWSER_GOOGLE_UPDATE_H_ | 132 #endif // CHROME_BROWSER_GOOGLE_UPDATE_H_ |
OLD | NEW |