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

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

Issue 8102019: redesign and reimplement proxy config service and tracker, revise proxy ui on cros (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/advanced_options_handler.h" 5 #include "chrome/browser/ui/webui/options/advanced_options_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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 GURL(chrome::kCloudPrintLearnMoreURL)).spec()); 196 GURL(chrome::kCloudPrintLearnMoreURL)).spec());
197 #endif 197 #endif
198 } 198 }
199 199
200 void AdvancedOptionsHandler::Initialize() { 200 void AdvancedOptionsHandler::Initialize() {
201 DCHECK(web_ui_); 201 DCHECK(web_ui_);
202 SetupMetricsReportingCheckbox(); 202 SetupMetricsReportingCheckbox();
203 SetupMetricsReportingSettingVisibility(); 203 SetupMetricsReportingSettingVisibility();
204 SetupFontSizeLabel(); 204 SetupFontSizeLabel();
205 SetupAutoOpenFileTypesDisabledAttribute(); 205 SetupAutoOpenFileTypesDisabledAttribute();
206 #if !defined(OS_CHROMEOS)
206 SetupProxySettingsSection(); 207 SetupProxySettingsSection();
208 #endif // !defined(OS_CHROMEOS)
207 SetupSSLConfigSettings(); 209 SetupSSLConfigSettings();
208 #if !defined(OS_CHROMEOS) 210 #if !defined(OS_CHROMEOS)
209 if (cloud_print_proxy_ui_enabled_) { 211 if (cloud_print_proxy_ui_enabled_) {
210 SetupCloudPrintProxySection(); 212 SetupCloudPrintProxySection();
211 RefreshCloudPrintStatusFromService(); 213 RefreshCloudPrintStatusFromService();
212 } else { 214 } else {
213 RemoveCloudPrintProxySection(); 215 RemoveCloudPrintProxySection();
214 } 216 }
215 #endif 217 #endif
216 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) 218 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
(...skipping 21 matching lines...) Expand all
238 g_browser_process->local_state(), this); 240 g_browser_process->local_state(), this);
239 241
240 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) 242 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
241 background_mode_enabled_.Init(prefs::kBackgroundModeEnabled, 243 background_mode_enabled_.Init(prefs::kBackgroundModeEnabled,
242 g_browser_process->local_state(), 244 g_browser_process->local_state(),
243 this); 245 this);
244 #endif 246 #endif
245 247
246 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); 248 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this);
247 default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this); 249 default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this);
250 #if !defined(OS_CHROMEOS)
248 proxy_prefs_.reset( 251 proxy_prefs_.reset(
249 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); 252 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this));
253 #endif // !defined(OS_CHROMEOS)
250 254
251 // Return result from the superclass. 255 // Return result from the superclass.
252 return handler; 256 return handler;
253 } 257 }
254 258
255 void AdvancedOptionsHandler::RegisterMessages() { 259 void AdvancedOptionsHandler::RegisterMessages() {
256 // Setup handlers specific to this panel. 260 // Setup handlers specific to this panel.
257 DCHECK(web_ui_); 261 DCHECK(web_ui_);
258 web_ui_->RegisterMessageCallback("selectDownloadLocation", 262 web_ui_->RegisterMessageCallback("selectDownloadLocation",
259 base::Bind(&AdvancedOptionsHandler::HandleSelectDownloadLocation, 263 base::Bind(&AdvancedOptionsHandler::HandleSelectDownloadLocation,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 #endif 304 #endif
301 } 305 }
302 306
303 void AdvancedOptionsHandler::Observe(int type, 307 void AdvancedOptionsHandler::Observe(int type,
304 const NotificationSource& source, 308 const NotificationSource& source,
305 const NotificationDetails& details) { 309 const NotificationDetails& details) {
306 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 310 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
307 std::string* pref_name = Details<std::string>(details).ptr(); 311 std::string* pref_name = Details<std::string>(details).ptr();
308 if (*pref_name == prefs::kDownloadExtensionsToOpen) { 312 if (*pref_name == prefs::kDownloadExtensionsToOpen) {
309 SetupAutoOpenFileTypesDisabledAttribute(); 313 SetupAutoOpenFileTypesDisabledAttribute();
314 #if !defined(OS_CHROMEOS)
310 } else if (proxy_prefs_->IsObserved(*pref_name)) { 315 } else if (proxy_prefs_->IsObserved(*pref_name)) {
311 SetupProxySettingsSection(); 316 SetupProxySettingsSection();
317 #endif // !defined(OS_CHROMEOS)
312 } else if ((*pref_name == prefs::kCloudPrintEmail) || 318 } else if ((*pref_name == prefs::kCloudPrintEmail) ||
313 (*pref_name == prefs::kCloudPrintProxyEnabled)) { 319 (*pref_name == prefs::kCloudPrintProxyEnabled)) {
314 #if !defined(OS_CHROMEOS) 320 #if !defined(OS_CHROMEOS)
315 if (cloud_print_proxy_ui_enabled_) 321 if (cloud_print_proxy_ui_enabled_)
316 SetupCloudPrintProxySection(); 322 SetupCloudPrintProxySection();
317 #endif 323 #endif
318 } else if (*pref_name == prefs::kWebKitDefaultFontSize) { 324 } else if (*pref_name == prefs::kWebKitDefaultFontSize) {
319 SetupFontSizeLabel(); 325 SetupFontSizeLabel();
320 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) 326 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS)
321 } else if (*pref_name == prefs::kBackgroundModeEnabled) { 327 } else if (*pref_name == prefs::kBackgroundModeEnabled) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // We enable the button if the user has any auto-open file types registered. 544 // We enable the button if the user has any auto-open file types registered.
539 DownloadManager* manager = 545 DownloadManager* manager =
540 web_ui_->tab_contents()->browser_context()->GetDownloadManager(); 546 web_ui_->tab_contents()->browser_context()->GetDownloadManager();
541 bool disabled = !(manager && 547 bool disabled = !(manager &&
542 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); 548 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed());
543 base::FundamentalValue value(disabled); 549 base::FundamentalValue value(disabled);
544 web_ui_->CallJavascriptFunction( 550 web_ui_->CallJavascriptFunction(
545 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value); 551 "options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value);
546 } 552 }
547 553
554 #if !defined(OS_CHROMEOS)
548 void AdvancedOptionsHandler::SetupProxySettingsSection() { 555 void AdvancedOptionsHandler::SetupProxySettingsSection() {
549 // Disable the button if proxy settings are managed by a sysadmin or 556 // Disable the button if proxy settings are managed by a sysadmin or
xiyuan 2011/10/18 17:33:31 Can we use the following here? #if defined(OS_CHRO
kuan 2011/10/18 20:32:47 Done.
550 // overridden by an extension. 557 // overridden by an extension.
551 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs(); 558 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
552 const PrefService::Preference* proxy_config = 559 const PrefService::Preference* proxy_config =
553 pref_service->FindPreference(prefs::kProxy); 560 pref_service->FindPreference(prefs::kProxy);
554 bool is_extension_controlled = (proxy_config && 561 bool is_extension_controlled = (proxy_config &&
555 proxy_config->IsExtensionControlled()); 562 proxy_config->IsExtensionControlled());
556 563
557 base::FundamentalValue disabled(proxy_prefs_->IsManaged() || 564 base::FundamentalValue disabled(proxy_prefs_->IsManaged() ||
558 is_extension_controlled); 565 is_extension_controlled);
559 566
560 // Get the appropriate info string to describe the button. 567 // Get the appropriate info string to describe the button.
561 string16 label_str; 568 string16 label_str;
562 if (is_extension_controlled) { 569 if (is_extension_controlled) {
563 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); 570 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL);
564 } else { 571 } else {
565 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, 572 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL,
566 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 573 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
567 } 574 }
568 StringValue label(label_str); 575 StringValue label(label_str);
569 576
570 web_ui_->CallJavascriptFunction( 577 web_ui_->CallJavascriptFunction(
571 "options.AdvancedOptions.SetupProxySettingsSection", disabled, label); 578 "options.AdvancedOptions.SetupProxySettingsSection", disabled, label);
572 } 579 }
580 #endif // !defined(OS_CHROMEOS)
573 581
574 void AdvancedOptionsHandler::SetupSSLConfigSettings() { 582 void AdvancedOptionsHandler::SetupSSLConfigSettings() {
575 { 583 {
576 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); 584 base::FundamentalValue checked(rev_checking_enabled_.GetValue());
577 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); 585 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged());
578 web_ui_->CallJavascriptFunction( 586 web_ui_->CallJavascriptFunction(
579 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked, 587 "options.AdvancedOptions.SetCheckRevocationCheckboxState", checked,
580 disabled); 588 disabled);
581 } 589 }
582 } 590 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698