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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "chrome/browser/sync/profile_sync_service.h" | 53 #include "chrome/browser/sync/profile_sync_service.h" |
54 #include "chrome/browser/sync/profile_sync_service_factory.h" | 54 #include "chrome/browser/sync/profile_sync_service_factory.h" |
55 #include "chrome/browser/sync/sync_ui_util.h" | 55 #include "chrome/browser/sync/sync_ui_util.h" |
56 #include "chrome/browser/themes/theme_service.h" | 56 #include "chrome/browser/themes/theme_service.h" |
57 #include "chrome/browser/themes/theme_service_factory.h" | 57 #include "chrome/browser/themes/theme_service_factory.h" |
58 #include "chrome/browser/ui/browser_finder.h" | 58 #include "chrome/browser/ui/browser_finder.h" |
59 #include "chrome/browser/ui/chrome_select_file_policy.h" | 59 #include "chrome/browser/ui/chrome_select_file_policy.h" |
60 #include "chrome/browser/ui/host_desktop.h" | 60 #include "chrome/browser/ui/host_desktop.h" |
61 #include "chrome/browser/ui/webui/favicon_source.h" | 61 #include "chrome/browser/ui/webui/favicon_source.h" |
62 #include "chrome/browser/ui/webui/options/options_handlers_helper.h" | 62 #include "chrome/browser/ui/webui/options/options_handlers_helper.h" |
| 63 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
63 #include "chrome/common/chrome_constants.h" | 64 #include "chrome/common/chrome_constants.h" |
64 #include "chrome/common/chrome_paths.h" | 65 #include "chrome/common/chrome_paths.h" |
65 #include "chrome/common/chrome_switches.h" | 66 #include "chrome/common/chrome_switches.h" |
66 #include "chrome/common/extensions/extension_constants.h" | 67 #include "chrome/common/extensions/extension_constants.h" |
67 #include "chrome/common/pref_names.h" | 68 #include "chrome/common/pref_names.h" |
68 #include "chrome/common/url_constants.h" | 69 #include "chrome/common/url_constants.h" |
69 #include "chrome/grit/chromium_strings.h" | 70 #include "chrome/grit/chromium_strings.h" |
70 #include "chrome/grit/generated_resources.h" | 71 #include "chrome/grit/generated_resources.h" |
71 #include "chrome/grit/locale_settings.h" | 72 #include "chrome/grit/locale_settings.h" |
72 #include "chromeos/chromeos_switches.h" | 73 #include "chromeos/chromeos_switches.h" |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 OnStateChanged(); | 802 OnStateChanged(); |
802 } | 803 } |
803 | 804 |
804 void BrowserOptionsHandler::PageLoadStarted() { | 805 void BrowserOptionsHandler::PageLoadStarted() { |
805 page_initialized_ = false; | 806 page_initialized_ = false; |
806 } | 807 } |
807 | 808 |
808 void BrowserOptionsHandler::InitializeHandler() { | 809 void BrowserOptionsHandler::InitializeHandler() { |
809 Profile* profile = Profile::FromWebUI(web_ui()); | 810 Profile* profile = Profile::FromWebUI(web_ui()); |
810 PrefService* prefs = profile->GetPrefs(); | 811 PrefService* prefs = profile->GetPrefs(); |
| 812 chrome::ChromeZoomLevelPrefs* zoom_level_prefs = profile->GetZoomLevelPrefs(); |
| 813 DCHECK(zoom_level_prefs); |
811 | 814 |
812 ProfileSyncService* sync_service( | 815 ProfileSyncService* sync_service( |
813 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); | 816 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
814 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on | 817 // TODO(blundell): Use a ScopedObserver to observe the PSS so that cleanup on |
815 // destruction is automatic. | 818 // destruction is automatic. |
816 if (sync_service) | 819 if (sync_service) |
817 sync_service->AddObserver(this); | 820 sync_service->AddObserver(this); |
818 | 821 |
819 SigninManagerBase* signin_manager( | 822 SigninManagerBase* signin_manager( |
820 SigninManagerFactory::GetInstance()->GetForProfile(profile)); | 823 SigninManagerFactory::GetInstance()->GetForProfile(profile)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 861 |
859 // No preferences below this point may be modified by guest profiles. | 862 // No preferences below this point may be modified by guest profiles. |
860 if (Profile::FromWebUI(web_ui())->IsGuestSession()) | 863 if (Profile::FromWebUI(web_ui())->IsGuestSession()) |
861 return; | 864 return; |
862 | 865 |
863 auto_open_files_.Init( | 866 auto_open_files_.Init( |
864 prefs::kDownloadExtensionsToOpen, prefs, | 867 prefs::kDownloadExtensionsToOpen, prefs, |
865 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, | 868 base::Bind(&BrowserOptionsHandler::SetupAutoOpenFileTypes, |
866 base::Unretained(this))); | 869 base::Unretained(this))); |
867 default_zoom_level_.Init( | 870 default_zoom_level_.Init( |
868 prefs::kDefaultZoomLevel, prefs, | 871 zoom_level_prefs->GetDefaultZoomLevelPath().c_str(), |
| 872 prefs, |
869 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, | 873 base::Bind(&BrowserOptionsHandler::SetupPageZoomSelector, |
870 base::Unretained(this))); | 874 base::Unretained(this))); |
871 profile_pref_registrar_.Init(prefs); | 875 profile_pref_registrar_.Init(prefs); |
872 profile_pref_registrar_.Add( | 876 profile_pref_registrar_.Add( |
873 prefs::kNetworkPredictionOptions, | 877 prefs::kNetworkPredictionOptions, |
874 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl, | 878 base::Bind(&BrowserOptionsHandler::SetupNetworkPredictionControl, |
875 base::Unretained(this))); | 879 base::Unretained(this))); |
876 profile_pref_registrar_.Add( | 880 profile_pref_registrar_.Add( |
877 prefs::kWebKitDefaultFontSize, | 881 prefs::kWebKitDefaultFontSize, |
878 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, | 882 base::Bind(&BrowserOptionsHandler::SetupFontSizeSelector, |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1531 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
1528 pref_service->SetInteger(prefs::kWebKitDefaultFontSize, font_size); | 1532 pref_service->SetInteger(prefs::kWebKitDefaultFontSize, font_size); |
1529 SetupFontSizeSelector(); | 1533 SetupFontSizeSelector(); |
1530 } | 1534 } |
1531 } | 1535 } |
1532 } | 1536 } |
1533 | 1537 |
1534 void BrowserOptionsHandler::HandleDefaultZoomFactor( | 1538 void BrowserOptionsHandler::HandleDefaultZoomFactor( |
1535 const base::ListValue* args) { | 1539 const base::ListValue* args) { |
1536 double zoom_factor; | 1540 double zoom_factor; |
1537 if (ExtractDoubleValue(args, &zoom_factor)) { | 1541 if (ExtractDoubleValue(args, &zoom_factor)) |
1538 default_zoom_level_.SetValue(content::ZoomFactorToZoomLevel(zoom_factor)); | 1542 default_zoom_level_.SetValue(content::ZoomFactorToZoomLevel(zoom_factor)); |
1539 } | |
1540 } | 1543 } |
1541 | 1544 |
1542 void BrowserOptionsHandler::HandleRestartBrowser(const base::ListValue* args) { | 1545 void BrowserOptionsHandler::HandleRestartBrowser(const base::ListValue* args) { |
1543 #if defined(OS_WIN) && defined(USE_ASH) | 1546 #if defined(OS_WIN) && defined(USE_ASH) |
1544 // If hardware acceleration is disabled then we need to force restart | 1547 // If hardware acceleration is disabled then we need to force restart |
1545 // browser in desktop mode. | 1548 // browser in desktop mode. |
1546 // TODO(shrikant): Remove this once we fix start mode logic for browser. | 1549 // TODO(shrikant): Remove this once we fix start mode logic for browser. |
1547 // Currently there are issues with determining correct browser mode | 1550 // Currently there are issues with determining correct browser mode |
1548 // at startup. | 1551 // at startup. |
1549 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) { | 1552 if (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH) { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1785 dict.SetString("controlledBy", "policy"); | 1788 dict.SetString("controlledBy", "policy"); |
1786 } else if (default_font_size->IsExtensionControlled() || | 1789 } else if (default_font_size->IsExtensionControlled() || |
1787 default_fixed_font_size->IsExtensionControlled()) { | 1790 default_fixed_font_size->IsExtensionControlled()) { |
1788 dict.SetString("controlledBy", "extension"); | 1791 dict.SetString("controlledBy", "extension"); |
1789 } | 1792 } |
1790 | 1793 |
1791 web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", dict); | 1794 web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", dict); |
1792 } | 1795 } |
1793 | 1796 |
1794 void BrowserOptionsHandler::SetupPageZoomSelector() { | 1797 void BrowserOptionsHandler::SetupPageZoomSelector() { |
1795 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1798 double default_zoom_level = |
1796 double default_zoom_level = pref_service->GetDouble(prefs::kDefaultZoomLevel); | 1799 content::HostZoomMap::GetDefaultForBrowserContext( |
| 1800 Profile::FromWebUI(web_ui()))->GetDefaultZoomLevel(); |
1797 double default_zoom_factor = | 1801 double default_zoom_factor = |
1798 content::ZoomLevelToZoomFactor(default_zoom_level); | 1802 content::ZoomLevelToZoomFactor(default_zoom_level); |
1799 | 1803 |
1800 // Generate a vector of zoom factors from an array of known presets along with | 1804 // Generate a vector of zoom factors from an array of known presets along with |
1801 // the default factor added if necessary. | 1805 // the default factor added if necessary. |
1802 std::vector<double> zoom_factors = | 1806 std::vector<double> zoom_factors = |
1803 chrome_page_zoom::PresetZoomFactors(default_zoom_factor); | 1807 chrome_page_zoom::PresetZoomFactors(default_zoom_factor); |
1804 | 1808 |
1805 // Iterate through the zoom factors and and build the contents of the | 1809 // Iterate through the zoom factors and and build the contents of the |
1806 // selector that will be sent to the javascript handler. | 1810 // selector that will be sent to the javascript handler. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1976 | 1980 |
1977 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, | 1981 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, |
1978 bool disabled) { | 1982 bool disabled) { |
1979 web_ui()->CallJavascriptFunction( | 1983 web_ui()->CallJavascriptFunction( |
1980 "BrowserOptions.setMetricsReportingCheckboxState", | 1984 "BrowserOptions.setMetricsReportingCheckboxState", |
1981 base::FundamentalValue(checked), | 1985 base::FundamentalValue(checked), |
1982 base::FundamentalValue(disabled)); | 1986 base::FundamentalValue(disabled)); |
1983 } | 1987 } |
1984 | 1988 |
1985 } // namespace options | 1989 } // namespace options |
OLD | NEW |