diff options
author | ygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-26 10:10:00 +0000 |
---|---|---|
committer | ygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-26 10:10:00 +0000 |
commit | f1ed3ad967b977a0c4c7e97da25a82cf620ec08f (patch) | |
tree | 847e4a8e6cfe4ab79ce038d406b68ea347ad59b5 /chromeos | |
parent | 59ba319354051d6baa1b42fe4b164da7b3481b4e (diff) | |
download | chromium_src-f1ed3ad967b977a0c4c7e97da25a82cf620ec08f.zip chromium_src-f1ed3ad967b977a0c4c7e97da25a82cf620ec08f.tar.gz chromium_src-f1ed3ad967b977a0c4c7e97da25a82cf620ec08f.tar.bz2 |
Implemented new channel switcher UI.
Must be landed after:
https://gerrit.chromium.org/gerrit/#/c/59422/
https://gerrit.chromium.org/gerrit/#/c/59427/
BUG=219292
TEST=tested on Linux ChromiumOS and Lumpy
Review URL: https://chromiumcodereview.appspot.com/17437004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/chromeos_switches.cc | 3 | ||||
-rw-r--r-- | chromeos/chromeos_switches.h | 3 | ||||
-rw-r--r-- | chromeos/dbus/fake_update_engine_client.cc | 8 | ||||
-rw-r--r-- | chromeos/dbus/fake_update_engine_client.h | 4 | ||||
-rw-r--r-- | chromeos/dbus/update_engine_client.cc | 104 | ||||
-rw-r--r-- | chromeos/dbus/update_engine_client.h | 33 |
6 files changed, 143 insertions, 12 deletions
diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index e1ce231..e3b9d07 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc @@ -44,6 +44,9 @@ const char kDisableLocalAccounts[] = "disable-local-accounts"; // Avoid doing expensive animations upon login. const char kDisableLoginAnimations[] = "disable-login-animations"; +// Disable new channel switcher UI. +const char kDisableNewChannelSwitcherUI[] = "disable-new-channel-switcher-ui"; + // Disable Quickoffice component app thus handlers won't be registered so // it will be possible to install another version as normal app for testing. const char kDisableQuickofficeComponentApp[] = diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index 21e2607..f5eddc1 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h @@ -31,10 +31,11 @@ CHROMEOS_EXPORT extern const char kDisableChromeCaptivePortalDetector[]; CHROMEOS_EXPORT extern const char kDisableDrive[]; CHROMEOS_EXPORT extern const char kDisableLocalAccounts[]; CHROMEOS_EXPORT extern const char kDisableLoginAnimations[]; +CHROMEOS_EXPORT extern const char kDisableNewChannelSwitcherUI[]; CHROMEOS_EXPORT extern const char kDisableNewNetworkChangeNotifier[]; +CHROMEOS_EXPORT extern const char kDisableOOBEBlockingUpdate[]; CHROMEOS_EXPORT extern const char kDisableOnlineEULA[]; CHROMEOS_EXPORT extern const char kDisableOobeAnimation[]; -CHROMEOS_EXPORT extern const char kDisableOOBEBlockingUpdate[]; CHROMEOS_EXPORT extern const char kDisableQuickofficeComponentApp[]; CHROMEOS_EXPORT extern const char kDisableStubEthernet[]; CHROMEOS_EXPORT extern const char kEchoExtensionPath[]; diff --git a/chromeos/dbus/fake_update_engine_client.cc b/chromeos/dbus/fake_update_engine_client.cc index be248d0..ff82fdc 100644 --- a/chromeos/dbus/fake_update_engine_client.cc +++ b/chromeos/dbus/fake_update_engine_client.cc @@ -49,6 +49,14 @@ UpdateEngineClient::Status FakeUpdateEngineClient::GetLastStatus() { return last_status; } +void FakeUpdateEngineClient::SetChannel(const std::string& target_channel, + bool is_powerwash_allowed) { +} + +void FakeUpdateEngineClient::GetChannel(bool get_current_channel, + const GetChannelCallback& callback) { +} + void FakeUpdateEngineClient::set_default_status( const UpdateEngineClient::Status& status) { default_status_ = status; diff --git a/chromeos/dbus/fake_update_engine_client.h b/chromeos/dbus/fake_update_engine_client.h index 46bbd5e..1de5100 100644 --- a/chromeos/dbus/fake_update_engine_client.h +++ b/chromeos/dbus/fake_update_engine_client.h @@ -31,6 +31,10 @@ class FakeUpdateEngineClient : public UpdateEngineClient { virtual void GetReleaseTrack(const GetReleaseTrackCallback& callback) OVERRIDE; virtual Status GetLastStatus() OVERRIDE; + virtual void SetChannel(const std::string& target_channel, + bool is_powerwash_allowed) OVERRIDE; + virtual void GetChannel(bool get_current_channel, + const GetChannelCallback& callback) OVERRIDE; // Pushes UpdateEngineClient::Status in the queue to test changing status. // GetLastStatus() returns the status set by this method in FIFO order. diff --git a/chromeos/dbus/update_engine_client.cc b/chromeos/dbus/update_engine_client.cc index d13ddca..cd6cd00 100644 --- a/chromeos/dbus/update_engine_client.cc +++ b/chromeos/dbus/update_engine_client.cc @@ -14,8 +14,13 @@ #include "third_party/cros_system_api/dbus/service_constants.h" namespace chromeos { + namespace { +const char kReleaseChannelDev[] = "dev-channel"; +const char kReleaseChannelBeta[] = "beta-channel"; +const char kReleaseChannelStable[] = "stable-channel"; + // Returns UPDATE_STATUS_ERROR on error. UpdateEngineClient::UpdateStatusOperation UpdateStatusFromString( const std::string& str) { @@ -43,6 +48,12 @@ void EmptyUpdateCheckCallbackBody( UpdateEngineClient::UpdateCheckResult unused_result) { } +bool IsValidChannel(const std::string& channel) { + return channel == kReleaseChannelDev || + channel == kReleaseChannelBeta || + channel == kReleaseChannelStable; +} + } // namespace // The UpdateEngineClient implementation used in production. @@ -77,22 +88,19 @@ class UpdateEngineClientImpl : public UpdateEngineClient { virtual ~UpdateEngineClientImpl() { } - // UpdateEngineClient override. + // UpdateEngineClient implementation: virtual void AddObserver(Observer* observer) OVERRIDE { observers_.AddObserver(observer); } - // UpdateEngineClient override. virtual void RemoveObserver(Observer* observer) OVERRIDE { observers_.RemoveObserver(observer); } - // UpdateEngineClient override. virtual bool HasObserver(Observer* observer) OVERRIDE { return observers_.HasObserver(observer); } - // UpdateEngineClient override. virtual void RequestUpdateCheck( const UpdateCheckCallback& callback) OVERRIDE { dbus::MethodCall method_call( @@ -111,7 +119,6 @@ class UpdateEngineClientImpl : public UpdateEngineClient { callback)); } - // UpdateEngineClient override. virtual void RebootAfterUpdate() OVERRIDE { dbus::MethodCall method_call( update_engine::kUpdateEngineInterface, @@ -125,7 +132,6 @@ class UpdateEngineClientImpl : public UpdateEngineClient { weak_ptr_factory_.GetWeakPtr())); } - // UpdateEngineClient override. virtual void SetReleaseTrack(const std::string& track) OVERRIDE { dbus::MethodCall method_call( update_engine::kUpdateEngineInterface, @@ -141,7 +147,6 @@ class UpdateEngineClientImpl : public UpdateEngineClient { weak_ptr_factory_.GetWeakPtr())); } - // UpdateEngineClient override. virtual void GetReleaseTrack( const GetReleaseTrackCallback& callback) OVERRIDE { dbus::MethodCall method_call( @@ -157,11 +162,52 @@ class UpdateEngineClientImpl : public UpdateEngineClient { callback)); } - // UpdateEngineClient override. virtual Status GetLastStatus() OVERRIDE { return last_status_; } + virtual void SetChannel(const std::string& target_channel, + bool is_powerwash_allowed) OVERRIDE { + if (!IsValidChannel(target_channel)) { + LOG(ERROR) << "Invalid channel name: " << target_channel; + return; + } + + dbus::MethodCall method_call( + update_engine::kUpdateEngineInterface, + update_engine::kSetChannel); + dbus::MessageWriter writer(&method_call); + writer.AppendString(target_channel); + writer.AppendBool(is_powerwash_allowed); + + VLOG(1) << "Requesting to set channel: " + << "target_channel=" << target_channel << ", " + << "is_powerwash_allowed=" << is_powerwash_allowed; + update_engine_proxy_->CallMethod( + &method_call, + dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + base::Bind(&UpdateEngineClientImpl::OnSetChannel, + weak_ptr_factory_.GetWeakPtr())); + } + + virtual void GetChannel(bool get_current_channel, + const GetChannelCallback& callback) OVERRIDE { + dbus::MethodCall method_call( + update_engine::kUpdateEngineInterface, + update_engine::kGetChannel); + dbus::MessageWriter writer(&method_call); + writer.AppendBool(get_current_channel); + + VLOG(1) << "Requesting to get channel, get_current_channel=" + << get_current_channel; + update_engine_proxy_->CallMethod( + &method_call, + dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, + base::Bind(&UpdateEngineClientImpl::OnGetChannel, + weak_ptr_factory_.GetWeakPtr(), + callback)); + } + private: void GetUpdateEngineStatus() { dbus::MethodCall method_call( @@ -251,6 +297,34 @@ class UpdateEngineClientImpl : public UpdateEngineClient { LOG(ERROR) << "GetStatus request failed with error: " << error->ToString(); } + // Called when a response for SetReleaseTrack() is received. + void OnSetChannel(dbus::Response* response) { + if (!response) { + LOG(ERROR) << "Failed to request setting channel"; + return; + } + VLOG(1) << "Succeeded to set channel"; + } + + // Called when a response for GetChannel() is received. + void OnGetChannel(const GetReleaseTrackCallback& callback, + dbus::Response* response) { + if (!response) { + LOG(ERROR) << "Failed to request getting channel"; + callback.Run(""); + return; + } + dbus::MessageReader reader(response); + std::string channel; + if (!reader.PopString(&channel)) { + LOG(ERROR) << "Incorrect response: " << response->ToString(); + callback.Run(""); + return; + } + VLOG(1) << "The channel received: " << channel; + callback.Run(channel); + } + // Called when a status update signal is received. void StatusUpdateReceived(dbus::Signal* signal) { VLOG(1) << "Status update signal received: " << signal->ToString(); @@ -302,7 +376,7 @@ class UpdateEngineClientImpl : public UpdateEngineClient { // The UpdateEngineClient implementation used on Linux desktop, // which does nothing. class UpdateEngineClientStubImpl : public UpdateEngineClient { - // UpdateEngineClient overrides. + // UpdateEngineClient implementation: virtual void AddObserver(Observer* observer) OVERRIDE {} virtual void RemoveObserver(Observer* observer) OVERRIDE {} virtual bool HasObserver(Observer* observer) OVERRIDE { return false; } @@ -318,6 +392,18 @@ class UpdateEngineClientStubImpl : public UpdateEngineClient { callback.Run("beta-channel"); } virtual Status GetLastStatus() OVERRIDE { return Status(); } + virtual void SetChannel(const std::string& target_channel, + bool is_powerwash_allowed) OVERRIDE { + LOG(INFO) << "Requesting to set channel: " + << "target_channel=" << target_channel << ", " + << "is_powerwash_allowed=" << is_powerwash_allowed; + } + virtual void GetChannel(bool get_current_channel, + const GetChannelCallback& callback) OVERRIDE { + LOG(INFO) << "Requesting to get channel, get_current_channel=" + << get_current_channel; + callback.Run("beta-channel"); + } }; UpdateEngineClient::UpdateEngineClient() { diff --git a/chromeos/dbus/update_engine_client.h b/chromeos/dbus/update_engine_client.h index 914094e..26e4bfa 100644 --- a/chromeos/dbus/update_engine_client.h +++ b/chromeos/dbus/update_engine_client.h @@ -14,7 +14,7 @@ namespace dbus { class Bus; -} // namespace +} namespace chromeos { @@ -87,14 +87,22 @@ class CHROMEOS_EXPORT UpdateEngineClient { // Reboots if update has been performed. virtual void RebootAfterUpdate() = 0; + // DEPRECATED: Use SetChannel instead. // Requests to set the release track (channel). |track| should look like // "beta-channel" or "dev-channel". virtual void SetReleaseTrack(const std::string& track) = 0; // Called once GetReleaseTrack() is complete. Takes one parameter; // - string: the release track name like "beta-channel". - typedef base::Callback<void(const std::string&)> GetReleaseTrackCallback; + typedef base::Callback<void(const std::string& channel_name)> + GetReleaseTrackCallback; + // Called once GetChannel() is complete. Takes one parameter; + // - string: the channel name like "beta-channel". + typedef base::Callback<void(const std::string& channel_name)> + GetChannelCallback; + + // DEPRECATED: Use GetChannel() instead. // Requests to get the release track and calls |callback| with the // release track (channel). On error, calls |callback| with an empty // string. @@ -106,6 +114,27 @@ class CHROMEOS_EXPORT UpdateEngineClient { // that need this information. virtual Status GetLastStatus() = 0; + // Changes the current channel of the device to the target + // channel. If the target channel is a less stable channel than the + // current channel, then the channel change happens immediately (at + // the next update check). If the target channel is a more stable + // channel, then if |is_powerwash_allowed| is set to true, then also + // the change happens immediately but with a powerwash if + // required. Otherwise, the change takes effect eventually (when the + // version on the target channel goes above the version number of + // what the device currently has). |target_channel| should look like + // "dev-channel", "beta-channel" or "stable-channel". + virtual void SetChannel(const std::string& target_channel, + bool is_powerwash_allowed) = 0; + + // If |get_current_channel| is set to true, calls |callback| with + // the name of the channel that the device is currently + // on. Otherwise, it calls it with the name of the channel the + // device is supposed to be (in case of a pending channel + // change). On error, calls |callback| with an empty string. + virtual void GetChannel(bool get_current_channel, + const GetChannelCallback& callback) = 0; + // Returns an empty UpdateCheckCallback that does nothing. static UpdateCheckCallback EmptyUpdateCheckCallback(); |