Use app list item shadow for app list folders.
[chromium-blink-merge.git] / chrome / browser / google / google_update_win.h
blob0e02c76338509c39e8d1bc3a196d88a68c8b1491
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 // DEPRECATED.
49 // GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY = 9,
50 NUM_ERROR_CODES
53 // A delegate by which a caller of BeginUpdateCheck is notified of the status
54 // and results of an update check.
55 class UpdateCheckDelegate {
56 public:
57 virtual ~UpdateCheckDelegate() {}
59 // Invoked following a successful update check. |new_version|, if not empty,
60 // indicates the new version that is available. Otherwise (if |new_version| is
61 // empty), Chrome is up to date. This method will only be invoked when
62 // BeginUpdateCheck is called with |install_update_if_possible| == false.
63 virtual void OnUpdateCheckComplete(const base::string16& new_version) = 0;
65 // Invoked zero or more times during an upgrade. |progress|, a number between
66 // 0 and 100 (inclusive), is an estimation as to what percentage of the
67 // upgrade has completed. |new_version| indicates the version that is being
68 // download and installed. This method will only be invoked when
69 // BeginUpdateCheck is called with |install_update_if_possible| == true.
70 virtual void OnUpgradeProgress(int progress,
71 const base::string16& new_version) = 0;
73 // Invoked following a successful upgrade. |new_version| indicates the version
74 // to which Chrome was updated. This method will only be invoked when
75 // BeginUpdateCheck is called with |install_update_if_possible| == true.
76 virtual void OnUpgradeComplete(const base::string16& new_version) = 0;
78 // Invoked following an unrecoverable error, indicated by |error_code|.
79 // |error_message|, if not empty, contains a localized string that may be
80 // presented to the user explaining the nature of the error. |new_version|, if
81 // not empty, indicates the version to which an upgrade attempt was made.
82 virtual void OnError(GoogleUpdateErrorCode error_code,
83 const base::string16& error_message,
84 const base::string16& new_version) = 0;
86 protected:
87 UpdateCheckDelegate() {}
90 // Begins an asynchronous update check on |task_runner|. If a new version is
91 // available and |install_update_if_possible| is true, the new version will be
92 // automatically downloaded and installed. |elevation_window| is the window
93 // which should own any necessary elevation UI. Methods on |delegate| will be
94 // invoked on the caller's thread to provide feedback on the operation, with
95 // messages localized to |locale| if possible.
96 void BeginUpdateCheck(
97 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
98 const std::string& locale,
99 bool install_update_if_possible,
100 gfx::AcceleratedWidget elevation_window,
101 const base::WeakPtr<UpdateCheckDelegate>& delegate);
103 // A type of callback supplied by tests to provide a custom IGoogleUpdate3Web
104 // implementation (see src/google_update/google_update_idl.idl).
105 typedef base::Callback<HRESULT(base::win::ScopedComPtr<IGoogleUpdate3Web>*)>
106 GoogleUpdate3ClassFactory;
108 // For use by tests that wish to provide a custom IGoogleUpdate3Web
109 // implementation independent of Google Update's.
110 void SetGoogleUpdateFactoryForTesting(
111 const GoogleUpdate3ClassFactory& google_update_factory);
113 #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_