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 #include "chrome/browser/ui/webui/help/help_handler.h" | 5 #include "chrome/browser/ui/webui/help/help_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "chrome/browser/chromeos/login/user_manager.h" | 35 #include "chrome/browser/chromeos/login/user_manager.h" |
36 #include "chrome/browser/chromeos/cros_settings.h" | 36 #include "chrome/browser/chromeos/cros_settings.h" |
37 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
38 #include "chrome/browser/prefs/pref_service.h" | 38 #include "chrome/browser/prefs/pref_service.h" |
39 #endif | 39 #endif |
40 | 40 |
41 using base::ListValue; | 41 using base::ListValue; |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 const char kDomainChangable[] = "domain"; | |
46 | |
47 // Returns the browser version as a string. | 45 // Returns the browser version as a string. |
48 string16 BuildBrowserVersionString() { | 46 string16 BuildBrowserVersionString() { |
49 chrome::VersionInfo version_info; | 47 chrome::VersionInfo version_info; |
50 DCHECK(version_info.is_valid()); | 48 DCHECK(version_info.is_valid()); |
51 | 49 |
52 std::string browser_version = version_info.Version(); | 50 std::string browser_version = version_info.Version(); |
53 std::string version_modifier = | 51 std::string version_modifier = |
54 chrome::VersionInfo::GetVersionStringModifier(); | 52 chrome::VersionInfo::GetVersionStringModifier(); |
55 if (!version_modifier.empty()) | 53 if (!version_modifier.empty()) |
56 browser_version += " " + version_modifier; | 54 browser_version += " " + version_modifier; |
(...skipping 10 matching lines...) Expand all Loading... |
67 #if defined(OS_CHROMEOS) | 65 #if defined(OS_CHROMEOS) |
68 | 66 |
69 bool CanChangeReleaseChannel() { | 67 bool CanChangeReleaseChannel() { |
70 // On non managed machines we have local owner who is the only one to change | 68 // On non managed machines we have local owner who is the only one to change |
71 // anything. | 69 // anything. |
72 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) | 70 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) |
73 return true; | 71 return true; |
74 // On a managed machine we delegate this setting to the users of the same | 72 // On a managed machine we delegate this setting to the users of the same |
75 // domain only if the policy value is "domain". | 73 // domain only if the policy value is "domain". |
76 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) { | 74 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) { |
77 std::string value; | 75 bool value = false; |
78 chromeos::CrosSettings::Get()->GetString(chromeos::kReleaseChannel, &value); | 76 if (!chromeos::CrosSettings::Get()->GetBoolean( |
79 if (value != kDomainChangable) | 77 chromeos::kReleaseChannelDelegated, &value) || !value) |
80 return false; | 78 return false; |
81 // Get the currently logged in user and strip the domain part only. | 79 // Get the currently logged in user and strip the domain part only. |
82 std::string domain = ""; | 80 std::string domain = ""; |
83 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); | 81 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); |
84 size_t at_pos = user.find('@'); | 82 size_t at_pos = user.find('@'); |
85 if (at_pos != std::string::npos && at_pos + 1 < user.length()) | 83 if (at_pos != std::string::npos && at_pos + 1 < user.length()) |
86 domain = user.substr(user.find('@') + 1); | 84 domain = user.substr(user.find('@') + 1); |
87 return domain == g_browser_process->browser_policy_connector()-> | 85 return domain == g_browser_process->browser_policy_connector()-> |
88 GetEnterpriseDomain(); | 86 GetEnterpriseDomain(); |
89 } | 87 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 247 |
250 #if defined(OS_CHROMEOS) | 248 #if defined(OS_CHROMEOS) |
251 | 249 |
252 void HelpHandler::SetReleaseTrack(const ListValue* args) { | 250 void HelpHandler::SetReleaseTrack(const ListValue* args) { |
253 if (!CanChangeReleaseChannel()) { | 251 if (!CanChangeReleaseChannel()) { |
254 LOG(WARNING) << "Non-owner tried to change release track."; | 252 LOG(WARNING) << "Non-owner tried to change release track."; |
255 return; | 253 return; |
256 } | 254 } |
257 | 255 |
258 const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); | 256 const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); |
259 Profile* profile = Profile::FromWebUI(web_ui()); | |
260 PrefService* prefs = profile->GetPrefs(); | |
261 prefs->SetString("cros.system.releaseChannel", channel); | |
262 version_updater_->SetReleaseChannel(channel); | 257 version_updater_->SetReleaseChannel(channel); |
| 258 // On enterprise machines we can only use SetReleaseChannel to store the |
| 259 // user choice in the lsb-release file but we can not modify the policy blob. |
| 260 // Therefore we only call SetString if the device is locally owned and the |
| 261 // currently logged in user is the owner. |
| 262 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { |
| 263 chromeos::CrosSettings::Get()->SetString(chromeos::kReleaseChannel, |
| 264 channel); |
| 265 } |
263 } | 266 } |
264 | 267 |
265 #endif // defined(OS_CHROMEOS) | 268 #endif // defined(OS_CHROMEOS) |
266 | 269 |
267 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, | 270 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, |
268 int progress, const string16& message) { | 271 int progress, const string16& message) { |
269 // Only UPDATING state should have progress set. | 272 // Only UPDATING state should have progress set. |
270 DCHECK(status == VersionUpdater::UPDATING || progress == 0); | 273 DCHECK(status == VersionUpdater::UPDATING || progress == 0); |
271 | 274 |
272 std::string status_str; | 275 std::string status_str; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", | 340 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", |
338 *firmware_string); | 341 *firmware_string); |
339 } | 342 } |
340 | 343 |
341 void HelpHandler::OnReleaseChannel(const std::string& channel) { | 344 void HelpHandler::OnReleaseChannel(const std::string& channel) { |
342 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); | 345 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); |
343 web_ui()->CallJavascriptFunction( | 346 web_ui()->CallJavascriptFunction( |
344 "help.HelpPage.updateSelectedChannel", *channel_string); | 347 "help.HelpPage.updateSelectedChannel", *channel_string); |
345 } | 348 } |
346 #endif // defined(OS_CHROMEOS) | 349 #endif // defined(OS_CHROMEOS) |
OLD | NEW |