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

Side by Side Diff: chrome/browser/ui/webui/settings/about_handler.cc

Issue 2746643002: MD About: controlled indicator for change channel option (Closed)
Patch Set: format Created 3 years, 9 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/settings/about_handler.h" 5 #include "chrome/browser/ui/webui/settings/about_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 // Returns true if the device is enterprise managed, false otherwise. 107 // Returns true if the device is enterprise managed, false otherwise.
108 bool IsEnterpriseManaged() { 108 bool IsEnterpriseManaged() {
109 policy::BrowserPolicyConnectorChromeOS* connector = 109 policy::BrowserPolicyConnectorChromeOS* connector =
110 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 110 g_browser_process->platform_part()->browser_policy_connector_chromeos();
111 return connector->IsEnterpriseManaged(); 111 return connector->IsEnterpriseManaged();
112 } 112 }
113 113
114 // Returns true if current user can change channel, false otherwise. 114 // Returns true if current user can change channel, false otherwise.
115 bool CanChangeChannel(Profile* profile) { 115 bool CanChangeChannel(Profile* profile) {
116 bool value = false;
117 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kReleaseChannelDelegated,
118 &value);
119
120 // On a managed machine we delegate this setting to the users of the same 116 // On a managed machine we delegate this setting to the users of the same
121 // domain only if the policy value is "domain". 117 // domain only if the policy value is "domain".
122 if (IsEnterpriseManaged()) { 118 if (IsEnterpriseManaged()) {
119 bool value = false;
120 chromeos::CrosSettings::Get()->GetBoolean(
121 chromeos::kReleaseChannelDelegated, &value);
123 if (!value) 122 if (!value)
124 return false; 123 return false;
125 // Get the currently logged in user and strip the domain part only. 124
125 // Get the currently logged-in user and strip the domain part only.
126 std::string domain = ""; 126 std::string domain = "";
127 const user_manager::User* user = 127 const user_manager::User* user =
128 profile ? chromeos::ProfileHelper::Get()->GetUserByProfile(profile) 128 profile ? chromeos::ProfileHelper::Get()->GetUserByProfile(profile)
129 : nullptr; 129 : nullptr;
130 std::string email = 130 std::string email =
131 user ? user->GetAccountId().GetUserEmail() : std::string(); 131 user ? user->GetAccountId().GetUserEmail() : std::string();
132 size_t at_pos = email.find('@'); 132 size_t at_pos = email.find('@');
133 if (at_pos != std::string::npos && at_pos + 1 < email.length()) 133 if (at_pos != std::string::npos && at_pos + 1 < email.length())
134 domain = email.substr(email.find('@') + 1); 134 domain = email.substr(email.find('@') + 1);
135 policy::BrowserPolicyConnectorChromeOS* connector = 135 policy::BrowserPolicyConnectorChromeOS* connector =
136 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 136 g_browser_process->platform_part()->browser_policy_connector_chromeos();
137 return domain == connector->GetEnterpriseDomain(); 137 return domain == connector->GetEnterpriseDomain();
138 } else {
139 chromeos::OwnerSettingsServiceChromeOS* service =
140 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance()
141 ->GetForBrowserContext(profile);
142 // On non managed machines we have local owner who is the only one to change
143 // anything. Ensure that ReleaseChannelDelegated is false.
144 if (service && service->IsOwner())
145 return !value;
146 } 138 }
147 return false; 139
140 // On non-managed machines, only the local owner can change the channel.
141 chromeos::OwnerSettingsServiceChromeOS* service =
142 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance()
143 ->GetForBrowserContext(profile);
144 return service && service->IsOwner();
148 } 145 }
149 146
150 // Returns the path of the regulatory labels directory for a given region, if 147 // Returns the path of the regulatory labels directory for a given region, if
151 // found. Must be called from the blocking pool. 148 // found. Must be called from the blocking pool.
152 base::FilePath GetRegulatoryLabelDirForRegion(const std::string& region) { 149 base::FilePath GetRegulatoryLabelDirForRegion(const std::string& region) {
153 // Generate the path under the asset dir or URL host to the regulatory files 150 // Generate the path under the asset dir or URL host to the regulatory files
154 // for the region, e.g., "regulatory_labels/us/". 151 // for the region, e.g., "regulatory_labels/us/".
155 const base::FilePath region_path = 152 const base::FilePath region_path =
156 base::FilePath(kRegulatoryLabelsDirectory).AppendASCII(region); 153 base::FilePath(kRegulatoryLabelsDirectory).AppendASCII(region);
157 154
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII(); 644 label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII();
648 std::string url = 645 std::string url =
649 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path; 646 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path;
650 regulatory_info->SetString("url", url); 647 regulatory_info->SetString("url", url);
651 648
652 ResolveJavascriptCallback(base::Value(callback_id), *regulatory_info); 649 ResolveJavascriptCallback(base::Value(callback_id), *regulatory_info);
653 } 650 }
654 #endif // defined(OS_CHROMEOS) 651 #endif // defined(OS_CHROMEOS)
655 652
656 } // namespace settings 653 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698