Index: chrome/browser/ui/webui/help/help_handler.cc |
diff --git a/chrome/browser/ui/webui/help/help_handler.cc b/chrome/browser/ui/webui/help/help_handler.cc |
index 97a636af9a22845ca5068b39bf0421082ba7ea21..028ce377da6e71267e729054eb10749a41f21cad 100644 |
--- a/chrome/browser/ui/webui/help/help_handler.cc |
+++ b/chrome/browser/ui/webui/help/help_handler.cc |
@@ -48,7 +48,10 @@ |
#include "base/i18n/time_formatting.h" |
#include "base/prefs/pref_service.h" |
#include "base/sys_info.h" |
+#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
+#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h" |
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
+#include "chrome/browser/chromeos/profiles/profile_helper.h" |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/webui/chromeos/image_source.h" |
@@ -88,7 +91,7 @@ bool IsEnterpriseManaged() { |
} |
// Returns true if current user can change channel, false otherwise. |
-bool CanChangeChannel() { |
+bool CanChangeChannel(Profile* profile) { |
bool value = false; |
chromeos::CrosSettings::Get()->GetBoolean(chromeos::kReleaseChannelDelegated, |
&value); |
@@ -100,18 +103,24 @@ bool CanChangeChannel() { |
return false; |
// Get the currently logged in user and strip the domain part only. |
std::string domain = ""; |
- std::string user = |
- user_manager::UserManager::Get()->GetLoggedInUser()->email(); |
- size_t at_pos = user.find('@'); |
- if (at_pos != std::string::npos && at_pos + 1 < user.length()) |
- domain = user.substr(user.find('@') + 1); |
+ const user_manager::User* user = |
+ profile ? chromeos::ProfileHelper::Get()->GetUserByProfile(profile) |
+ : nullptr; |
+ std::string email = user ? user->email() : std::string(); |
+ size_t at_pos = email.find('@'); |
+ if (at_pos != std::string::npos && at_pos + 1 < email.length()) |
+ domain = email.substr(email.find('@') + 1); |
policy::BrowserPolicyConnectorChromeOS* connector = |
g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
return domain == connector->GetEnterpriseDomain(); |
- } else if (user_manager::UserManager::Get()->IsCurrentUserOwner()) { |
+ } else { |
+ chromeos::OwnerSettingsServiceChromeOS* service = |
+ chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance() |
+ ->GetForProfile(profile); |
// On non managed machines we have local owner who is the only one to change |
// anything. Ensure that ReleaseChannelDelegated is false. |
- return !value; |
+ if (service && service->IsOwner()) |
+ return !value; |
} |
return false; |
} |
@@ -121,8 +130,7 @@ bool CanChangeChannel() { |
} // namespace |
HelpHandler::HelpHandler() |
- : version_updater_(VersionUpdater::Create()), |
- weak_factory_(this) { |
+ : version_updater_(VersionUpdater::Create(nullptr)), weak_factory_(this) { |
} |
HelpHandler::~HelpHandler() { |
@@ -276,6 +284,9 @@ void HelpHandler::GetLocalizedValues(base::DictionaryValue* localized_strings) { |
} |
void HelpHandler::RegisterMessages() { |
+#if defined(OS_CHROMEOS) |
+ version_updater_.reset(VersionUpdater::Create(Profile::FromWebUI(web_ui()))); |
Nikita (slow)
2014/11/19 17:45:59
VersionUpdater::Create(web_ui()->GetWebContents()-
ygorshenin1
2014/11/19 18:30:44
Done.
|
+#endif |
registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
content::NotificationService::AllSources()); |
@@ -351,7 +362,7 @@ void HelpHandler::OnPageLoaded(const base::ListValue* args) { |
web_ui()->CallJavascriptFunction( |
"help.HelpPage.updateEnableReleaseChannel", |
- base::FundamentalValue(CanChangeChannel())); |
+ base::FundamentalValue(CanChangeChannel(Profile::FromWebUI(web_ui())))); |
base::Time build_time = base::SysInfo::GetLsbReleaseTime(); |
base::string16 build_date = base::TimeFormatFriendlyDate(build_time); |
@@ -426,7 +437,7 @@ void HelpHandler::OpenHelpPage(const base::ListValue* args) { |
void HelpHandler::SetChannel(const base::ListValue* args) { |
DCHECK(args->GetSize() == 2); |
- if (!CanChangeChannel()) { |
+ if (!CanChangeChannel(Profile::FromWebUI(web_ui()))) { |
LOG(WARNING) << "Non-owner tried to change release track."; |
return; |
} |