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

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

Issue 1749813002: Fixes hidden "Set Default Browser" button when group policy is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/settings/settings_default_browser_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser_options_handler.h" 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void AppendExtensionData(const std::string& key, 166 void AppendExtensionData(const std::string& key,
167 const Extension* extension, 167 const Extension* extension,
168 base::DictionaryValue* dict) { 168 base::DictionaryValue* dict) {
169 scoped_ptr<base::DictionaryValue> details(new base::DictionaryValue); 169 scoped_ptr<base::DictionaryValue> details(new base::DictionaryValue);
170 details->SetString("id", extension ? extension->id() : std::string()); 170 details->SetString("id", extension ? extension->id() : std::string());
171 details->SetString("name", extension ? extension->name() : std::string()); 171 details->SetString("name", extension ? extension->name() : std::string());
172 dict->Set(key, details.release()); 172 dict->Set(key, details.release());
173 } 173 }
174 #endif // defined(OS_WIN) 174 #endif // defined(OS_WIN)
175 175
176 bool IsDisabledByPolicy(const BooleanPrefMember& pref) {
177 return pref.IsManaged() && !pref.GetValue();
178 }
179
176 } // namespace 180 } // namespace
177 181
178 namespace options { 182 namespace options {
179 183
180 BrowserOptionsHandler::BrowserOptionsHandler() 184 BrowserOptionsHandler::BrowserOptionsHandler()
181 : page_initialized_(false), 185 : page_initialized_(false),
182 template_url_service_(NULL), 186 template_url_service_(NULL),
183 cloud_print_mdns_ui_enabled_(false), 187 cloud_print_mdns_ui_enabled_(false),
184 #if defined(OS_CHROMEOS) 188 #if defined(OS_CHROMEOS)
185 enable_factory_reset_(false), 189 enable_factory_reset_(false),
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 #endif 1095 #endif
1092 } 1096 }
1093 1097
1094 void BrowserOptionsHandler::UpdateDefaultBrowserState() { 1098 void BrowserOptionsHandler::UpdateDefaultBrowserState() {
1095 default_browser_worker_->StartCheckIsDefault(); 1099 default_browser_worker_->StartCheckIsDefault();
1096 } 1100 }
1097 1101
1098 void BrowserOptionsHandler::BecomeDefaultBrowser(const base::ListValue* args) { 1102 void BrowserOptionsHandler::BecomeDefaultBrowser(const base::ListValue* args) {
1099 // If the default browser setting is managed then we should not be able to 1103 // If the default browser setting is managed then we should not be able to
1100 // call this function. 1104 // call this function.
1101 if (default_browser_policy_.IsManaged()) 1105 if (IsDisabledByPolicy(default_browser_policy_))
1102 return; 1106 return;
1103 1107
1104 content::RecordAction(UserMetricsAction("Options_SetAsDefaultBrowser")); 1108 content::RecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"));
1105 UMA_HISTOGRAM_COUNTS("Settings.StartSetAsDefault", true); 1109 UMA_HISTOGRAM_COUNTS("Settings.StartSetAsDefault", true);
1106 1110
1107 // Callback takes care of updating UI. 1111 // Callback takes care of updating UI.
1108 default_browser_worker_->StartSetAsDefault(); 1112 default_browser_worker_->StartSetAsDefault();
1109 1113
1110 // If the user attempted to make Chrome the default browser, notify 1114 // If the user attempted to make Chrome the default browser, notify
1111 // them when this changes. 1115 // them when this changes.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 1154
1151 void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) { 1155 void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) {
1152 base::StringValue status_string( 1156 base::StringValue status_string(
1153 l10n_util::GetStringFUTF16(status_string_id, 1157 l10n_util::GetStringFUTF16(status_string_id,
1154 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 1158 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
1155 1159
1156 base::FundamentalValue is_default( 1160 base::FundamentalValue is_default(
1157 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT); 1161 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT);
1158 1162
1159 base::FundamentalValue can_be_default( 1163 base::FundamentalValue can_be_default(
1160 !default_browser_policy_.IsManaged() && 1164 !IsDisabledByPolicy(default_browser_policy_) &&
1161 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT || 1165 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT ||
1162 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT)); 1166 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT));
1163 1167
1164 web_ui()->CallJavascriptFunction( 1168 web_ui()->CallJavascriptFunction(
1165 "BrowserOptions.updateDefaultBrowserState", 1169 "BrowserOptions.updateDefaultBrowserState",
1166 status_string, is_default, can_be_default); 1170 status_string, is_default, can_be_default);
1167 } 1171 }
1168 1172
1169 void BrowserOptionsHandler::OnTemplateURLServiceChanged() { 1173 void BrowserOptionsHandler::OnTemplateURLServiceChanged() {
1170 if (!template_url_service_ || !template_url_service_->loaded()) 1174 if (!template_url_service_ || !template_url_service_->loaded())
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 2123
2120 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { 2124 bool BrowserOptionsHandler::IsDeviceOwnerProfile() {
2121 #if defined(OS_CHROMEOS) 2125 #if defined(OS_CHROMEOS)
2122 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); 2126 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui()));
2123 #else 2127 #else
2124 return true; 2128 return true;
2125 #endif 2129 #endif
2126 } 2130 }
2127 2131
2128 } // namespace options 2132 } // namespace options
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/settings/settings_default_browser_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698