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