| 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 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 #if defined(OS_MACOSX) | 39 #if defined(OS_MACOSX) |
| 40 #include "chrome/browser/mac/obsolete_system.h" | 40 #include "chrome/browser/mac/obsolete_system.h" |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
| 44 #include "base/files/file_util_proxy.h" | 44 #include "base/files/file_util_proxy.h" |
| 45 #include "base/i18n/time_formatting.h" | 45 #include "base/i18n/time_formatting.h" |
| 46 #include "base/prefs/pref_service.h" | 46 #include "base/prefs/pref_service.h" |
| 47 #include "base/sys_info.h" | 47 #include "base/sys_info.h" |
| 48 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
| 49 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 48 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 50 #include "chrome/browser/chromeos/settings/cros_settings.h" | 49 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 51 #include "chrome/browser/profiles/profile.h" | 50 #include "chrome/browser/profiles/profile.h" |
| 52 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | 51 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" |
| 53 #include "chromeos/chromeos_switches.h" | 52 #include "chromeos/chromeos_switches.h" |
| 54 #include "chromeos/dbus/dbus_thread_manager.h" | 53 #include "chromeos/dbus/dbus_thread_manager.h" |
| 55 #include "chromeos/dbus/power_manager_client.h" | 54 #include "chromeos/dbus/power_manager_client.h" |
| 55 #include "components/user_manager/user_manager.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 using base::ListValue; | 58 using base::ListValue; |
| 59 using content::BrowserThread; | 59 using content::BrowserThread; |
| 60 | 60 |
| 61 namespace { | 61 namespace { |
| 62 | 62 |
| 63 // Returns the browser version as a string. | 63 // Returns the browser version as a string. |
| 64 base::string16 BuildBrowserVersionString() { | 64 base::string16 BuildBrowserVersionString() { |
| 65 chrome::VersionInfo version_info; | 65 chrome::VersionInfo version_info; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kReleaseChannelDelegated, | 110 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kReleaseChannelDelegated, |
| 111 &value); | 111 &value); |
| 112 | 112 |
| 113 // On a managed machine we delegate this setting to the users of the same | 113 // On a managed machine we delegate this setting to the users of the same |
| 114 // domain only if the policy value is "domain". | 114 // domain only if the policy value is "domain". |
| 115 if (IsEnterpriseManaged()) { | 115 if (IsEnterpriseManaged()) { |
| 116 if (!value) | 116 if (!value) |
| 117 return false; | 117 return false; |
| 118 // Get the currently logged in user and strip the domain part only. | 118 // Get the currently logged in user and strip the domain part only. |
| 119 std::string domain = ""; | 119 std::string domain = ""; |
| 120 std::string user = chromeos::UserManager::Get()->GetLoggedInUser()->email(); | 120 std::string user = |
| 121 user_manager::UserManager::Get()->GetLoggedInUser()->email(); |
| 121 size_t at_pos = user.find('@'); | 122 size_t at_pos = user.find('@'); |
| 122 if (at_pos != std::string::npos && at_pos + 1 < user.length()) | 123 if (at_pos != std::string::npos && at_pos + 1 < user.length()) |
| 123 domain = user.substr(user.find('@') + 1); | 124 domain = user.substr(user.find('@') + 1); |
| 124 policy::BrowserPolicyConnectorChromeOS* connector = | 125 policy::BrowserPolicyConnectorChromeOS* connector = |
| 125 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 126 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 126 return domain == connector->GetEnterpriseDomain(); | 127 return domain == connector->GetEnterpriseDomain(); |
| 127 } else if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { | 128 } else if (user_manager::UserManager::Get()->IsCurrentUserOwner()) { |
| 128 // On non managed machines we have local owner who is the only one to change | 129 // On non managed machines we have local owner who is the only one to change |
| 129 // anything. Ensure that ReleaseChannelDelegated is false. | 130 // anything. Ensure that ReleaseChannelDelegated is false. |
| 130 return !value; | 131 return !value; |
| 131 } | 132 } |
| 132 return false; | 133 return false; |
| 133 } | 134 } |
| 134 | 135 |
| 135 #endif // defined(OS_CHROMEOS) | 136 #endif // defined(OS_CHROMEOS) |
| 136 | 137 |
| 137 } // namespace | 138 } // namespace |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 base::string16 channel; | 423 base::string16 channel; |
| 423 bool is_powerwash_allowed; | 424 bool is_powerwash_allowed; |
| 424 if (!args->GetString(0, &channel) || | 425 if (!args->GetString(0, &channel) || |
| 425 !args->GetBoolean(1, &is_powerwash_allowed)) { | 426 !args->GetBoolean(1, &is_powerwash_allowed)) { |
| 426 LOG(ERROR) << "Can't parse SetChannel() args"; | 427 LOG(ERROR) << "Can't parse SetChannel() args"; |
| 427 return; | 428 return; |
| 428 } | 429 } |
| 429 | 430 |
| 430 version_updater_->SetChannel(base::UTF16ToUTF8(channel), | 431 version_updater_->SetChannel(base::UTF16ToUTF8(channel), |
| 431 is_powerwash_allowed); | 432 is_powerwash_allowed); |
| 432 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { | 433 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) { |
| 433 // Check for update after switching release channel. | 434 // Check for update after switching release channel. |
| 434 version_updater_->CheckForUpdate(base::Bind(&HelpHandler::SetUpdateStatus, | 435 version_updater_->CheckForUpdate(base::Bind(&HelpHandler::SetUpdateStatus, |
| 435 base::Unretained(this))); | 436 base::Unretained(this))); |
| 436 } | 437 } |
| 437 } | 438 } |
| 438 | 439 |
| 439 void HelpHandler::RelaunchAndPowerwash(const base::ListValue* args) { | 440 void HelpHandler::RelaunchAndPowerwash(const base::ListValue* args) { |
| 440 DCHECK(args->empty()); | 441 DCHECK(args->empty()); |
| 441 | 442 |
| 442 if (IsEnterpriseManaged()) | 443 if (IsEnterpriseManaged()) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 web_ui()->CallJavascriptFunction( | 548 web_ui()->CallJavascriptFunction( |
| 548 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); | 549 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); |
| 549 } | 550 } |
| 550 | 551 |
| 551 void HelpHandler::OnTargetChannel(const std::string& channel) { | 552 void HelpHandler::OnTargetChannel(const std::string& channel) { |
| 552 web_ui()->CallJavascriptFunction( | 553 web_ui()->CallJavascriptFunction( |
| 553 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); | 554 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); |
| 554 } | 555 } |
| 555 | 556 |
| 556 #endif // defined(OS_CHROMEOS) | 557 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |