| 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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 OnStateChanged(); | 787 OnStateChanged(); |
| 788 } | 788 } |
| 789 | 789 |
| 790 void BrowserOptionsHandler::PageLoadStarted() { | 790 void BrowserOptionsHandler::PageLoadStarted() { |
| 791 page_initialized_ = false; | 791 page_initialized_ = false; |
| 792 } | 792 } |
| 793 | 793 |
| 794 void BrowserOptionsHandler::InitializeHandler() { | 794 void BrowserOptionsHandler::InitializeHandler() { |
| 795 Profile* profile = Profile::FromWebUI(web_ui()); | 795 Profile* profile = Profile::FromWebUI(web_ui()); |
| 796 PrefService* prefs = profile->GetPrefs(); | 796 PrefService* prefs = profile->GetPrefs(); |
| 797 PrefService* zoom_level_prefs = profile->GetZoomLevelPrefs(); |
| 798 DCHECK(zoom_level_prefs); |
| 797 | 799 |
| 798 ProfileSyncService* sync_service( | 800 ProfileSyncService* sync_service( |
| 799 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 801 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
| 800 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on | 802 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on |
| 801 // destruction is automatic. | 803 // destruction is automatic. |
| 802 if (sync_service) | 804 if (sync_service) |
| 803 sync_service->AddObserver(this); | 805 sync_service->AddObserver(this); |
| 804 | 806 |
| 805 SigninManagerBase* signin_manager( | 807 SigninManagerBase* signin_manager( |
| 806 SigninManagerFactory::GetInstance()->GetForProfile(profile)); | 808 SigninManagerFactory::GetInstance()->GetForProfile(profile)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 | 846 |
| 845 // No preferences below this point may be modified by guest profiles. | 847 // No preferences below this point may be modified by guest profiles. |
| 846 if (Profile::FromWebUI(web_ui())->IsGuestSession()) | 848 if (Profile::FromWebUI(web_ui())->IsGuestSession()) |
| 847 return; | 849 return; |
| 848 | 850 |
| 849 auto_open_files_.Init( | 851 auto_open_files_.Init( |
| 850 prefs::kDownloadExtensionsToOpen, prefs, | 852 prefs::kDownloadExtensionsToOpen, prefs, |
| 851 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, | 853 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, |
| 852 base::Unretained(this))); | 854 base::Unretained(this))); |
| 853 default_zoom_level_.Init( | 855 default_zoom_level_.Init( |
| 854 prefs::kDefaultZoomLevel, prefs, | 856 prefs::kDefaultZoomLevel, |
| 857 zoom_level_prefs, |
| 855 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, | 858 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, |
| 856 base::Unretained(this))); | 859 base::Unretained(this))); |
| 857 profile_pref_registrar_.Init(prefs); | 860 profile_pref_registrar_.Init(prefs); |
| 858 profile_pref_registrar_.Add( | 861 profile_pref_registrar_.Add( |
| 859 prefs::kNetworkPredictionOptions, | 862 prefs::kNetworkPredictionOptions, |
| 860 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl, | 863 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl, |
| 861 base::Unretained(this))); | 864 base::Unretained(this))); |
| 862 profile_pref_registrar_.Add( | 865 profile_pref_registrar_.Add( |
| 863 prefs::kWebKitDefaultFontSize, | 866 prefs::kWebKitDefaultFontSize, |
| 864 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, | 867 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 dict.SetString("controlledBy", "policy"); | 1727 dict.SetString("controlledBy", "policy"); |
| 1725 } else if (default_font_size->IsExtensionControlled() || | 1728 } else if (default_font_size->IsExtensionControlled() || |
| 1726 default_fixed_font_size->IsExtensionControlled()) { | 1729 default_fixed_font_size->IsExtensionControlled()) { |
| 1727 dict.SetString("controlledBy", "extension"); | 1730 dict.SetString("controlledBy", "extension"); |
| 1728 } | 1731 } |
| 1729 | 1732 |
| 1730 web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", dict); | 1733 web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", dict); |
| 1731 } | 1734 } |
| 1732 | 1735 |
| 1733 void BrowserOptionsHandler::SetupPageZoomSelector() { | 1736 void BrowserOptionsHandler::SetupPageZoomSelector() { |
| 1734 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1737 double default_zoom_level = |
| 1735 double default_zoom_level = pref_service->GetDouble(prefs::kDefaultZoomLevel); | 1738 content::HostZoomMap::GetDefaultForBrowserContext( |
| 1739 Profile::FromWebUI(web_ui()))->GetDefaultZoomLevel(); |
| 1736 double default_zoom_factor = | 1740 double default_zoom_factor = |
| 1737 content::ZoomLevelToZoomFactor(default_zoom_level); | 1741 content::ZoomLevelToZoomFactor(default_zoom_level); |
| 1738 | 1742 |
| 1739 // Generate a vector of zoom factors from an array of known presets along with | 1743 // Generate a vector of zoom factors from an array of known presets along with |
| 1740 // the default factor added if necessary. | 1744 // the default factor added if necessary. |
| 1741 std::vector<double> zoom_factors = | 1745 std::vector<double> zoom_factors = |
| 1742 chrome_page_zoom::PresetZoomFactors(default_zoom_factor); | 1746 chrome_page_zoom::PresetZoomFactors(default_zoom_factor); |
| 1743 | 1747 |
| 1744 // Iterate through the zoom factors and and build the contents of the | 1748 // Iterate through the zoom factors and and build the contents of the |
| 1745 // selector that will be sent to the javascript handler. | 1749 // selector that will be sent to the javascript handler. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 extension = extensions::GetExtensionOverridingProxy( | 1885 extension = extensions::GetExtensionOverridingProxy( |
| 1882 Profile::FromWebUI(web_ui())); | 1886 Profile::FromWebUI(web_ui())); |
| 1883 AppendExtensionData("proxy", extension, &extension_controlled); | 1887 AppendExtensionData("proxy", extension, &extension_controlled); |
| 1884 | 1888 |
| 1885 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", | 1889 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", |
| 1886 extension_controlled); | 1890 extension_controlled); |
| 1887 #endif // defined(OS_WIN) | 1891 #endif // defined(OS_WIN) |
| 1888 } | 1892 } |
| 1889 | 1893 |
| 1890 } // namespace options | 1894 } // namespace options |
| OLD | NEW |