Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2362)

Unified Diff: chrome/browser/ui/webui/help/help_handler.cc

Issue 738843002: Call to CrosSettings::Set() is replaced by OwnerSettingsService::Set() in VersionUpdaterCros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/flags_ui.cc ('k') | chrome/browser/ui/webui/help/version_updater.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b88247f3f3061447b0ef0f9e38ef3f2e5bed1c6b 100644
--- a/chrome/browser/ui/webui/help/help_handler.cc
+++ b/chrome/browser/ui/webui/help/help_handler.cc
@@ -33,6 +33,7 @@
#include "components/google/core/browser/google_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/common/user_agent.h"
#include "grit/components_strings.h"
@@ -48,7 +49,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 +92,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 +104,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()
+ ->GetForBrowserContext(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 +131,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 +285,10 @@ void HelpHandler::GetLocalizedValues(base::DictionaryValue* localized_strings) {
}
void HelpHandler::RegisterMessages() {
+#if defined(OS_CHROMEOS)
+ version_updater_.reset(
+ VersionUpdater::Create(web_ui()->GetWebContents()->GetBrowserContext()));
+#endif
registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
content::NotificationService::AllSources());
@@ -351,7 +364,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 +439,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;
}
« no previous file with comments | « chrome/browser/ui/webui/flags_ui.cc ('k') | chrome/browser/ui/webui/help/version_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698