| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 | 13 |
| 14 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
| 15 #include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h" | 15 #include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h" |
| 16 #endif // defined(OS_CHROMEOS) | 16 #endif // defined(OS_CHROMEOS) |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 class WebContents; | 19 class WebContents; |
| 20 } | 20 } |
| 21 | 21 |
| 22 // Interface implemented to expose per-platform updating functionality. | 22 // Interface implemented to expose per-platform updating functionality. |
| 23 class VersionUpdater { | 23 class VersionUpdater { |
| 24 public: | 24 public: |
| 25 // Update process state machine. | 25 // Update process state machine. |
| 26 enum Status { | 26 enum Status { |
| 27 CHECKING, | 27 CHECKING, |
| 28 NEED_PERMISSION_TO_UPDATE, |
| 28 UPDATING, | 29 UPDATING, |
| 29 NEARLY_UPDATED, | 30 NEARLY_UPDATED, |
| 30 UPDATED, | 31 UPDATED, |
| 31 FAILED, | 32 FAILED, |
| 32 FAILED_OFFLINE, | 33 FAILED_OFFLINE, |
| 33 FAILED_CONNECTION_TYPE_DISALLOWED, | 34 FAILED_CONNECTION_TYPE_DISALLOWED, |
| 34 DISABLED, | 35 DISABLED, |
| 35 DISABLED_BY_ADMIN | 36 DISABLED_BY_ADMIN |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 // Promotion state (Mac-only). | 39 // Promotion state (Mac-only). |
| 39 enum PromotionState { | 40 enum PromotionState { |
| 40 PROMOTE_HIDDEN, | 41 PROMOTE_HIDDEN, |
| 41 PROMOTE_ENABLED, | 42 PROMOTE_ENABLED, |
| 42 PROMOTE_DISABLED, | 43 PROMOTE_DISABLED, |
| 43 PROMOTED, | 44 PROMOTED, |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 // TODO(jhawkins): Use a delegate interface instead of multiple callback | 47 // TODO(jhawkins): Use a delegate interface instead of multiple callback |
| 47 // types. | 48 // types. |
| 48 #if defined(OS_CHROMEOS) | 49 #if defined(OS_CHROMEOS) |
| 49 typedef base::Callback<void(const std::string&)> ChannelCallback; | 50 typedef base::Callback<void(const std::string&)> ChannelCallback; |
| 50 typedef base::Callback<void(update_engine::EndOfLifeStatus status)> | 51 typedef base::Callback<void(update_engine::EndOfLifeStatus status)> |
| 51 EolStatusCallback; | 52 EolStatusCallback; |
| 52 #endif | 53 #endif |
| 53 | 54 |
| 54 // Used to update the client of status changes. int parameter is the progress | 55 // Used to update the client of status changes. int parameter is the progress |
| 55 // and should only be non-zero for the UPDATING state. | 56 // and should only be non-zero for the UPDATING state. |
| 57 // std::string parameter is the version of the available update and should be |
| 58 // empty string when update is not available. |
| 59 // int64_t parameter is the size in bytes of the available update and should |
| 60 // be 0 when update is not available. |
| 56 // base::string16 parameter is a message explaining a failure. | 61 // base::string16 parameter is a message explaining a failure. |
| 57 typedef base::Callback<void(Status, int, const base::string16&)> | 62 typedef base::Callback< |
| 63 void(Status, int, const std::string&, int64_t, const base::string16&)> |
| 58 StatusCallback; | 64 StatusCallback; |
| 59 | 65 |
| 60 // Used to show or hide the promote UI elements. Mac-only. | 66 // Used to show or hide the promote UI elements. Mac-only. |
| 61 typedef base::Callback<void(PromotionState)> PromoteCallback; | 67 typedef base::Callback<void(PromotionState)> PromoteCallback; |
| 62 | 68 |
| 63 virtual ~VersionUpdater() {} | 69 virtual ~VersionUpdater() {} |
| 64 | 70 |
| 65 // Sub-classes must implement this method to create the respective | 71 // Sub-classes must implement this method to create the respective |
| 66 // specialization. |web_contents| may be null, in which case any required UX | 72 // specialization. |web_contents| may be null, in which case any required UX |
| 67 // (e.g., UAC to elevate on Windows) may not be associated with any existing | 73 // (e.g., UAC to elevate on Windows) may not be associated with any existing |
| (...skipping 11 matching lines...) Expand all Loading... |
| 79 // Make updates available for all users. | 85 // Make updates available for all users. |
| 80 virtual void PromoteUpdater() const = 0; | 86 virtual void PromoteUpdater() const = 0; |
| 81 #endif | 87 #endif |
| 82 | 88 |
| 83 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
| 84 virtual void SetChannel(const std::string& channel, | 90 virtual void SetChannel(const std::string& channel, |
| 85 bool is_powerwash_allowed) = 0; | 91 bool is_powerwash_allowed) = 0; |
| 86 virtual void GetChannel(bool get_current_channel, | 92 virtual void GetChannel(bool get_current_channel, |
| 87 const ChannelCallback& callback) = 0; | 93 const ChannelCallback& callback) = 0; |
| 88 virtual void GetEolStatus(const EolStatusCallback& callback) = 0; | 94 virtual void GetEolStatus(const EolStatusCallback& callback) = 0; |
| 95 |
| 96 // Set the update over cellular target in |target_version| and |target_size| |
| 97 // arguments maintained by update engine. The arguments are later used by |
| 98 // update engine to match the given target with the server head and to allow |
| 99 // update over cellular to this given target. |
| 100 virtual void SetUpdateOverCellularTarget(const StatusCallback& callback, |
| 101 const std::string& target_version, |
| 102 int64_t target_size) = 0; |
| 89 #endif | 103 #endif |
| 90 }; | 104 }; |
| 91 | 105 |
| 92 #endif // CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_H_ | 106 #endif // CHROME_BROWSER_UI_WEBUI_HELP_VERSION_UPDATER_H_ |
| OLD | NEW |