OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/preferences_window_controller.h" | 5 #import "chrome/browser/cocoa/preferences_window_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/l10n_util_mac.h" | 10 #include "app/l10n_util_mac.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 - (void)registerPrefObservers; | 327 - (void)registerPrefObservers; |
328 - (void)unregisterPrefObservers; | 328 - (void)unregisterPrefObservers; |
329 | 329 |
330 - (void)customHomePagesChanged; | 330 - (void)customHomePagesChanged; |
331 | 331 |
332 // KVC setter methods. | 332 // KVC setter methods. |
333 - (void)setNewTabPageIsHomePageIndex:(NSInteger)val; | 333 - (void)setNewTabPageIsHomePageIndex:(NSInteger)val; |
334 - (void)setHomepageURL:(NSString*)urlString; | 334 - (void)setHomepageURL:(NSString*)urlString; |
335 - (void)setRestoreOnStartupIndex:(NSInteger)type; | 335 - (void)setRestoreOnStartupIndex:(NSInteger)type; |
336 - (void)setShowHomeButton:(BOOL)value; | 336 - (void)setShowHomeButton:(BOOL)value; |
337 - (void)setShowPageOptionsButtons:(BOOL)value; | |
338 - (void)setPasswordManagerEnabledIndex:(NSInteger)value; | 337 - (void)setPasswordManagerEnabledIndex:(NSInteger)value; |
339 - (void)setFormAutofillEnabledIndex:(NSInteger)value; | 338 - (void)setFormAutofillEnabledIndex:(NSInteger)value; |
340 - (void)setIsUsingDefaultTheme:(BOOL)value; | 339 - (void)setIsUsingDefaultTheme:(BOOL)value; |
341 - (void)setShowAlternateErrorPages:(BOOL)value; | 340 - (void)setShowAlternateErrorPages:(BOOL)value; |
342 - (void)setUseSuggest:(BOOL)value; | 341 - (void)setUseSuggest:(BOOL)value; |
343 - (void)setDnsPrefetch:(BOOL)value; | 342 - (void)setDnsPrefetch:(BOOL)value; |
344 - (void)setSafeBrowsing:(BOOL)value; | 343 - (void)setSafeBrowsing:(BOOL)value; |
345 - (void)setMetricsRecording:(BOOL)value; | 344 - (void)setMetricsRecording:(BOOL)value; |
346 - (void)setAskForSaveLocation:(BOOL)value; | 345 - (void)setAskForSaveLocation:(BOOL)value; |
347 - (void)setFileHandlerUIEnabled:(BOOL)value; | 346 - (void)setFileHandlerUIEnabled:(BOOL)value; |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 - (void)registerPrefObservers { | 687 - (void)registerPrefObservers { |
689 if (!prefs_) return; | 688 if (!prefs_) return; |
690 | 689 |
691 // Basics panel | 690 // Basics panel |
692 prefs_->AddPrefObserver(prefs::kURLsToRestoreOnStartup, observer_.get()); | 691 prefs_->AddPrefObserver(prefs::kURLsToRestoreOnStartup, observer_.get()); |
693 restoreOnStartup_.Init(prefs::kRestoreOnStartup, prefs_, observer_.get()); | 692 restoreOnStartup_.Init(prefs::kRestoreOnStartup, prefs_, observer_.get()); |
694 newTabPageIsHomePage_.Init(prefs::kHomePageIsNewTabPage, | 693 newTabPageIsHomePage_.Init(prefs::kHomePageIsNewTabPage, |
695 prefs_, observer_.get()); | 694 prefs_, observer_.get()); |
696 homepage_.Init(prefs::kHomePage, prefs_, observer_.get()); | 695 homepage_.Init(prefs::kHomePage, prefs_, observer_.get()); |
697 showHomeButton_.Init(prefs::kShowHomeButton, prefs_, observer_.get()); | 696 showHomeButton_.Init(prefs::kShowHomeButton, prefs_, observer_.get()); |
698 showPageOptionButtons_.Init(prefs::kShowPageOptionsButtons, prefs_, | |
699 observer_.get()); | |
700 | 697 |
701 // Personal Stuff panel | 698 // Personal Stuff panel |
702 askSavePasswords_.Init(prefs::kPasswordManagerEnabled, | 699 askSavePasswords_.Init(prefs::kPasswordManagerEnabled, |
703 prefs_, observer_.get()); | 700 prefs_, observer_.get()); |
704 formAutofill_.Init(prefs::kAutoFillEnabled, prefs_, observer_.get()); | 701 formAutofill_.Init(prefs::kAutoFillEnabled, prefs_, observer_.get()); |
705 currentTheme_.Init(prefs::kCurrentThemeID, prefs_, observer_.get()); | 702 currentTheme_.Init(prefs::kCurrentThemeID, prefs_, observer_.get()); |
706 | 703 |
707 // Under the hood panel | 704 // Under the hood panel |
708 alternateErrorPages_.Init(prefs::kAlternateErrorPagesEnabled, | 705 alternateErrorPages_.Init(prefs::kAlternateErrorPagesEnabled, |
709 prefs_, observer_.get()); | 706 prefs_, observer_.get()); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 [self setNewTabPageIsHomePageIndex:useNewTabPage]; | 860 [self setNewTabPageIsHomePageIndex:useNewTabPage]; |
864 } | 861 } |
865 if (*prefName == prefs::kHomePage) { | 862 if (*prefName == prefs::kHomePage) { |
866 NSString* value = base::SysWideToNSString(homepage_.GetValue()); | 863 NSString* value = base::SysWideToNSString(homepage_.GetValue()); |
867 [self setHomepageURL:value]; | 864 [self setHomepageURL:value]; |
868 } | 865 } |
869 | 866 |
870 if (*prefName == prefs::kShowHomeButton) { | 867 if (*prefName == prefs::kShowHomeButton) { |
871 [self setShowHomeButton:showHomeButton_.GetValue() ? YES : NO]; | 868 [self setShowHomeButton:showHomeButton_.GetValue() ? YES : NO]; |
872 } | 869 } |
873 if (*prefName == prefs::kShowPageOptionsButtons) { | |
874 [self setShowPageOptionsButtons:showPageOptionButtons_.GetValue() ? | |
875 YES : NO]; | |
876 } | |
877 } | 870 } |
878 | 871 |
879 // Returns the index of the selected cell in the "on startup" matrix based | 872 // Returns the index of the selected cell in the "on startup" matrix based |
880 // on the "restore on startup" pref. The ordering of the cells is in the | 873 // on the "restore on startup" pref. The ordering of the cells is in the |
881 // same order as the pref. | 874 // same order as the pref. |
882 - (NSInteger)restoreOnStartupIndex { | 875 - (NSInteger)restoreOnStartupIndex { |
883 const SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs_); | 876 const SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs_); |
884 return pref.type; | 877 return pref.type; |
885 } | 878 } |
886 | 879 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 - (void)setShowHomeButton:(BOOL)value { | 1047 - (void)setShowHomeButton:(BOOL)value { |
1055 if (value) | 1048 if (value) |
1056 [self recordUserAction:UserMetricsAction( | 1049 [self recordUserAction:UserMetricsAction( |
1057 "Options_Homepage_ShowHomeButton")]; | 1050 "Options_Homepage_ShowHomeButton")]; |
1058 else | 1051 else |
1059 [self recordUserAction:UserMetricsAction( | 1052 [self recordUserAction:UserMetricsAction( |
1060 "Options_Homepage_HideHomeButton")]; | 1053 "Options_Homepage_HideHomeButton")]; |
1061 showHomeButton_.SetValue(value ? true : false); | 1054 showHomeButton_.SetValue(value ? true : false); |
1062 } | 1055 } |
1063 | 1056 |
1064 // Returns whether the page and options button should be checked based on the | |
1065 // preference. | |
1066 - (BOOL)showPageOptionsButtons { | |
1067 return showPageOptionButtons_.GetValue() ? YES : NO; | |
1068 } | |
1069 | |
1070 // Sets the backend pref for whether or not the page and options buttons should | |
1071 // be displayed based on |value|. | |
1072 - (void)setShowPageOptionsButtons:(BOOL)value { | |
1073 if (value) | |
1074 [self recordUserAction:UserMetricsAction( | |
1075 "Options_Homepage_ShowPageOptionsButtons")]; | |
1076 else | |
1077 [self recordUserAction:UserMetricsAction( | |
1078 "Options_Homepage_HidePageOptionsButtons")]; | |
1079 showPageOptionButtons_.SetValue(value ? true : false); | |
1080 } | |
1081 | |
1082 // Getter for the |searchEngineModel| property for bindings. | 1057 // Getter for the |searchEngineModel| property for bindings. |
1083 - (id)searchEngineModel { | 1058 - (id)searchEngineModel { |
1084 return searchEngineModel_.get(); | 1059 return searchEngineModel_.get(); |
1085 } | 1060 } |
1086 | 1061 |
1087 // Bindings for the search engine popup. We not binding directly to the model | 1062 // Bindings for the search engine popup. We not binding directly to the model |
1088 // in order to siphon off the setter so we can record the metric. If we're | 1063 // in order to siphon off the setter so we can record the metric. If we're |
1089 // doing it with one, might as well do it with both. | 1064 // doing it with one, might as well do it with both. |
1090 - (NSUInteger)searchEngineSelectedIndex { | 1065 - (NSUInteger)searchEngineSelectedIndex { |
1091 return [searchEngineModel_ defaultIndex]; | 1066 return [searchEngineModel_ defaultIndex]; |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 case OPTIONS_PAGE_ADVANCED: | 1954 case OPTIONS_PAGE_ADVANCED: |
1980 return underTheHoodView_; | 1955 return underTheHoodView_; |
1981 case OPTIONS_PAGE_DEFAULT: | 1956 case OPTIONS_PAGE_DEFAULT: |
1982 case OPTIONS_PAGE_COUNT: | 1957 case OPTIONS_PAGE_COUNT: |
1983 LOG(DFATAL) << "Invalid page value " << page; | 1958 LOG(DFATAL) << "Invalid page value " << page; |
1984 } | 1959 } |
1985 return basicsView_; | 1960 return basicsView_; |
1986 } | 1961 } |
1987 | 1962 |
1988 @end | 1963 @end |
OLD | NEW |