Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / chrome / browser / google / google_update_win.h
blobdf9c84a6ee80f83e02bf7ef03ac158ee9d16dca5
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.
5 #ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_
6 #define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h"
13 #include "base/win/scoped_comptr.h"
14 #include "google_update/google_update_idl.h"
15 #include "ui/gfx/native_widget_types.h"
17 namespace base {
18 class SingleThreadTaskRunner;
19 } // namespace base
21 // These values are used for a histogram. Do not reorder.
22 enum GoogleUpdateErrorCode {
23 // The upgrade completed successfully (or hasn't been started yet).
24 GOOGLE_UPDATE_NO_ERROR = 0,
25 // Google Update only supports upgrading if Chrome is installed in the default
26 // location. This error will appear for developer builds and with
27 // installations unzipped to random locations.
28 CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY = 1,
29 // Failed to create Google Update JobServer COM class. DEPRECATED.
30 // GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED = 2,
31 // Failed to create Google Update OnDemand COM class.
32 GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND = 3,
33 // Google Update OnDemand COM class reported an error during a check for
34 // update (or while upgrading).
35 GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR = 4,
36 // A call to GetResults failed. DEPRECATED.
37 // GOOGLE_UPDATE_GET_RESULT_CALL_FAILED = 5,
38 // A call to GetVersionInfo failed. DEPRECATED
39 // GOOGLE_UPDATE_GET_VERSION_INFO_FAILED = 6,
40 // An error occurred while upgrading (or while checking for update).
41 // Check the Google Update log in %TEMP% for more details.
42 GOOGLE_UPDATE_ERROR_UPDATING = 7,
43 // Updates can not be downloaded because the administrator has disabled all
44 // types of updating.
45 GOOGLE_UPDATE_DISABLED_BY_POLICY = 8,
46 // Updates can not be downloaded because the administrator has disabled
47 // manual (on-demand) updates. Automatic background updates are allowed.
48 GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY = 9,
49 NUM_ERROR_CODES
52 // A delegate by which a caller of BeginUpdateCheck is notified of the status
53 // and results of an update check.
54 class UpdateCheckDelegate {
55 public:
56 virtual ~UpdateCheckDelegate() {}
58 // Invoked following a successful update check. |new_version|, if not empty,
59 // indicates the new version that is available. Otherwise (if |new_version| is
60 // empty), Chrome is up to date. This method will only be invoked when
61 // BeginUpdateCheck is called with |install_update_if_possible| == false.
62 virtual void OnUpdateCheckComplete(const base::string16& new_version) = 0;
64 // Invoked zero or more times during an upgrade. |progress|, a number between
65 // 0 and 100 (inclusive), is an estimation as to what percentage of the
66 // upgrade has completed. |new_version| indicates the version that is being
67 // download and installed. This method will only be invoked when
68 // BeginUpdateCheck is called with |install_update_if_possible| == true.
69 virtual void OnUpgradeProgress(int progress,
70 const base::string16& new_version) = 0;
72 // Invoked following a successful upgrade. |new_version| indicates the version
73 // to which Chrome was updated. This method will only be invoked when
74 // BeginUpdateCheck is called with |install_update_if_possible| == true.
75 virtual void OnUpgradeComplete(const base::string16& new_version) = 0;
77 // Invoked following an unrecoverable error, indicated by |error_code|.
78 // |html_error_message|, if not empty, must be a localized string containing
79 // all information required by users to act on the error as well as for
80 // support staff to diagnose it (i.e. |error_code| and any other related
81 // state information). |new_version|, if not empty, indicates the version
82 // to which an upgrade attempt was made.
83 virtual void OnError(GoogleUpdateErrorCode error_code,
84 const base::string16& html_error_message,
85 const base::string16& new_version) = 0;
87 protected:
88 UpdateCheckDelegate() {}
91 // Begins an asynchronous update check on |task_runner|. If a new version is
92 // available and |install_update_if_possible| is true, the new version will be
93 // automatically downloaded and installed. |elevation_window| is the window
94 // which should own any necessary elevation UI. Methods on |delegate| will be
95 // invoked on the caller's thread to provide feedback on the operation, with
96 // messages localized to |locale| if possible.
97 void BeginUpdateCheck(
98 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
99 const std::string& locale,
100 bool install_update_if_possible,
101 gfx::AcceleratedWidget elevation_window,
102 const base::WeakPtr<UpdateCheckDelegate>& delegate);
104 // A type of callback supplied by tests to provide a custom IGoogleUpdate3Web
105 // implementation (see src/google_update/google_update_idl.idl).
106 typedef base::Callback<HRESULT(base::win::ScopedComPtr<IGoogleUpdate3Web>*)>
107 GoogleUpdate3ClassFactory;
109 // For use by tests that wish to provide a custom IGoogleUpdate3Web
110 // implementation independent of Google Update's.
111 void SetGoogleUpdateFactoryForTesting(
112 const GoogleUpdate3ClassFactory& google_update_factory);
114 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_