Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: chrome/browser/ui/webui/help/version_updater_chromeos.cc

Issue 17437004: Implemented new channel switcher UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed FakeUpdateEngineClient. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h" 5 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chromeos/login/startup_utils.h" 12 #include "chrome/browser/chromeos/login/startup_utils.h"
12 #include "chrome/browser/chromeos/login/user_manager.h" 13 #include "chrome/browser/chromeos/login/user_manager.h"
13 #include "chrome/browser/chromeos/login/wizard_controller.h" 14 #include "chrome/browser/chromeos/login/wizard_controller.h"
14 #include "chrome/browser/chromeos/settings/cros_settings.h" 15 #include "chrome/browser/chromeos/settings/cros_settings.h"
15 #include "chrome/browser/chromeos/settings/cros_settings_names.h" 16 #include "chrome/browser/chromeos/settings/cros_settings_names.h"
17 #include "chrome/browser/policy/browser_policy_connector.h"
16 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" 18 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
17 #include "chromeos/dbus/dbus_thread_manager.h" 19 #include "chromeos/dbus/dbus_thread_manager.h"
18 #include "chromeos/dbus/power_manager_client.h" 20 #include "chromeos/dbus/power_manager_client.h"
19 #include "chromeos/network/network_handler.h" 21 #include "chromeos/network/network_handler.h"
20 #include "chromeos/network/network_state.h" 22 #include "chromeos/network/network_state.h"
21 #include "chromeos/network/network_state_handler.h" 23 #include "chromeos/network/network_state_handler.h"
22 #include "grit/chromium_strings.h" 24 #include "grit/chromium_strings.h"
23 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
24 #include "third_party/cros_system_api/dbus/service_constants.h" 26 #include "third_party/cros_system_api/dbus/service_constants.h"
25 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 update_engine_client->RequestUpdateCheck( 120 update_engine_client->RequestUpdateCheck(
119 base::Bind(&VersionUpdaterCros::OnUpdateCheck, 121 base::Bind(&VersionUpdaterCros::OnUpdateCheck,
120 weak_ptr_factory_.GetWeakPtr())); 122 weak_ptr_factory_.GetWeakPtr()));
121 } 123 }
122 } 124 }
123 125
124 void VersionUpdaterCros::RelaunchBrowser() const { 126 void VersionUpdaterCros::RelaunchBrowser() const {
125 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); 127 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
126 } 128 }
127 129
128 void VersionUpdaterCros::SetReleaseChannel(const std::string& channel) { 130 void VersionUpdaterCros::SetChannel(const std::string& channel,
129 DBusThreadManager::Get()->GetUpdateEngineClient()->SetReleaseTrack(channel); 131 bool is_powerwash_allowed) {
130 // For local owner set the field in the policy blob too. 132 // On enterprise machines we can only use SetChannel to store the
131 if (UserManager::Get()->IsCurrentUserOwner()) 133 // user choice in the lsb-release file but we can not modify the
134 // policy blob. Therefore we only call SetString if the device is
135 // locally owned and the currently logged in user is the owner.
136 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) {
137 DBusThreadManager::Get()->GetUpdateEngineClient()->
138 SetChannel(channel, is_powerwash_allowed);
139 } else if (UserManager::Get()->IsCurrentUserOwner()) {
140 // For local owner set the field in the policy blob.
132 CrosSettings::Get()->SetString(chromeos::kReleaseChannel, channel); 141 CrosSettings::Get()->SetString(chromeos::kReleaseChannel, channel);
142 }
133 } 143 }
134 144
135 void VersionUpdaterCros::GetReleaseChannel(const ChannelCallback& cb) { 145 void VersionUpdaterCros::GetChannel(bool get_current_channel,
136 channel_callback_ = cb; 146 const ChannelCallback& cb) {
137
138 // TODO(jhawkins): Store on this object.
139 UpdateEngineClient* update_engine_client = 147 UpdateEngineClient* update_engine_client =
140 DBusThreadManager::Get()->GetUpdateEngineClient(); 148 DBusThreadManager::Get()->GetUpdateEngineClient();
141 149
142 // Request the channel information. Use the observer to track the help page 150 // Request the channel information.
143 // handler and ensure it does not get deleted before the callback. 151 update_engine_client->GetChannel(get_current_channel, cb);
144 update_engine_client->GetReleaseTrack(
145 base::Bind(&VersionUpdaterCros::UpdateSelectedChannel,
146 weak_ptr_factory_.GetWeakPtr()));
147 } 152 }
148 153
149 VersionUpdaterCros::VersionUpdaterCros() 154 VersionUpdaterCros::VersionUpdaterCros()
150 : last_operation_(UpdateEngineClient::UPDATE_STATUS_IDLE), 155 : last_operation_(UpdateEngineClient::UPDATE_STATUS_IDLE),
151 weak_ptr_factory_(this) { 156 weak_ptr_factory_(this) {
152 } 157 }
153 158
154 VersionUpdaterCros::~VersionUpdaterCros() { 159 VersionUpdaterCros::~VersionUpdaterCros() {
155 UpdateEngineClient* update_engine_client = 160 UpdateEngineClient* update_engine_client =
156 DBusThreadManager::Get()->GetUpdateEngineClient(); 161 DBusThreadManager::Get()->GetUpdateEngineClient();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 last_operation_ = status.status; 213 last_operation_ = status.status;
209 } 214 }
210 215
211 void VersionUpdaterCros::OnUpdateCheck( 216 void VersionUpdaterCros::OnUpdateCheck(
212 UpdateEngineClient::UpdateCheckResult result) { 217 UpdateEngineClient::UpdateCheckResult result) {
213 // If version updating is not implemented, this binary is the most up-to-date 218 // If version updating is not implemented, this binary is the most up-to-date
214 // possible with respect to automatic updating. 219 // possible with respect to automatic updating.
215 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) 220 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED)
216 callback_.Run(UPDATED, 0, string16()); 221 callback_.Run(UPDATED, 0, string16());
217 } 222 }
218
219 void VersionUpdaterCros::UpdateSelectedChannel(const std::string& channel) {
220 channel_callback_.Run(channel);
221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698