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

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: Address review comments and rebase to ToT. 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 cloud_print_connector_ui_enabled_ = true; 144 cloud_print_connector_ui_enabled_ = true;
145 #endif 145 #endif
146 } 146 }
147 147
148 BrowserOptionsHandler::~BrowserOptionsHandler() { 148 BrowserOptionsHandler::~BrowserOptionsHandler() {
149 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: 149 ProfileSyncService* sync_service(ProfileSyncServiceFactory::
150 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); 150 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui())));
151 if (sync_service) 151 if (sync_service)
152 sync_service->RemoveObserver(this); 152 sync_service->RemoveObserver(this);
153 153
154 profile_pref_registrar_.RemoveAll();
Dan Beam 2013/02/25 17:35:08 also may not be necessary.
154 if (default_browser_worker_.get()) 155 if (default_browser_worker_.get())
155 default_browser_worker_->ObserverDestroyed(); 156 default_browser_worker_->ObserverDestroyed();
156 if (template_url_service_) 157 if (template_url_service_)
157 template_url_service_->RemoveObserver(this); 158 template_url_service_->RemoveObserver(this);
158 // There may be pending file dialogs, we need to tell them that we've gone 159 // There may be pending file dialogs, we need to tell them that we've gone
159 // away so they don't try and call back to us. 160 // away so they don't try and call back to us.
160 if (select_folder_dialog_.get()) 161 if (select_folder_dialog_.get())
161 select_folder_dialog_->ListenerDestroyed(); 162 select_folder_dialog_->ListenerDestroyed();
162 } 163 }
163 164
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 #endif 598 #endif
598 } 599 }
599 600
600 void BrowserOptionsHandler::OnStateChanged() { 601 void BrowserOptionsHandler::OnStateChanged() {
601 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", 602 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState",
602 *GetSyncStateDictionary()); 603 *GetSyncStateDictionary());
603 604
604 SendProfilesInfo(); 605 SendProfilesInfo();
605 } 606 }
606 607
608 void BrowserOptionsHandler::OnSigninAllowedPrefChange() {
609 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState",
610 *GetSyncStateDictionary());
611
612 SendProfilesInfo();
613 }
614
607 void BrowserOptionsHandler::PageLoadStarted() { 615 void BrowserOptionsHandler::PageLoadStarted() {
608 page_initialized_ = false; 616 page_initialized_ = false;
609 } 617 }
610 618
611 void BrowserOptionsHandler::InitializeHandler() { 619 void BrowserOptionsHandler::InitializeHandler() {
612 Profile* profile = Profile::FromWebUI(web_ui()); 620 Profile* profile = Profile::FromWebUI(web_ui());
613 PrefService* prefs = profile->GetPrefs(); 621 PrefService* prefs = profile->GetPrefs();
614 622
615 ProfileSyncService* sync_service( 623 ProfileSyncService* sync_service(
616 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); 624 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, 675 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes,
668 base::Unretained(this))); 676 base::Unretained(this)));
669 default_font_size_.Init( 677 default_font_size_.Init(
670 prefs::kWebKitDefaultFontSize, prefs, 678 prefs::kWebKitDefaultFontSize, prefs,
671 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, 679 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector,
672 base::Unretained(this))); 680 base::Unretained(this)));
673 default_zoom_level_.Init( 681 default_zoom_level_.Init(
674 prefs::kDefaultZoomLevel, prefs, 682 prefs::kDefaultZoomLevel, prefs,
675 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, 683 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector,
676 base::Unretained(this))); 684 base::Unretained(this)));
685 profile_pref_registrar_.Init(prefs);
686 profile_pref_registrar_.Add(
687 prefs::kSigninAllowed,
688 base::Bind(&BrowserOptionsHandler::OnSigninAllowedPrefChange,
689 base::Unretained(this)));
677 #if !defined(OS_CHROMEOS) 690 #if !defined(OS_CHROMEOS)
678 proxy_prefs_.Init(prefs); 691 profile_pref_registrar_.Add(
679 proxy_prefs_.Add(prefs::kProxy, 692 prefs::kProxy,
680 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection, 693 base::Bind(&BrowserOptionsHandler::SetupProxySettingsSection,
681 base::Unretained(this))); 694 base::Unretained(this)));
682 #endif // !defined(OS_CHROMEOS) 695 #endif // !defined(OS_CHROMEOS)
683 } 696 }
684 697
685 void BrowserOptionsHandler::InitializePage() { 698 void BrowserOptionsHandler::InitializePage() {
686 page_initialized_ = true; 699 page_initialized_ = true;
687 OnTemplateURLServiceChanged(); 700 OnTemplateURLServiceChanged();
688 ObserveThemeChanged(); 701 ObserveThemeChanged();
689 OnStateChanged(); 702 OnStateChanged();
690 UpdateDefaultBrowserState(); 703 UpdateDefaultBrowserState();
691 704
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 base::StringValue email_value(email); 1109 base::StringValue email_value(email);
1097 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", 1110 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture",
1098 email_value); 1111 email_value);
1099 } 1112 }
1100 } 1113 }
1101 #endif 1114 #endif
1102 1115
1103 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() { 1116 scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() {
1104 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue); 1117 scoped_ptr<DictionaryValue> sync_status(new DictionaryValue);
1105 Profile* profile = Profile::FromWebUI(web_ui()); 1118 Profile* profile = Profile::FromWebUI(web_ui());
1106 sync_status->SetBoolean("signinAllowed", !profile->IsGuestSession());
1107 if (profile->IsGuestSession()) { 1119 if (profile->IsGuestSession()) {
1108 // Cannot display signin status when running in guest mode on chromeos 1120 // Cannot display signin status when running in guest mode on chromeos
1109 // because there is no SigninManager. 1121 // because there is no SigninManager.
1122 sync_status->SetBoolean("signinAllowed", false);
1110 return sync_status.Pass(); 1123 return sync_status.Pass();
1111 } 1124 }
1112 1125
1113 // Signout is not allowed if the user has policy (crbug.com/172204). 1126 // Signout is not allowed if the user has policy (crbug.com/172204).
1114 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); 1127 SigninManager* signin = SigninManagerFactory::GetForProfile(profile);
1128 DCHECK(signin);
1115 sync_status->SetBoolean("signoutAllowed", !signin->IsSignoutProhibited()); 1129 sync_status->SetBoolean("signoutAllowed", !signin->IsSignoutProhibited());
1116 ProfileSyncService* service( 1130 ProfileSyncService* service(
1117 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); 1131 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile));
1132 sync_status->SetBoolean("signinAllowed", signin->IsSigninAllowed());
1118 sync_status->SetBoolean("syncSystemEnabled", !!service); 1133 sync_status->SetBoolean("syncSystemEnabled", !!service);
1119 sync_status->SetBoolean("setupCompleted", 1134 sync_status->SetBoolean("setupCompleted",
1120 service && service->HasSyncSetupCompleted()); 1135 service && service->HasSyncSetupCompleted());
1121 sync_status->SetBoolean("setupInProgress", 1136 sync_status->SetBoolean("setupInProgress",
1122 service && !service->IsManaged() && service->FirstSetupInProgress()); 1137 service && !service->IsManaged() && service->FirstSetupInProgress());
1123 1138
1124 string16 status_label; 1139 string16 status_label;
1125 string16 link_label; 1140 string16 link_label;
1126 DCHECK(signin); 1141 DCHECK(signin);
1127 bool status_has_error = sync_ui_util::GetStatusLabels( 1142 bool status_has_error = sync_ui_util::GetStatusLabels(
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 void BrowserOptionsHandler::SetupProxySettingsSection() { 1465 void BrowserOptionsHandler::SetupProxySettingsSection() {
1451 #if !defined(OS_CHROMEOS) 1466 #if !defined(OS_CHROMEOS)
1452 // Disable the button if proxy settings are managed by a sysadmin or 1467 // Disable the button if proxy settings are managed by a sysadmin or
1453 // overridden by an extension. 1468 // overridden by an extension.
1454 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 1469 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
1455 const PrefService::Preference* proxy_config = 1470 const PrefService::Preference* proxy_config =
1456 pref_service->FindPreference(prefs::kProxy); 1471 pref_service->FindPreference(prefs::kProxy);
1457 bool is_extension_controlled = (proxy_config && 1472 bool is_extension_controlled = (proxy_config &&
1458 proxy_config->IsExtensionControlled()); 1473 proxy_config->IsExtensionControlled());
1459 1474
1460 base::FundamentalValue disabled(proxy_prefs_.IsManaged() || 1475 base::FundamentalValue disabled(profile_pref_registrar_.IsManaged() ||
1461 is_extension_controlled); 1476 is_extension_controlled);
1462 base::FundamentalValue extension_controlled(is_extension_controlled); 1477 base::FundamentalValue extension_controlled(is_extension_controlled);
1463 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection", 1478 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsSection",
1464 disabled, extension_controlled); 1479 disabled, extension_controlled);
1465 1480
1466 #endif // !defined(OS_CHROMEOS) 1481 #endif // !defined(OS_CHROMEOS)
1467 } 1482 }
1468 1483
1469 } // namespace options 1484 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698