| 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 "apps/app_window.h" | 10 #include "apps/app_window.h" |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 OnStateChanged(); | 785 OnStateChanged(); |
| 786 } | 786 } |
| 787 | 787 |
| 788 void BrowserOptionsHandler::PageLoadStarted() { | 788 void BrowserOptionsHandler::PageLoadStarted() { |
| 789 page_initialized_ = false; | 789 page_initialized_ = false; |
| 790 } | 790 } |
| 791 | 791 |
| 792 void BrowserOptionsHandler::InitializeHandler() { | 792 void BrowserOptionsHandler::InitializeHandler() { |
| 793 Profile* profile = Profile::FromWebUI(web_ui()); | 793 Profile* profile = Profile::FromWebUI(web_ui()); |
| 794 PrefService* prefs = profile->GetPrefs(); | 794 PrefService* prefs = profile->GetPrefs(); |
| 795 PrefService* zoom_level_prefs = profile->GetZoomLevelPrefs(); |
| 796 DCHECK(zoom_level_prefs); |
| 795 | 797 |
| 796 ProfileSyncService* sync_service( | 798 ProfileSyncService* sync_service( |
| 797 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 799 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
| 798 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on | 800 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on |
| 799 // destruction is automatic. | 801 // destruction is automatic. |
| 800 if (sync_service) | 802 if (sync_service) |
| 801 sync_service->AddObserver(this); | 803 sync_service->AddObserver(this); |
| 802 | 804 |
| 803 SigninManagerBase* signin_manager( | 805 SigninManagerBase* signin_manager( |
| 804 SigninManagerFactory::GetInstance()->GetForProfile(profile)); | 806 SigninManagerFactory::GetInstance()->GetForProfile(profile)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 | 844 |
| 843 // No preferences below this point may be modified by guest profiles. | 845 // No preferences below this point may be modified by guest profiles. |
| 844 if (Profile::FromWebUI(web_ui())->IsGuestSession()) | 846 if (Profile::FromWebUI(web_ui())->IsGuestSession()) |
| 845 return; | 847 return; |
| 846 | 848 |
| 847 auto_open_files_.Init( | 849 auto_open_files_.Init( |
| 848 prefs::kDownloadExtensionsToOpen, prefs, | 850 prefs::kDownloadExtensionsToOpen, prefs, |
| 849 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, | 851 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, |
| 850 base::Unretained(this))); | 852 base::Unretained(this))); |
| 851 default_zoom_level_.Init( | 853 default_zoom_level_.Init( |
| 852 prefs::kDefaultZoomLevel, prefs, | 854 prefs::kDefaultZoomLevel, |
| 855 zoom_level_prefs, |
| 853 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, | 856 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, |
| 854 base::Unretained(this))); | 857 base::Unretained(this))); |
| 855 profile_pref_registrar_.Init(prefs); | 858 profile_pref_registrar_.Init(prefs); |
| 856 profile_pref_registrar_.Add( | 859 profile_pref_registrar_.Add( |
| 857 prefs::kNetworkPredictionOptions, | 860 prefs::kNetworkPredictionOptions, |
| 858 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl, | 861 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl, |
| 859 base::Unretained(this))); | 862 base::Unretained(this))); |
| 860 profile_pref_registrar_.Add( | 863 profile_pref_registrar_.Add( |
| 861 prefs::kWebKitDefaultFontSize, | 864 prefs::kWebKitDefaultFontSize, |
| 862 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, | 865 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 dict.SetString("controlledBy", "policy"); | 1710 dict.SetString("controlledBy", "policy"); |
| 1708 } else if (default_font_size->IsExtensionControlled() || | 1711 } else if (default_font_size->IsExtensionControlled() || |
| 1709 default_fixed_font_size->IsExtensionControlled()) { | 1712 default_fixed_font_size->IsExtensionControlled()) { |
| 1710 dict.SetString("controlledBy", "extension"); | 1713 dict.SetString("controlledBy", "extension"); |
| 1711 } | 1714 } |
| 1712 | 1715 |
| 1713 web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", dict); | 1716 web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", dict); |
| 1714 } | 1717 } |
| 1715 | 1718 |
| 1716 void BrowserOptionsHandler::SetupPageZoomSelector() { | 1719 void BrowserOptionsHandler::SetupPageZoomSelector() { |
| 1717 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1720 double default_zoom_level = |
| 1718 double default_zoom_level = pref_service->GetDouble(prefs::kDefaultZoomLevel); | 1721 Profile::FromWebUI(web_ui())->GetDefaultZoomLevel(); |
| 1719 double default_zoom_factor = | 1722 double default_zoom_factor = |
| 1720 content::ZoomLevelToZoomFactor(default_zoom_level); | 1723 content::ZoomLevelToZoomFactor(default_zoom_level); |
| 1721 | 1724 |
| 1722 // Generate a vector of zoom factors from an array of known presets along with | 1725 // Generate a vector of zoom factors from an array of known presets along with |
| 1723 // the default factor added if necessary. | 1726 // the default factor added if necessary. |
| 1724 std::vector<double> zoom_factors = | 1727 std::vector<double> zoom_factors = |
| 1725 chrome_page_zoom::PresetZoomFactors(default_zoom_factor); | 1728 chrome_page_zoom::PresetZoomFactors(default_zoom_factor); |
| 1726 | 1729 |
| 1727 // Iterate through the zoom factors and and build the contents of the | 1730 // Iterate through the zoom factors and and build the contents of the |
| 1728 // selector that will be sent to the javascript handler. | 1731 // selector that will be sent to the javascript handler. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 extension = extensions::GetExtensionOverridingProxy( | 1867 extension = extensions::GetExtensionOverridingProxy( |
| 1865 Profile::FromWebUI(web_ui())); | 1868 Profile::FromWebUI(web_ui())); |
| 1866 AppendExtensionData("proxy", extension, &extension_controlled); | 1869 AppendExtensionData("proxy", extension, &extension_controlled); |
| 1867 | 1870 |
| 1868 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", | 1871 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", |
| 1869 extension_controlled); | 1872 extension_controlled); |
| 1870 #endif // defined(OS_WIN) | 1873 #endif // defined(OS_WIN) |
| 1871 } | 1874 } |
| 1872 | 1875 |
| 1873 } // namespace options | 1876 } // namespace options |
| OLD | NEW |