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/options/chromeos/about_page_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/about_page_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Returns a substring [start, end) from |text|. | 59 // Returns a substring [start, end) from |text|. |
60 std::string StringSubRange(const std::string& text, size_t start, | 60 std::string StringSubRange(const std::string& text, size_t start, |
61 size_t end) { | 61 size_t end) { |
62 DCHECK(end > start); | 62 DCHECK(end > start); |
63 return text.substr(start, end - start); | 63 return text.substr(start, end - start); |
64 } | 64 } |
65 | 65 |
66 bool CanChangeReleaseChannel() { | 66 bool CanChangeReleaseChannel() { |
67 // On non managed machines we have local owner who is the only one to change | 67 // On non managed machines we have local owner who is the only one to change |
68 // anything. | 68 // anything. |
69 if (chromeos::UserManager::Get()->current_user_is_owner()) | 69 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) |
70 return true; | 70 return true; |
71 // On a managed machine we delegate this setting to the users of the same | 71 // On a managed machine we delegate this setting to the users of the same |
72 // domain only if the policy value is "domain". | 72 // domain only if the policy value is "domain". |
73 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) { | 73 if (g_browser_process->browser_policy_connector()->IsEnterpriseManaged()) { |
74 std::string value; | 74 std::string value; |
75 chromeos::CrosSettings::Get()->GetString(chromeos::kReleaseChannel, &value); | 75 chromeos::CrosSettings::Get()->GetString(chromeos::kReleaseChannel, &value); |
76 if (value != kDomainChangable) | 76 if (value != kDomainChangable) |
77 return false; | 77 return false; |
78 // Get the currently logged in user and strip the domain part only. | 78 // Get the currently logged in user and strip the domain part only. |
79 std::string domain = ""; | 79 std::string domain = ""; |
80 std::string user = chromeos::UserManager::Get()->logged_in_user().email(); | 80 std::string user = chromeos::UserManager::Get()->GetLoggedInUser().email(); |
81 size_t at_pos = user.find('@'); | 81 size_t at_pos = user.find('@'); |
82 if (at_pos != std::string::npos && at_pos + 1 < user.length()) | 82 if (at_pos != std::string::npos && at_pos + 1 < user.length()) |
83 domain = user.substr(user.find('@') + 1); | 83 domain = user.substr(user.find('@') + 1); |
84 return domain == g_browser_process->browser_policy_connector()-> | 84 return domain == g_browser_process->browser_policy_connector()-> |
85 GetEnterpriseDomain(); | 85 GetEnterpriseDomain(); |
86 } | 86 } |
87 return false; | 87 return false; |
88 } | 88 } |
89 | 89 |
90 } // namespace | 90 } // namespace |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 } | 313 } |
314 | 314 |
315 void AboutPageHandler::SetReleaseTrack(const ListValue* args) { | 315 void AboutPageHandler::SetReleaseTrack(const ListValue* args) { |
316 if (!CanChangeReleaseChannel()) { | 316 if (!CanChangeReleaseChannel()) { |
317 LOG(WARNING) << "Non-owner tried to change release track."; | 317 LOG(WARNING) << "Non-owner tried to change release track."; |
318 return; | 318 return; |
319 } | 319 } |
320 const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); | 320 const std::string channel = UTF16ToUTF8(ExtractStringValue(args)); |
321 DBusThreadManager::Get()->GetUpdateEngineClient()->SetReleaseTrack(channel); | 321 DBusThreadManager::Get()->GetUpdateEngineClient()->SetReleaseTrack(channel); |
322 // For local owner set the field in the policy blob too. | 322 // For local owner set the field in the policy blob too. |
323 if (UserManager::Get()->current_user_is_owner()) | 323 if (UserManager::Get()->IsCurrentUserOwner()) |
324 CrosSettings::Get()->SetString(kReleaseChannel, channel); | 324 CrosSettings::Get()->SetString(kReleaseChannel, channel); |
325 } | 325 } |
326 | 326 |
327 void AboutPageHandler::CheckNow(const ListValue* args) { | 327 void AboutPageHandler::CheckNow(const ListValue* args) { |
328 // Make sure that libcros is loaded and OOBE is complete. | 328 // Make sure that libcros is loaded and OOBE is complete. |
329 if (!WizardController::default_controller() || | 329 if (!WizardController::default_controller() || |
330 WizardController::IsDeviceRegistered()) { | 330 WizardController::IsDeviceRegistered()) { |
331 DBusThreadManager::Get()->GetUpdateEngineClient()-> | 331 DBusThreadManager::Get()->GetUpdateEngineClient()-> |
332 RequestUpdateCheck(UpdateEngineClient::EmptyUpdateCheckCallback()); | 332 RequestUpdateCheck(UpdateEngineClient::EmptyUpdateCheckCallback()); |
333 } | 333 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 // If UpdateEngineClient still has the observer, then the page handler | 448 // If UpdateEngineClient still has the observer, then the page handler |
449 // is valid. | 449 // is valid. |
450 AboutPageHandler* handler = observer->page_handler(); | 450 AboutPageHandler* handler = observer->page_handler(); |
451 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); | 451 scoped_ptr<Value> channel_string(Value::CreateStringValue(channel)); |
452 handler->web_ui()->CallJavascriptFunction( | 452 handler->web_ui()->CallJavascriptFunction( |
453 "AboutPage.updateSelectedOptionCallback", *channel_string); | 453 "AboutPage.updateSelectedOptionCallback", *channel_string); |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 } // namespace chromeos | 457 } // namespace chromeos |
OLD | NEW |