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