Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/browser/google/google_update.h

Issue 10698106: Switch about box to web ui on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better hack for reusing GOOGLE_UPDATE_ERROR_UPDATING Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_
6 #define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/string16.h"
11 #if defined(OS_WIN)
12 #include "google_update/google_update_idl.h"
13 #endif
14
15 class MessageLoop;
16 namespace views {
17 class Widget;
18 }
19
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 enum GoogleUpdateUpgradeResult {
23 // The upgrade has started.
24 UPGRADE_STARTED = 0,
25 // A check for upgrade has been initiated.
26 UPGRADE_CHECK_STARTED,
27 // An update is available.
28 UPGRADE_IS_AVAILABLE,
29 // The upgrade happened successfully.
30 UPGRADE_SUCCESSFUL,
31 // No need to upgrade, we are up to date.
32 UPGRADE_ALREADY_UP_TO_DATE,
33 // An error occurred.
34 UPGRADE_ERROR,
35 };
36
37 enum GoogleUpdateErrorCode {
38 // The upgrade completed successfully (or hasn't been started yet).
39 GOOGLE_UPDATE_NO_ERROR = 0,
40 // Google Update only supports upgrading if Chrome is installed in the default
41 // location. This error will appear for developer builds and with
42 // installations unzipped to random locations.
43 CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY,
44 // Failed to create Google Update JobServer COM class.
45 GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED,
46 // Failed to create Google Update OnDemand COM class.
47 GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND,
48 // Google Update OnDemand COM class reported an error during a check for
49 // update (or while upgrading).
50 GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR,
51 // A call to GetResults failed.
52 GOOGLE_UPDATE_GET_RESULT_CALL_FAILED,
53 // A call to GetVersionInfo failed.
54 GOOGLE_UPDATE_GET_VERSION_INFO_FAILED,
55 // An error occurred while upgrading (or while checking for update).
56 // Check the Google Update log in %TEMP% for more details.
57 GOOGLE_UPDATE_ERROR_UPDATING,
58 // Updates can not be downloaded because the administrator has disabled them.
59 GOOGLE_UPDATE_DISABLED_BY_POLICY,
60 };
61
62 // The GoogleUpdateStatusListener interface is used by components to receive
63 // notifications about the results of an Google Update operation.
64 class GoogleUpdateStatusListener {
65 public:
66 // This function is called when Google Update has finished its operation and
67 // wants to notify us about the results. |results| represents what the end
68 // state is, |error_code| represents what error occurred, |error_message| is a
69 // string version of the same (might be blank) and |version| specifies what
70 // new version Google Update detected (or installed). This value can be a
71 // blank string, if the version tag in the Update{} block (in Google Update's
72 // server config for Chrome) is blank.
73 virtual void OnReportResults(GoogleUpdateUpgradeResult results,
74 GoogleUpdateErrorCode error_code,
75 const string16& error_message,
76 const string16& version) = 0;
77 };
78
79 ////////////////////////////////////////////////////////////////////////////////
80 //
81 // The Google Update class is responsible for communicating with Google Update
82 // and get it to perform operations on our behalf (for example, CheckForUpdate).
83 // This class will report back to its parent via the GoogleUpdateStatusListener
84 // interface and will delete itself after reporting back.
85 //
86 ////////////////////////////////////////////////////////////////////////////////
87 class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> {
88 public:
89 GoogleUpdate();
90
91 // 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
93 // version.
94 // |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
96 // be null.
97 void CheckForUpdate(bool install_if_newer, views::Widget* window);
98
99 // Pass NULL to clear the listener
100 void set_status_listener(GoogleUpdateStatusListener* listener) {
101 listener_ = listener;
102 }
103
104 private:
105 friend class base::RefCountedThreadSafe<GoogleUpdate>;
106
107 virtual ~GoogleUpdate();
108
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
114 // listener.
115 // Note, after this function completes, this object will have deleted itself.
116 bool ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code,
117 const string16& error_message, MessageLoop* main_loop);
118
119 #endif
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
123 // to the message loop that we want the response to come from.
124 // |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.
126 void InitiateGoogleUpdateCheck(bool install_if_newer, views::Widget* window,
127 MessageLoop* main_loop);
128
129 // This function reports the results of the GoogleUpdate operation to the
130 // listener. If results indicates an error, the |error_code| and
131 // |error_message| will indicate which error occurred.
132 // Note, after this function completes, this object will have deleted itself.
133 void ReportResults(GoogleUpdateUpgradeResult results,
134 GoogleUpdateErrorCode error_code,
135 const string16& error_message);
136
137 // Which version string Google Update found (if a new one was available).
138 // Otherwise, this will be blank.
139 string16 version_available_;
140
141 // The listener who is interested in finding out the result of the operation.
142 GoogleUpdateStatusListener* listener_;
143
144 DISALLOW_COPY_AND_ASSIGN(GoogleUpdate);
145 };
146
147 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/google/google_update.cc » ('j') | chrome/browser/ui/webui/help/version_updater_chromeos.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698