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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 251 |
254 #if defined(OS_CHROMEOS) | 252 #if defined(OS_CHROMEOS) |
255 | 253 |
256 void HelpHandler::SetReleaseTrack(const ListValue* args) { | 254 void HelpHandler::SetReleaseTrack(const ListValue* args) { |
257 if (!CanChangeReleaseChannel()) { | 255 if (!CanChangeReleaseChannel()) { |
258 LOG(WARNING) << "Non-owner tried to change release track."; | 256 LOG(WARNING) << "Non-owner tried to change release track."; |
259 return; | 257 return; |
260 } | 258 } |
261 | 259 |
262 const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); | 260 const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); |
263 Profile* profile = Profile::FromWebUI(web_ui()); | |
264 PrefService* prefs = profile->GetPrefs(); | |
265 prefs->SetString("cros.system.releaseChannel", channel); | |
266 version_updater_->SetReleaseChannel(channel); | 261 version_updater_->SetReleaseChannel(channel); |
| 262 // On enterprise machines we can only use SetReleaseChannel to store the |
| 263 // user choice in the lsb-release file but we can not modify the policy blob. |
| 264 // Therefore we only call SetString if the device is locally owned and the |
| 265 // currently logged in user is the owner. |
| 266 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { |
| 267 chromeos::CrosSettings::Get()->SetString(chromeos::kReleaseChannel, |
| 268 channel); |
| 269 } |
267 } | 270 } |
268 | 271 |
269 #endif // defined(OS_CHROMEOS) | 272 #endif // defined(OS_CHROMEOS) |
270 | 273 |
271 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, | 274 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, |
272 int progress, const string16& message) { | 275 int progress, const string16& message) { |
273 // Only UPDATING state should have progress set. | 276 // Only UPDATING state should have progress set. |
274 DCHECK(status == VersionUpdater::UPDATING || progress == 0); | 277 DCHECK(status == VersionUpdater::UPDATING || progress == 0); |
275 | 278 |
276 std::string status_str; | 279 std::string status_str; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", | 345 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", |
343 *firmware_string); | 346 *firmware_string); |
344 } | 347 } |
345 | 348 |
346 void HelpHandler::OnReleaseChannel(const std::string& channel) { | 349 void HelpHandler::OnReleaseChannel(const std::string& channel) { |
347 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); | 350 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); |
348 web_ui()->CallJavascriptFunction( | 351 web_ui()->CallJavascriptFunction( |
349 "help.HelpPage.updateSelectedChannel", *channel_string); | 352 "help.HelpPage.updateSelectedChannel", *channel_string); |
350 } | 353 } |
351 #endif // defined(OS_CHROMEOS) | 354 #endif // defined(OS_CHROMEOS) |
OLD | NEW |