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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 cloud_print_connector_ui_enabled_ = true; | 136 cloud_print_connector_ui_enabled_ = true; |
137 #endif | 137 #endif |
138 } | 138 } |
139 | 139 |
140 BrowserOptionsHandler::~BrowserOptionsHandler() { | 140 BrowserOptionsHandler::~BrowserOptionsHandler() { |
141 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: | 141 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: |
142 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); | 142 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); |
143 if (sync_service) | 143 if (sync_service) |
144 sync_service->RemoveObserver(this); | 144 sync_service->RemoveObserver(this); |
145 | 145 |
146 profile_pref_registrar_.RemoveAll(); | |
146 if (default_browser_worker_.get()) | 147 if (default_browser_worker_.get()) |
147 default_browser_worker_->ObserverDestroyed(); | 148 default_browser_worker_->ObserverDestroyed(); |
148 if (template_url_service_) | 149 if (template_url_service_) |
149 template_url_service_->RemoveObserver(this); | 150 template_url_service_->RemoveObserver(this); |
150 // There may be pending file dialogs, we need to tell them that we've gone | 151 // There may be pending file dialogs, we need to tell them that we've gone |
151 // away so they don't try and call back to us. | 152 // away so they don't try and call back to us. |
152 if (select_folder_dialog_.get()) | 153 if (select_folder_dialog_.get()) |
153 select_folder_dialog_->ListenerDestroyed(); | 154 select_folder_dialog_->ListenerDestroyed(); |
154 } | 155 } |
155 | 156 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 #endif | 574 #endif |
574 } | 575 } |
575 | 576 |
576 void BrowserOptionsHandler::OnStateChanged() { | 577 void BrowserOptionsHandler::OnStateChanged() { |
577 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", | 578 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", |
578 *GetSyncStateDictionary()); | 579 *GetSyncStateDictionary()); |
579 | 580 |
580 SendProfilesInfo(); | 581 SendProfilesInfo(); |
581 } | 582 } |
582 | 583 |
584 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { | |
585 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", | |
586 *GetSyncStateDictionary()); | |
587 | |
588 SendProfilesInfo(); | |
589 } | |
590 | |
583 void BrowserOptionsHandler::PageLoadStarted() { | 591 void BrowserOptionsHandler::PageLoadStarted() { |
584 page_initialized_ = false; | 592 page_initialized_ = false; |
585 } | 593 } |
586 | 594 |
587 void BrowserOptionsHandler::InitializeHandler() { | 595 void BrowserOptionsHandler::InitializeHandler() { |
588 Profile* profile = Profile::FromWebUI(web_ui()); | 596 Profile* profile = Profile::FromWebUI(web_ui()); |
589 PrefService* prefs = profile->GetPrefs(); | 597 PrefService* prefs = profile->GetPrefs(); |
590 | 598 |
591 ProfileSyncService* sync_service( | 599 ProfileSyncService* sync_service( |
592 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 600 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
643 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, | 651 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, |
644 base::Unretained(this))); | 652 base::Unretained(this))); |
645 default_font_size_.Init( | 653 default_font_size_.Init( |
646 prefs::kWebKitDefaultFontSize, prefs, | 654 prefs::kWebKitDefaultFontSize, prefs, |
647 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, | 655 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, |
648 base::Unretained(this))); | 656 base::Unretained(this))); |
649 default_zoom_level_.Init( | 657 default_zoom_level_.Init( |
650 prefs::kDefaultZoomLevel, prefs, | 658 prefs::kDefaultZoomLevel, prefs, |
651 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, | 659 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, |
652 base::Unretained(this))); | 660 base::Unretained(this))); |
661 profile_pref_registrar_.Init(prefs); | |
662 profile_pref_registrar_.Add(prefs::kSigninAllowed, | |
663 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange, | |
664 base::Unretained(this))); | |
653 #if !defined(OS_CHROMEOS) | 665 #if !defined(OS_CHROMEOS) |
654 proxy_prefs_.Init(prefs); | 666 profile_pref_registrar_.Add(prefs::kProxy, |
655 proxy_prefs_.Add(prefs::kProxy, | |
656 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection, | 667 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection, |
Andrew T Wilson (Slow)
2013/02/07 15:05:30
Indent is off here now.
Adrian Kuegel
2013/02/07 16:08:59
Done.
| |
657 base::Unretained(this))); | 668 base::Unretained(this))); |
658 #endif // !defined(OS_CHROMEOS) | 669 #endif // !defined(OS_CHROMEOS) |
659 } | 670 } |
660 | 671 |
661 void BrowserOptionsHandler::InitializePage() { | 672 void BrowserOptionsHandler::InitializePage() { |
662 page_initialized_ = true; | 673 page_initialized_ = true; |
663 OnTemplateURLServiceChanged(); | 674 OnTemplateURLServiceChanged(); |
664 ObserveThemeChanged(); | 675 ObserveThemeChanged(); |
665 OnStateChanged(); | 676 OnStateChanged(); |
666 UpdateDefaultBrowserState(); | 677 UpdateDefaultBrowserState(); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1065 base::StringValue email_value(email); | 1076 base::StringValue email_value(email); |
1066 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", | 1077 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", |
1067 email_value); | 1078 email_value); |
1068 } | 1079 } |
1069 } | 1080 } |
1070 #endif | 1081 #endif |
1071 | 1082 |
1072 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() { | 1083 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() { |
1073 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue); | 1084 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue); |
1074 Profile* profile = Profile::FromWebUI(web_ui()); | 1085 Profile* profile = Profile::FromWebUI(web_ui()); |
1075 sync_status->SetBoolean("signinAllowed", !profile->IsGuestSession()); | |
1076 if (profile->IsGuestSession()) { | 1086 if (profile->IsGuestSession()) { |
1077 // Cannot display signin status when running in guest mode on chromeos | 1087 // Cannot display signin status when running in guest mode on chromeos |
1078 // because there is no SigninManager. | 1088 // because there is no SigninManager. |
1089 sync_status->SetBoolean("signinAllowed", false); | |
1079 return sync_status.Pass(); | 1090 return sync_status.Pass(); |
1080 } | 1091 } |
1081 ProfileSyncService* service( | 1092 ProfileSyncService* service( |
1082 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 1093 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
1094 SigninManager* signin(SigninManagerFactory::GetForProfile(profile)); | |
1095 DCHECK(signin); | |
1096 sync_status->SetBoolean("signinAllowed", signin->IsSigninAllowed()); | |
1083 sync_status->SetBoolean("syncSystemEnabled", !!service); | 1097 sync_status->SetBoolean("syncSystemEnabled", !!service); |
1084 sync_status->SetBoolean("setupCompleted", | 1098 sync_status->SetBoolean("setupCompleted", |
1085 service && service->HasSyncSetupCompleted()); | 1099 service && service->HasSyncSetupCompleted()); |
1086 sync_status->SetBoolean("setupInProgress", | 1100 sync_status->SetBoolean("setupInProgress", |
1087 service && !service->IsManaged() && service->FirstSetupInProgress()); | 1101 service && !service->IsManaged() && service->FirstSetupInProgress()); |
1088 | 1102 |
1089 string16 status_label; | 1103 string16 status_label; |
1090 string16 link_label; | 1104 string16 link_label; |
1091 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); | |
1092 DCHECK(signin); | |
1093 bool status_has_error = sync_ui_util::GetStatusLabels( | 1105 bool status_has_error = sync_ui_util::GetStatusLabels( |
1094 service, *signin, sync_ui_util::WITH_HTML, &status_label, &link_label) == | 1106 service, *signin, sync_ui_util::WITH_HTML, &status_label, &link_label) == |
1095 sync_ui_util::SYNC_ERROR; | 1107 sync_ui_util::SYNC_ERROR; |
1096 sync_status->SetString("statusText", status_label); | 1108 sync_status->SetString("statusText", status_label); |
1097 sync_status->SetString("actionLinkText", link_label); | 1109 sync_status->SetString("actionLinkText", link_label); |
1098 sync_status->SetBoolean("hasError", status_has_error); | 1110 sync_status->SetBoolean("hasError", status_has_error); |
1099 | 1111 |
1100 sync_status->SetBoolean("managed", service && service->IsManaged()); | 1112 sync_status->SetBoolean("managed", service && service->IsManaged()); |
1101 sync_status->SetBoolean("signedIn", | 1113 sync_status->SetBoolean("signedIn", |
1102 !signin->GetAuthenticatedUsername().empty()); | 1114 !signin->GetAuthenticatedUsername().empty()); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1416 void BrowserOptionsHandler::SetupProxySettingsSection() { | 1428 void BrowserOptionsHandler::SetupProxySettingsSection() { |
1417 #if !defined(OS_CHROMEOS) | 1429 #if !defined(OS_CHROMEOS) |
1418 // Disable the button if proxy settings are managed by a sysadmin or | 1430 // Disable the button if proxy settings are managed by a sysadmin or |
1419 // overridden by an extension. | 1431 // overridden by an extension. |
1420 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1432 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
1421 const PrefService::Preference* proxy_config = | 1433 const PrefService::Preference* proxy_config = |
1422 pref_service->FindPreference(prefs::kProxy); | 1434 pref_service->FindPreference(prefs::kProxy); |
1423 bool is_extension_controlled = (proxy_config && | 1435 bool is_extension_controlled = (proxy_config && |
1424 proxy_config->IsExtensionControlled()); | 1436 proxy_config->IsExtensionControlled()); |
1425 | 1437 |
1426 base::FundamentalValue disabled(proxy_prefs_.IsManaged() || | 1438 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() || |
1427 is_extension_controlled); | 1439 is_extension_controlled); |
1428 base::FundamentalValue extension_controlled(is_extension_controlled); | 1440 base::FundamentalValue extension_controlled(is_extension_controlled); |
1429 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", | 1441 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", |
1430 disabled, extension_controlled); | 1442 disabled, extension_controlled); |
1431 | 1443 |
1432 #endif // !defined(OS_CHROMEOS) | 1444 #endif // !defined(OS_CHROMEOS) |
1433 } | 1445 } |
1434 | 1446 |
1435 } // namespace options | 1447 } // namespace options |
OLD | NEW |