| 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, | 794 &BrowserOptionsHandler::HandleRefreshExtensionControlIndicators, |
| 795 base::Unretained(this))); | 795 base::Unretained(this))); |
| 796 #endif // defined(OS_WIN) | 796 #endif // defined(OS_WIN) |
| 797 web_ui()->RegisterMessageCallback("metricsReportingCheckboxChanged", | 797 web_ui()->RegisterMessageCallback("metricsReportingCheckboxChanged", |
| 798 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingChange, | 798 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingChange, |
| 799 base::Unretained(this))); | 799 base::Unretained(this))); |
| 800 } | 800 } |
| 801 | 801 |
| 802 void BrowserOptionsHandler::Uninitialize() { | 802 void BrowserOptionsHandler::Uninitialize() { |
| 803 registrar_.RemoveAll(); | 803 registrar_.RemoveAll(); |
| 804 g_browser_process->profile_manager()-> |
| 805 GetProfileInfoCache().RemoveObserver(this); |
| 804 #if defined(OS_WIN) | 806 #if defined(OS_WIN) |
| 805 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); | 807 ExtensionRegistry::Get(Profile::FromWebUI(web_ui()))->RemoveObserver(this); |
| 806 #endif | 808 #endif |
| 807 #if defined(OS_CHROMEOS) | 809 #if defined(OS_CHROMEOS) |
| 808 policy::ConsumerManagementService* consumer_management = | 810 policy::ConsumerManagementService* consumer_management = |
| 809 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> | 811 g_browser_process->platform_part()->browser_policy_connector_chromeos()-> |
| 810 GetConsumerManagementService(); | 812 GetConsumerManagementService(); |
| 811 if (consumer_management) | 813 if (consumer_management) |
| 812 consumer_management->RemoveObserver(this); | 814 consumer_management->RemoveObserver(this); |
| 813 #endif | 815 #endif |
| (...skipping 30 matching lines...) Expand all Loading... |
| 844 if (zoom_level_prefs) { | 846 if (zoom_level_prefs) { |
| 845 default_zoom_level_subscription_ = | 847 default_zoom_level_subscription_ = |
| 846 zoom_level_prefs->RegisterDefaultZoomLevelCallback( | 848 zoom_level_prefs->RegisterDefaultZoomLevelCallback( |
| 847 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, | 849 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, |
| 848 base::Unretained(this))); | 850 base::Unretained(this))); |
| 849 } | 851 } |
| 850 | 852 |
| 851 g_browser_process->policy_service()->AddObserver( | 853 g_browser_process->policy_service()->AddObserver( |
| 852 policy::POLICY_DOMAIN_CHROME, this); | 854 policy::POLICY_DOMAIN_CHROME, this); |
| 853 | 855 |
| 856 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); |
| 857 |
| 854 ProfileSyncService* sync_service( | 858 ProfileSyncService* sync_service( |
| 855 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 859 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
| 856 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on | 860 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on |
| 857 // destruction is automatic. | 861 // destruction is automatic. |
| 858 if (sync_service) | 862 if (sync_service) |
| 859 sync_service->AddObserver(this); | 863 sync_service->AddObserver(this); |
| 860 | 864 |
| 861 SigninManagerBase* signin_manager( | 865 SigninManagerBase* signin_manager( |
| 862 SigninManagerFactory::GetInstance()->GetForProfile(profile)); | 866 SigninManagerFactory::GetInstance()->GetForProfile(profile)); |
| 863 if (signin_manager) | 867 if (signin_manager) |
| 864 signin_observer_.Add(signin_manager); | 868 signin_observer_.Add(signin_manager); |
| 865 | 869 |
| 866 // Create our favicon data source. | 870 // Create our favicon data source. |
| 867 content::URLDataSource::Add( | 871 content::URLDataSource::Add( |
| 868 profile, new FaviconSource(profile, FaviconSource::FAVICON)); | 872 profile, new FaviconSource(profile, FaviconSource::FAVICON)); |
| 869 | 873 |
| 870 default_browser_policy_.Init( | 874 default_browser_policy_.Init( |
| 871 prefs::kDefaultBrowserSettingEnabled, | 875 prefs::kDefaultBrowserSettingEnabled, |
| 872 g_browser_process->local_state(), | 876 g_browser_process->local_state(), |
| 873 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState, | 877 base::Bind(&BrowserOptionsHandler::UpdateDefaultBrowserState, |
| 874 base::Unretained(this))); | 878 base::Unretained(this))); |
| 875 | 879 |
| 876 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | |
| 877 content::NotificationService::AllSources()); | |
| 878 #if defined(OS_CHROMEOS) | 880 #if defined(OS_CHROMEOS) |
| 879 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 881 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
| 880 content::NotificationService::AllSources()); | 882 content::NotificationService::AllSources()); |
| 881 #endif | 883 #endif |
| 882 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 884 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 883 content::Source<ThemeService>( | 885 content::Source<ThemeService>( |
| 884 ThemeServiceFactory::GetForProfile(profile))); | 886 ThemeServiceFactory::GetForProfile(profile))); |
| 885 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, | 887 registrar_.Add(this, chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED, |
| 886 content::Source<Profile>(profile)); | 888 content::Source<Profile>(profile)); |
| 887 AddTemplateUrlServiceObserver(); | 889 AddTemplateUrlServiceObserver(); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 | 1265 |
| 1264 switch (type) { | 1266 switch (type) { |
| 1265 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: | 1267 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: |
| 1266 ObserveThemeChanged(); | 1268 ObserveThemeChanged(); |
| 1267 break; | 1269 break; |
| 1268 #if defined(OS_CHROMEOS) | 1270 #if defined(OS_CHROMEOS) |
| 1269 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: | 1271 case chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED: |
| 1270 UpdateAccountPicture(); | 1272 UpdateAccountPicture(); |
| 1271 break; | 1273 break; |
| 1272 #endif | 1274 #endif |
| 1273 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | |
| 1274 SendProfilesInfo(); | |
| 1275 break; | |
| 1276 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: | 1275 case chrome::NOTIFICATION_GLOBAL_ERRORS_CHANGED: |
| 1277 // Update our sync/signin status display. | 1276 // Update our sync/signin status display. |
| 1278 OnStateChanged(); | 1277 OnStateChanged(); |
| 1279 break; | 1278 break; |
| 1280 default: | 1279 default: |
| 1281 NOTREACHED(); | 1280 NOTREACHED(); |
| 1282 } | 1281 } |
| 1283 } | 1282 } |
| 1284 | 1283 |
| 1284 void BrowserOptionsHandler::OnProfileAdded(const base::FilePath& profile_path) { |
| 1285 SendProfilesInfo(); |
| 1286 } |
| 1287 |
| 1288 void BrowserOptionsHandler::OnProfileWasRemoved( |
| 1289 const base::FilePath& profile_path, |
| 1290 const base::string16& profile_name) { |
| 1291 SendProfilesInfo(); |
| 1292 } |
| 1293 |
| 1294 void BrowserOptionsHandler::OnProfileNameChanged( |
| 1295 const base::FilePath& profile_path, |
| 1296 const base::string16& old_profile_name) { |
| 1297 SendProfilesInfo(); |
| 1298 } |
| 1299 |
| 1300 void BrowserOptionsHandler::OnProfileAvatarChanged( |
| 1301 const base::FilePath& profile_path) { |
| 1302 SendProfilesInfo(); |
| 1303 } |
| 1304 |
| 1285 void BrowserOptionsHandler::ToggleAutoLaunch(const base::ListValue* args) { | 1305 void BrowserOptionsHandler::ToggleAutoLaunch(const base::ListValue* args) { |
| 1286 #if defined(OS_WIN) | 1306 #if defined(OS_WIN) |
| 1287 if (!auto_launch_trial::IsInAutoLaunchGroup()) | 1307 if (!auto_launch_trial::IsInAutoLaunchGroup()) |
| 1288 return; | 1308 return; |
| 1289 | 1309 |
| 1290 bool enable; | 1310 bool enable; |
| 1291 CHECK_EQ(args->GetSize(), 1U); | 1311 CHECK_EQ(args->GetSize(), 1U); |
| 1292 CHECK(args->GetBoolean(0, &enable)); | 1312 CHECK(args->GetBoolean(0, &enable)); |
| 1293 | 1313 |
| 1294 Profile* profile = Profile::FromWebUI(web_ui()); | 1314 Profile* profile = Profile::FromWebUI(web_ui()); |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2117 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 2137 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, |
| 2118 const policy::PolicyMap& previous, | 2138 const policy::PolicyMap& previous, |
| 2119 const policy::PolicyMap& current) { | 2139 const policy::PolicyMap& current) { |
| 2120 std::set<std::string> different_keys; | 2140 std::set<std::string> different_keys; |
| 2121 current.GetDifferingKeys(previous, &different_keys); | 2141 current.GetDifferingKeys(previous, &different_keys); |
| 2122 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) | 2142 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) |
| 2123 SetupMetricsReportingCheckbox(); | 2143 SetupMetricsReportingCheckbox(); |
| 2124 } | 2144 } |
| 2125 | 2145 |
| 2126 } // namespace options | 2146 } // namespace options |
| OLD | NEW |