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

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

Issue 12088040: Add a SigninAllowed policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests and link UpdateLogin to kSigninAllowed pref. Created 7 years, 10 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) 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
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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, 648 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes,
641 base::Unretained(this))); 649 base::Unretained(this)));
642 default_font_size_.Init( 650 default_font_size_.Init(
643 prefs::kWebKitDefaultFontSize, prefs, 651 prefs::kWebKitDefaultFontSize, prefs,
644 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, 652 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector,
645 base::Unretained(this))); 653 base::Unretained(this)));
646 default_zoom_level_.Init( 654 default_zoom_level_.Init(
647 prefs::kDefaultZoomLevel, prefs, 655 prefs::kDefaultZoomLevel, prefs,
648 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, 656 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector,
649 base::Unretained(this))); 657 base::Unretained(this)));
658 profile_pref_registrar_.Init(prefs);
659 profile_pref_registrar_.Add(prefs::kSigninAllowed,
660 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange,
661 base::Unretained(this)));
650 #if !defined(OS_CHROMEOS) 662 #if !defined(OS_CHROMEOS)
651 proxy_prefs_.Init(prefs); 663 profile_pref_registrar_.Add(prefs::kProxy,
652 proxy_prefs_.Add(prefs::kProxy,
653 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection, 664 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection,
654 base::Unretained(this))); 665 base::Unretained(this)));
655 #endif // !defined(OS_CHROMEOS) 666 #endif // !defined(OS_CHROMEOS)
656 } 667 }
657 668
658 void BrowserOptionsHandler::InitializePage() { 669 void BrowserOptionsHandler::InitializePage() {
659 page_initialized_ = true; 670 page_initialized_ = true;
660 OnTemplateURLServiceChanged(); 671 OnTemplateURLServiceChanged();
661 ObserveThemeChanged(); 672 ObserveThemeChanged();
662 OnStateChanged(); 673 OnStateChanged();
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", 1065 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture",
1055 email_value); 1066 email_value);
1056 } 1067 }
1057 } 1068 }
1058 #endif 1069 #endif
1059 1070
1060 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() { 1071 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() {
1061 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue); 1072 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue);
1062 ProfileSyncService* service(ProfileSyncServiceFactory:: 1073 ProfileSyncService* service(ProfileSyncServiceFactory::
1063 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); 1074 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui())));
1075 SigninManager* signin = SigninManagerFactory::GetForProfile(
1076 Profile::FromWebUI(web_ui()));
1077 DCHECK(signin);
Andrew T Wilson (Slow) 2013/02/07 10:08:11 I believe signin can be NULL for chromeos guest pr
Adrian Kuegel 2013/02/07 11:09:21 I merged it to ToT. Hopefully correctly :-)
1078 sync_status->SetBoolean("signinAllowed", signin->IsSigninAllowed());
1064 sync_status->SetBoolean("syncSystemEnabled", !!service); 1079 sync_status->SetBoolean("syncSystemEnabled", !!service);
1065 if (!service) 1080 if (!service)
1066 return sync_status.Pass(); 1081 return sync_status.Pass();
1067 1082
1068 sync_status->SetBoolean("setupCompleted", 1083 sync_status->SetBoolean("setupCompleted",
1069 service->HasSyncSetupCompleted()); 1084 service->HasSyncSetupCompleted());
1070 sync_status->SetBoolean("setupInProgress", service->FirstSetupInProgress()); 1085 sync_status->SetBoolean("setupInProgress", service->FirstSetupInProgress());
1071 1086
1072 string16 status_label; 1087 string16 status_label;
1073 string16 link_label; 1088 string16 link_label;
1074 SigninManager* signin = SigninManagerFactory::GetForProfile(
1075 Profile::FromWebUI(web_ui()));
1076 1089
1077 bool status_has_error = sync_ui_util::GetStatusLabels( 1090 bool status_has_error = sync_ui_util::GetStatusLabels(
1078 service, *signin, sync_ui_util::WITH_HTML, &status_label, &link_label) == 1091 service, *signin, sync_ui_util::WITH_HTML, &status_label, &link_label) ==
1079 sync_ui_util::SYNC_ERROR; 1092 sync_ui_util::SYNC_ERROR;
1080 sync_status->SetString("statusText", status_label); 1093 sync_status->SetString("statusText", status_label);
1081 sync_status->SetString("actionLinkText", link_label); 1094 sync_status->SetString("actionLinkText", link_label);
1082 sync_status->SetBoolean("hasError", status_has_error); 1095 sync_status->SetBoolean("hasError", status_has_error);
1083 1096
1084 sync_status->SetBoolean("managed", service->IsManaged()); 1097 sync_status->SetBoolean("managed", service->IsManaged());
1085 sync_status->SetBoolean("signedIn", 1098 sync_status->SetBoolean("signedIn",
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 void BrowserOptionsHandler::SetupProxySettingsSection() { 1412 void BrowserOptionsHandler::SetupProxySettingsSection() {
1400 #if !defined(OS_CHROMEOS) 1413 #if !defined(OS_CHROMEOS)
1401 // Disable the button if proxy settings are managed by a sysadmin or 1414 // Disable the button if proxy settings are managed by a sysadmin or
1402 // overridden by an extension. 1415 // overridden by an extension.
1403 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 1416 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
1404 const PrefService::Preference* proxy_config = 1417 const PrefService::Preference* proxy_config =
1405 pref_service->FindPreference(prefs::kProxy); 1418 pref_service->FindPreference(prefs::kProxy);
1406 bool is_extension_controlled = (proxy_config && 1419 bool is_extension_controlled = (proxy_config &&
1407 proxy_config->IsExtensionControlled()); 1420 proxy_config->IsExtensionControlled());
1408 1421
1409 base::FundamentalValue disabled(proxy_prefs_.IsManaged() || 1422 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() ||
1410 is_extension_controlled); 1423 is_extension_controlled);
1411 base::FundamentalValue extension_controlled(is_extension_controlled); 1424 base::FundamentalValue extension_controlled(is_extension_controlled);
1412 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", 1425 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection",
1413 disabled, extension_controlled); 1426 disabled, extension_controlled);
1414 1427
1415 #endif // !defined(OS_CHROMEOS) 1428 #endif // !defined(OS_CHROMEOS)
1416 } 1429 }
1417 1430
1418 } // namespace options 1431 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698