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