blob: b66e322bd7326dc01fe902e18df59fc4dfd62feb [file] [log] [blame]
[email protected]cec99842012-02-10 03:24:231// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]3e0aa5042012-07-14 15:49:425#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_
6#define CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_
initial.commit09911bf2008-07-26 23:55:297
Robert Liaob2bc703d2017-10-17 20:52:358#include <wrl/client.h>
9
grt5a831092014-12-02 18:40:4410#include "base/callback_forward.h"
[email protected]3b63f8f42011-03-28 01:54:1511#include "base/memory/ref_counted.h"
grt1294c742015-05-13 14:30:1512#include "base/memory/weak_ptr.h"
[email protected]d8830562013-06-10 22:01:5413#include "base/strings/string16.h"
[email protected]cec99842012-02-10 03:24:2314#include "google_update/google_update_idl.h"
grt5a831092014-12-02 18:40:4415#include "ui/gfx/native_widget_types.h"
initial.commit09911bf2008-07-26 23:55:2916
[email protected]5e9e96a2013-03-31 02:29:2017namespace base {
Greg Thompsonc9c18a6d62017-07-28 09:14:3018class SingleThreadTaskRunner;
grt5a831092014-12-02 18:40:4419} // namespace base
initial.commit09911bf2008-07-26 23:55:2920
grt0fed9852014-10-18 16:16:4921// These values are used for a histogram. Do not reorder.
initial.commit09911bf2008-07-26 23:55:2922enum 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.
grt0fed9852014-10-18 16:16:4928 CANNOT_UPGRADE_CHROME_IN_THIS_DIRECTORY = 1,
grt1294c742015-05-13 14:30:1529 // Failed to create Google Update JobServer COM class. DEPRECATED.
30 // GOOGLE_UPDATE_JOB_SERVER_CREATION_FAILED = 2,
initial.commit09911bf2008-07-26 23:55:2931 // Failed to create Google Update OnDemand COM class.
grt0fed9852014-10-18 16:16:4932 GOOGLE_UPDATE_ONDEMAND_CLASS_NOT_FOUND = 3,
initial.commit09911bf2008-07-26 23:55:2933 // Google Update OnDemand COM class reported an error during a check for
34 // update (or while upgrading).
grt0fed9852014-10-18 16:16:4935 GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR = 4,
grt5a831092014-12-02 18:40:4436 // 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,
[email protected]287a0192008-07-31 18:49:3240 // An error occurred while upgrading (or while checking for update).
41 // Check the Google Update log in %TEMP% for more details.
grt0fed9852014-10-18 16:16:4942 GOOGLE_UPDATE_ERROR_UPDATING = 7,
[email protected]970749f2013-06-21 09:41:1243 // Updates can not be downloaded because the administrator has disabled all
44 // types of updating.
grt0fed9852014-10-18 16:16:4945 GOOGLE_UPDATE_DISABLED_BY_POLICY = 8,
[email protected]970749f2013-06-21 09:41:1246 // Updates can not be downloaded because the administrator has disabled
47 // manual (on-demand) updates. Automatic background updates are allowed.
grt9196d6c92015-08-22 02:15:0148 GOOGLE_UPDATE_DISABLED_BY_POLICY_AUTO_ONLY = 9,
grt0fed9852014-10-18 16:16:4949 NUM_ERROR_CODES
initial.commit09911bf2008-07-26 23:55:2950};
51
grt1294c742015-05-13 14:30:1552// A delegate by which a caller of BeginUpdateCheck is notified of the status
53// and results of an update check.
54class UpdateCheckDelegate {
55 public:
56 virtual ~UpdateCheckDelegate() {}
initial.commit09911bf2008-07-26 23:55:2957
grt1294c742015-05-13 14:30:1558 // 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;
initial.commit09911bf2008-07-26 23:55:2963
grt1294c742015-05-13 14:30:1564 // 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;
initial.commit09911bf2008-07-26 23:55:2971
grt1294c742015-05-13 14:30:1572 // 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;
76
77 // Invoked following an unrecoverable error, indicated by |error_code|.
bcwhite5895b192015-07-10 12:43:2778 // |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.
grt1294c742015-05-13 14:30:1583 virtual void OnError(GoogleUpdateErrorCode error_code,
bcwhite5895b192015-07-10 12:43:2784 const base::string16& html_error_message,
grt1294c742015-05-13 14:30:1585 const base::string16& new_version) = 0;
86
87 protected:
88 UpdateCheckDelegate() {}
89};
90
calamityc59edd82017-07-20 07:20:4291// Begins an asynchronous update check. If a new version is
grt1294c742015-05-13 14:30:1592// 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
grt9f391dd82016-09-07 12:49:3295// invoked on the caller's thread to provide feedback on the operation, with
96// messages localized to |locale| if possible.
97void BeginUpdateCheck(
grt9f391dd82016-09-07 12:49:3298 const std::string& locale,
99 bool install_update_if_possible,
100 gfx::AcceleratedWidget elevation_window,
101 const base::WeakPtr<UpdateCheckDelegate>& delegate);
grt1294c742015-05-13 14:30:15102
103// A type of callback supplied by tests to provide a custom IGoogleUpdate3Web
104// implementation (see src/google_update/google_update_idl.idl).
Robert Liaob2bc703d2017-10-17 20:52:35105typedef base::Callback<HRESULT(Microsoft::WRL::ComPtr<IGoogleUpdate3Web>*)>
grt9f391dd82016-09-07 12:49:32106 GoogleUpdate3ClassFactory;
grt1294c742015-05-13 14:30:15107
grt9f391dd82016-09-07 12:49:32108// For use by tests that wish to provide a custom IGoogleUpdate3Web
109// implementation independent of Google Update's.
110void SetGoogleUpdateFactoryForTesting(
grt1294c742015-05-13 14:30:15111 const GoogleUpdate3ClassFactory& google_update_factory);
initial.commit09911bf2008-07-26 23:55:29112
calamityc59edd82017-07-20 07:20:42113void SetUpdateDriverTaskRunnerForTesting(
Greg Thompsonc9c18a6d62017-07-28 09:14:30114 base::SingleThreadTaskRunner* task_runner);
calamityc59edd82017-07-20 07:20:42115
[email protected]3e0aa5042012-07-14 15:49:42116#endif // CHROME_BROWSER_GOOGLE_GOOGLE_UPDATE_WIN_H_