| OLD | NEW |
| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 #endif | 597 #endif |
| 598 } | 598 } |
| 599 | 599 |
| 600 void BrowserOptionsHandler::OnStateChanged() { | 600 void BrowserOptionsHandler::OnStateChanged() { |
| 601 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", | 601 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", |
| 602 *GetSyncStateDictionary()); | 602 *GetSyncStateDictionary()); |
| 603 | 603 |
| 604 SendProfilesInfo(); | 604 SendProfilesInfo(); |
| 605 } | 605 } |
| 606 | 606 |
| 607 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { |
| 608 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", |
| 609 *GetSyncStateDictionary()); |
| 610 |
| 611 SendProfilesInfo(); |
| 612 } |
| 613 |
| 607 void BrowserOptionsHandler::PageLoadStarted() { | 614 void BrowserOptionsHandler::PageLoadStarted() { |
| 608 page_initialized_ = false; | 615 page_initialized_ = false; |
| 609 } | 616 } |
| 610 | 617 |
| 611 void BrowserOptionsHandler::InitializeHandler() { | 618 void BrowserOptionsHandler::InitializeHandler() { |
| 612 Profile* profile = Profile::FromWebUI(web_ui()); | 619 Profile* profile = Profile::FromWebUI(web_ui()); |
| 613 PrefService* prefs = profile->GetPrefs(); | 620 PrefService* prefs = profile->GetPrefs(); |
| 614 | 621 |
| 615 ProfileSyncService* sync_service( | 622 ProfileSyncService* sync_service( |
| 616 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 623 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, | 674 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, |
| 668 base::Unretained(this))); | 675 base::Unretained(this))); |
| 669 default_font_size_.Init( | 676 default_font_size_.Init( |
| 670 prefs::kWebKitDefaultFontSize, prefs, | 677 prefs::kWebKitDefaultFontSize, prefs, |
| 671 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, | 678 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, |
| 672 base::Unretained(this))); | 679 base::Unretained(this))); |
| 673 default_zoom_level_.Init( | 680 default_zoom_level_.Init( |
| 674 prefs::kDefaultZoomLevel, prefs, | 681 prefs::kDefaultZoomLevel, prefs, |
| 675 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, | 682 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, |
| 676 base::Unretained(this))); | 683 base::Unretained(this))); |
| 684 profile_pref_registrar_.Init(prefs); |
| 685 profile_pref_registrar_.Add( |
| 686 prefs::kSigninAllowed, |
| 687 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange, |
| 688 base::Unretained(this))); |
| 677 #if !defined(OS_CHROMEOS) | 689 #if !defined(OS_CHROMEOS) |
| 678 proxy_prefs_.Init(prefs); | 690 profile_pref_registrar_.Add( |
| 679 proxy_prefs_.Add(prefs::kProxy, | 691 prefs::kProxy, |
| 680 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection, | 692 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection, |
| 681 base::Unretained(this))); | 693 base::Unretained(this))); |
| 682 #endif // !defined(OS_CHROMEOS) | 694 #endif // !defined(OS_CHROMEOS) |
| 683 } | 695 } |
| 684 | 696 |
| 685 void BrowserOptionsHandler::InitializePage() { | 697 void BrowserOptionsHandler::InitializePage() { |
| 686 page_initialized_ = true; | 698 page_initialized_ = true; |
| 687 OnTemplateURLServiceChanged(); | 699 OnTemplateURLServiceChanged(); |
| 688 ObserveThemeChanged(); | 700 ObserveThemeChanged(); |
| 689 OnStateChanged(); | 701 OnStateChanged(); |
| 690 UpdateDefaultBrowserState(); | 702 UpdateDefaultBrowserState(); |
| 691 | 703 |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 base::StringValue email_value(email); | 1108 base::StringValue email_value(email); |
| 1097 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", | 1109 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", |
| 1098 email_value); | 1110 email_value); |
| 1099 } | 1111 } |
| 1100 } | 1112 } |
| 1101 #endif | 1113 #endif |
| 1102 | 1114 |
| 1103 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() { | 1115 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() { |
| 1104 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue); | 1116 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue); |
| 1105 Profile* profile = Profile::FromWebUI(web_ui()); | 1117 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1106 sync_status->SetBoolean("signinAllowed", !profile->IsGuestSession()); | |
| 1107 if (profile->IsGuestSession()) { | 1118 if (profile->IsGuestSession()) { |
| 1108 // Cannot display signin status when running in guest mode on chromeos | 1119 // Cannot display signin status when running in guest mode on chromeos |
| 1109 // because there is no SigninManager. | 1120 // because there is no SigninManager. |
| 1121 sync_status->SetBoolean("signinAllowed", false); |
| 1110 return sync_status.Pass(); | 1122 return sync_status.Pass(); |
| 1111 } | 1123 } |
| 1112 | 1124 |
| 1113 // Signout is not allowed if the user has policy (crbug.com/172204). | 1125 // Signout is not allowed if the user has policy (crbug.com/172204). |
| 1114 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); | 1126 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); |
| 1127 DCHECK(signin); |
| 1115 sync_status->SetBoolean("signoutAllowed", !signin->IsSignoutProhibited()); | 1128 sync_status->SetBoolean("signoutAllowed", !signin->IsSignoutProhibited()); |
| 1116 ProfileSyncService* service( | 1129 ProfileSyncService* service( |
| 1117 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 1130 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
| 1131 sync_status->SetBoolean("signinAllowed", signin->IsSigninAllowed()); |
| 1118 sync_status->SetBoolean("syncSystemEnabled", !!service); | 1132 sync_status->SetBoolean("syncSystemEnabled", !!service); |
| 1119 sync_status->SetBoolean("setupCompleted", | 1133 sync_status->SetBoolean("setupCompleted", |
| 1120 service && service->HasSyncSetupCompleted()); | 1134 service && service->HasSyncSetupCompleted()); |
| 1121 sync_status->SetBoolean("setupInProgress", | 1135 sync_status->SetBoolean("setupInProgress", |
| 1122 service && !service->IsManaged() && service->FirstSetupInProgress()); | 1136 service && !service->IsManaged() && service->FirstSetupInProgress()); |
| 1123 | 1137 |
| 1124 string16 status_label; | 1138 string16 status_label; |
| 1125 string16 link_label; | 1139 string16 link_label; |
| 1126 DCHECK(signin); | 1140 DCHECK(signin); |
| 1127 bool status_has_error = sync_ui_util::GetStatusLabels( | 1141 bool status_has_error = sync_ui_util::GetStatusLabels( |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 void BrowserOptionsHandler::SetupProxySettingsSection() { | 1464 void BrowserOptionsHandler::SetupProxySettingsSection() { |
| 1451 #if !defined(OS_CHROMEOS) | 1465 #if !defined(OS_CHROMEOS) |
| 1452 // Disable the button if proxy settings are managed by a sysadmin or | 1466 // Disable the button if proxy settings are managed by a sysadmin or |
| 1453 // overridden by an extension. | 1467 // overridden by an extension. |
| 1454 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1468 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1455 const PrefService::Preference* proxy_config = | 1469 const PrefService::Preference* proxy_config = |
| 1456 pref_service->FindPreference(prefs::kProxy); | 1470 pref_service->FindPreference(prefs::kProxy); |
| 1457 bool is_extension_controlled = (proxy_config && | 1471 bool is_extension_controlled = (proxy_config && |
| 1458 proxy_config->IsExtensionControlled()); | 1472 proxy_config->IsExtensionControlled()); |
| 1459 | 1473 |
| 1460 base::FundamentalValue disabled(proxy_prefs_.IsManaged() || | 1474 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() || |
| 1461 is_extension_controlled); | 1475 is_extension_controlled); |
| 1462 base::FundamentalValue extension_controlled(is_extension_controlled); | 1476 base::FundamentalValue extension_controlled(is_extension_controlled); |
| 1463 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", | 1477 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", |
| 1464 disabled, extension_controlled); | 1478 disabled, extension_controlled); |
| 1465 | 1479 |
| 1466 #endif // !defined(OS_CHROMEOS) | 1480 #endif // !defined(OS_CHROMEOS) |
| 1467 } | 1481 } |
| 1468 | 1482 |
| 1469 } // namespace options | 1483 } // namespace options |
| OLD | NEW |