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 19 matching lines...) Expand all Loading... | |
30 #include "chrome/browser/chromeos/login/user_manager.h" | 30 #include "chrome/browser/chromeos/login/user_manager.h" |
31 #include "chrome/browser/chromeos/cros_settings.h" | 31 #include "chrome/browser/chromeos/cros_settings.h" |
32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
33 #include "chrome/browser/prefs/pref_service.h" | 33 #include "chrome/browser/prefs/pref_service.h" |
34 #endif | 34 #endif |
35 | 35 |
36 using base::ListValue; | 36 using base::ListValue; |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 const char kDomainChangable[] = "domain"; | |
41 | |
42 // Returns the browser version as a string. | 40 // Returns the browser version as a string. |
43 string16 BuildBrowserVersionString() { | 41 string16 BuildBrowserVersionString() { |
44 chrome::VersionInfo version_info; | 42 chrome::VersionInfo version_info; |
45 DCHECK(version_info.is_valid()); | 43 DCHECK(version_info.is_valid()); |
46 | 44 |
47 std::string browser_version = version_info.Version(); | 45 std::string browser_version = version_info.Version(); |
48 std::string version_modifier = | 46 std::string version_modifier = |
49 chrome::VersionInfo::GetVersionStringModifier(); | 47 chrome::VersionInfo::GetVersionStringModifier(); |
50 if (!version_modifier.empty()) | 48 if (!version_modifier.empty()) |
51 browser_version += " " + version_modifier; | 49 browser_version += " " + version_modifier; |
(...skipping 10 matching lines...) Expand all Loading... | |
62 #if defined(OS_CHROMEOS) | 60 #if defined(OS_CHROMEOS) |
63 | 61 |
64 bool CanChangeReleaseChannel() { | 62 bool CanChangeReleaseChannel() { |
65 // On non managed machines we have local owner who is the only one to change | 63 // On non managed machines we have local owner who is the only one to change |
66 // anything. | 64 // anything. |
67 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) | 65 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) |
68 return true; | 66 return true; |
69 // On a managed machine we delegate this setting to the users of the same | 67 // On a managed machine we delegate this setting to the users of the same |
70 // domain only if the policy value is "domain". | 68 // domain only if the policy value is "domain". |
71 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) { | 69 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) { |
72 std::string value; | 70 bool value = false; |
73 chromeos::CrosSettings::Get()->GetString(chromeos::kReleaseChannel, &value); | 71 if (!chromeos::CrosSettings::Get()->GetBoolean( |
74 if (value != kDomainChangable) | 72 chromeos::kReleaseChannelDelegated, &value) || !value) |
75 return false; | 73 return false; |
76 // Get the currently logged in user and strip the domain part only. | 74 // Get the currently logged in user and strip the domain part only. |
77 std::string domain = ""; | 75 std::string domain = ""; |
78 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); | 76 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); |
79 size_t at_pos = user.find('@'); | 77 size_t at_pos = user.find('@'); |
80 if (at_pos != std::string::npos && at_pos + 1 < user.length()) | 78 if (at_pos != std::string::npos && at_pos + 1 < user.length()) |
81 domain = user.substr(user.find('@') + 1); | 79 domain = user.substr(user.find('@') + 1); |
82 return domain == g_browser_process->browser_policy_connector()-> | 80 return domain == g_browser_process->browser_policy_connector()-> |
83 GetEnterpriseDomain(); | 81 GetEnterpriseDomain(); |
84 } | 82 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 | 221 |
224 #if defined(OS_CHROMEOS) | 222 #if defined(OS_CHROMEOS) |
225 | 223 |
226 void HelpHandler::SetReleaseTrack(const ListValue* args) { | 224 void HelpHandler::SetReleaseTrack(const ListValue* args) { |
227 if (!CanChangeReleaseChannel()) { | 225 if (!CanChangeReleaseChannel()) { |
228 LOG(WARNING) << "Non-owner tried to change release track."; | 226 LOG(WARNING) << "Non-owner tried to change release track."; |
229 return; | 227 return; |
230 } | 228 } |
231 | 229 |
232 const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); | 230 const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); |
233 Profile* profile = Profile::FromWebUI(web_ui()); | |
234 PrefService* prefs = profile->GetPrefs(); | |
235 prefs->SetString("cros.system.releaseChannel", channel); | |
236 version_updater_->SetReleaseChannel(channel); | 231 version_updater_->SetReleaseChannel(channel); |
232 // For local owner set the field in the policy blob too. | |
Joao da Silva
2012/03/09 15:15:55
Please drop a comment explaining why IsCurrentUser
pastarmovj
2012/03/12 13:06:53
Done.
| |
233 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { | |
234 chromeos::CrosSettings::Get()->SetString(chromeos::kReleaseChannel, | |
235 channel); | |
236 } | |
237 } | 237 } |
238 | 238 |
239 #endif // defined(OS_CHROMEOS) | 239 #endif // defined(OS_CHROMEOS) |
240 | 240 |
241 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, | 241 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, |
242 int progress, const string16& message) { | 242 int progress, const string16& message) { |
243 // Only UPDATING state should have progress set. | 243 // Only UPDATING state should have progress set. |
244 DCHECK(status == VersionUpdater::UPDATING || progress == 0); | 244 DCHECK(status == VersionUpdater::UPDATING || progress == 0); |
245 | 245 |
246 std::string status_str; | 246 std::string status_str; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", | 311 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", |
312 *firmware_string); | 312 *firmware_string); |
313 } | 313 } |
314 | 314 |
315 void HelpHandler::OnReleaseChannel(const std::string& channel) { | 315 void HelpHandler::OnReleaseChannel(const std::string& channel) { |
316 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); | 316 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); |
317 web_ui()->CallJavascriptFunction( | 317 web_ui()->CallJavascriptFunction( |
318 "help.HelpPage.updateSelectedChannel", *channel_string); | 318 "help.HelpPage.updateSelectedChannel", *channel_string); |
319 } | 319 } |
320 #endif // defined(OS_CHROMEOS) | 320 #endif // defined(OS_CHROMEOS) |
OLD | NEW |