Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / webui / help / version_updater.h
blobbef7e5578ba5298e22ca33d3fcbd183853f19428
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_UI_WEBUI_HELP_VERSION_UPDATER_H_
6 #define CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/strings/string16.h"
13 namespace content {
14 class WebContents;
17 // Interface implemented to expose per-platform updating functionality.
18 class VersionUpdater {
19 public:
20 // Update process state machine.
21 enum Status {
22 CHECKING,
23 UPDATING,
24 NEARLY_UPDATED,
25 UPDATED,
26 FAILED,
27 FAILED_OFFLINE,
28 FAILED_CONNECTION_TYPE_DISALLOWED,
29 DISABLED,
32 #if defined(OS_MACOSX)
33 // Promotion state.
34 enum PromotionState {
35 PROMOTE_HIDDEN,
36 PROMOTE_ENABLED,
37 PROMOTE_DISABLED
39 #endif // defined(OS_MACOSX)
41 // TODO(jhawkins): Use a delegate interface instead of multiple callback
42 // types.
43 #if defined(OS_CHROMEOS)
44 typedef base::Callback<void(const std::string&)> ChannelCallback;
45 #endif
47 // Used to update the client of status changes. int parameter is the progress
48 // and should only be non-zero for the UPDATING state.
49 // base::string16 parameter is a message explaining a failure.
50 typedef base::Callback<void(Status, int, const base::string16&)>
51 StatusCallback;
53 #if defined(OS_MACOSX)
54 // Used to show or hide the promote UI elements.
55 typedef base::Callback<void(PromotionState)> PromoteCallback;
56 #endif
58 virtual ~VersionUpdater() {}
60 // Sub-classes must implement this method to create the respective
61 // specialization.
62 static VersionUpdater* Create(content::WebContents* web_contents);
64 // Begins the update process by checking for update availability.
65 // |status_callback| is called for each status update. |promote_callback| can
66 // be used to show or hide the promote UI elements.
67 virtual void CheckForUpdate(const StatusCallback& status_callback
68 #if defined(OS_MACOSX)
69 , const PromoteCallback& promote_callback
70 #endif
71 ) = 0;
73 #if defined(OS_MACOSX)
74 // Make updates available for all users.
75 virtual void PromoteUpdater() const = 0;
76 #endif
78 // Relaunches the browser, generally after being updated.
79 virtual void RelaunchBrowser() const = 0;
81 #if defined(OS_CHROMEOS)
82 virtual void SetChannel(const std::string& channel,
83 bool is_powerwash_allowed) = 0;
84 virtual void GetChannel(bool get_current_channel,
85 const ChannelCallback& callback) = 0;
86 #endif
89 #endif // CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_H_