OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #import <Cocoa/Cocoa.h> | |
6 | |
7 #include "base/scoped_ptr.h" | |
8 #include "base/scoped_nsobject.h" | |
9 #include "chrome/browser/prefs/pref_member.h" | |
10 #include "chrome/browser/prefs/pref_set_observer.h" | |
11 #include "chrome/browser/prefs/pref_change_registrar.h" | |
12 #include "chrome/browser/ui/options/options_window.h" | |
13 | |
14 namespace PreferencesWindowControllerInternal { | |
15 class PrefObserverBridge; | |
16 class ManagedPrefsBannerState; | |
17 } | |
18 | |
19 @class CustomHomePagesModel; | |
20 @class FontLanguageSettingsController; | |
21 class PrefService; | |
22 class Profile; | |
23 class ProfileSyncService; | |
24 @class SearchEngineListModel; | |
25 @class VerticalGradientView; | |
26 @class WindowSizeAutosaver; | |
27 | |
28 // A window controller that handles the preferences window. The bulk of the | |
29 // work is handled via Cocoa Bindings and getter/setter methods that wrap | |
30 // cross-platform PrefMember objects. When prefs change in the back-end | |
31 // (that is, outside of this UI), our observer receives a notification and can | |
32 // tickle the KVO to update the UI so we are always in sync. The bindings are | |
33 // specified in the nib file. Preferences are persisted into the back-end | |
34 // as they are changed in the UI, and are thus immediately available even while | |
35 // the window is still open. When the window closes, a notification is sent | |
36 // via the system NotificationCenter. This can be used as a signal to | |
37 // release this controller, as it's likely the client wants to enforce there | |
38 // only being one (we don't do that internally as it makes it very difficult | |
39 // to unit test). | |
40 @interface PreferencesWindowController : NSWindowController { | |
41 @private | |
42 Profile* profile_; // weak ref | |
43 OptionsPage initialPage_; | |
44 PrefService* prefs_; // weak ref - Obtained from profile_ for convenience. | |
45 // weak ref - Also obtained from profile_ for convenience. May be NULL. | |
46 ProfileSyncService* syncService_; | |
47 scoped_ptr<PreferencesWindowControllerInternal::PrefObserverBridge> | |
48 observer_; // Watches for pref changes. | |
49 PrefChangeRegistrar registrar_; // Manages pref change observer registration. | |
50 scoped_nsobject<WindowSizeAutosaver> sizeSaver_; | |
51 NSView* currentPrefsView_; // weak ref - current prefs page view. | |
52 scoped_ptr<PreferencesWindowControllerInternal::ManagedPrefsBannerState> | |
53 bannerState_; | |
54 BOOL managedPrefsBannerVisible_; | |
55 | |
56 IBOutlet NSToolbar* toolbar_; | |
57 IBOutlet VerticalGradientView* managedPrefsBannerView_; | |
58 IBOutlet NSImageView* managedPrefsBannerWarningImage_; | |
59 | |
60 // The views we'll rotate through | |
61 IBOutlet NSView* basicsView_; | |
62 IBOutlet NSView* personalStuffView_; | |
63 IBOutlet NSView* underTheHoodView_; | |
64 // The last page the user was on when they opened the Options window. | |
65 IntegerPrefMember lastSelectedPage_; | |
66 | |
67 // The groups of the Basics view for layout fixup. | |
68 IBOutlet NSArray* basicsGroupStartup_; | |
69 IBOutlet NSArray* basicsGroupHomePage_; | |
70 IBOutlet NSArray* basicsGroupToolbar_; | |
71 IBOutlet NSArray* basicsGroupSearchEngine_; | |
72 IBOutlet NSArray* basicsGroupDefaultBrowser_; | |
73 | |
74 // The groups of the Personal Stuff view for layout fixup. | |
75 IBOutlet NSArray* personalStuffGroupSync_; | |
76 IBOutlet NSArray* personalStuffGroupPasswords_; | |
77 IBOutlet NSArray* personalStuffGroupAutofill_; | |
78 IBOutlet NSArray* personalStuffGroupBrowserData_; | |
79 IBOutlet NSArray* personalStuffGroupThemes_; | |
80 | |
81 // Having two animations around is bad (they fight), so just use one. | |
82 scoped_nsobject<NSViewAnimation> animation_; | |
83 | |
84 IBOutlet NSArrayController* customPagesArrayController_; | |
85 | |
86 // Basics panel | |
87 IntegerPrefMember restoreOnStartup_; | |
88 scoped_nsobject<CustomHomePagesModel> customPagesSource_; | |
89 BooleanPrefMember newTabPageIsHomePage_; | |
90 StringPrefMember homepage_; | |
91 BooleanPrefMember showHomeButton_; | |
92 BooleanPrefMember instantEnabled_; | |
93 IBOutlet NSButton* instantCheckbox_; | |
94 scoped_nsobject<SearchEngineListModel> searchEngineModel_; | |
95 // Used when creating a new home page url to make the new cell editable. | |
96 BOOL pendingSelectForEdit_; | |
97 BOOL restoreButtonsEnabled_; | |
98 BOOL restoreURLsEnabled_; | |
99 BOOL showHomeButtonEnabled_; | |
100 BOOL defaultSearchEngineEnabled_; | |
101 | |
102 // User Data panel | |
103 BooleanPrefMember askSavePasswords_; | |
104 BooleanPrefMember autoFillEnabled_; | |
105 IBOutlet NSButton* autoFillSettingsButton_; | |
106 IBOutlet NSButton* syncButton_; | |
107 IBOutlet NSButton* syncCustomizeButton_; | |
108 IBOutlet NSTextField* syncStatus_; | |
109 IBOutlet NSButton* syncLink_; | |
110 IBOutlet NSButton* privacyDashboardLink_; | |
111 scoped_nsobject<NSColor> syncStatusNoErrorBackgroundColor_; | |
112 scoped_nsobject<NSColor> syncLinkNoErrorBackgroundColor_; | |
113 scoped_nsobject<NSColor> syncErrorBackgroundColor_; | |
114 BOOL passwordManagerChoiceEnabled_; | |
115 BOOL passwordManagerButtonEnabled_; | |
116 BOOL autoFillSettingsButtonEnabled_; | |
117 | |
118 // Under the hood panel | |
119 IBOutlet NSView* underTheHoodContentView_; | |
120 IBOutlet NSScrollView* underTheHoodScroller_; | |
121 IBOutlet NSButton* contentSettingsButton_; | |
122 IBOutlet NSButton* clearDataButton_; | |
123 BooleanPrefMember alternateErrorPages_; | |
124 BooleanPrefMember useSuggest_; | |
125 BooleanPrefMember dnsPrefetch_; | |
126 BooleanPrefMember safeBrowsing_; | |
127 BooleanPrefMember metricsReporting_; | |
128 IBOutlet NSPathControl* downloadLocationControl_; | |
129 IBOutlet NSButton* downloadLocationButton_; | |
130 StringPrefMember defaultDownloadLocation_; | |
131 BooleanPrefMember askForSaveLocation_; | |
132 IBOutlet NSButton* resetFileHandlersButton_; | |
133 StringPrefMember autoOpenFiles_; | |
134 BooleanPrefMember translateEnabled_; | |
135 BooleanPrefMember tabsToLinks_; | |
136 FontLanguageSettingsController* fontLanguageSettings_; | |
137 StringPrefMember currentTheme_; | |
138 IBOutlet NSButton* enableLoggingCheckbox_; | |
139 scoped_ptr<PrefSetObserver> proxyPrefs_; | |
140 BOOL showAlternateErrorPagesEnabled_; | |
141 BOOL useSuggestEnabled_; | |
142 BOOL dnsPrefetchEnabled_; | |
143 BOOL safeBrowsingEnabled_; | |
144 BOOL metricsReportingEnabled_; | |
145 BOOL proxiesConfigureButtonEnabled_; | |
146 } | |
147 | |
148 // Designated initializer. |profile| should not be NULL. | |
149 - (id)initWithProfile:(Profile*)profile initialPage:(OptionsPage)initialPage; | |
150 | |
151 // Show the preferences window. | |
152 - (void)showPreferences:(id)sender; | |
153 | |
154 // Switch to the given preference page. | |
155 - (void)switchToPage:(OptionsPage)page animate:(BOOL)animate; | |
156 | |
157 // Enables or disables the restoreOnStartup elements | |
158 - (void) setEnabledStateOfRestoreOnStartup; | |
159 | |
160 // IBAction methods for responding to user actions. | |
161 | |
162 // Basics panel | |
163 - (IBAction)addHomepage:(id)sender; | |
164 - (IBAction)removeSelectedHomepages:(id)sender; | |
165 - (IBAction)useCurrentPagesAsHomepage:(id)sender; | |
166 - (IBAction)manageSearchEngines:(id)sender; | |
167 - (IBAction)toggleInstant:(id)sender; | |
168 - (IBAction)learnMoreAboutInstant:(id)sender; | |
169 - (IBAction)makeDefaultBrowser:(id)sender; | |
170 | |
171 // User Data panel | |
172 - (IBAction)doSyncAction:(id)sender; | |
173 - (IBAction)doSyncCustomize:(id)sender; | |
174 - (IBAction)doSyncReauthentication:(id)sender; | |
175 - (IBAction)showPrivacyDashboard:(id)sender; | |
176 - (IBAction)showSavedPasswords:(id)sender; | |
177 - (IBAction)showAutoFillSettings:(id)sender; | |
178 - (IBAction)importData:(id)sender; | |
179 - (IBAction)resetThemeToDefault:(id)sender; | |
180 - (IBAction)themesGallery:(id)sender; | |
181 | |
182 // Under the hood | |
183 - (IBAction)showContentSettings:(id)sender; | |
184 - (IBAction)clearData:(id)sender; | |
185 - (IBAction)privacyLearnMore:(id)sender; | |
186 - (IBAction)browseDownloadLocation:(id)sender; | |
187 - (IBAction)resetAutoOpenFiles:(id)sender; | |
188 - (IBAction)changeFontAndLanguageSettings:(id)sender; | |
189 - (IBAction)openProxyPreferences:(id)sender; | |
190 - (IBAction)showCertificates:(id)sender; | |
191 - (IBAction)resetToDefaults:(id)sender; | |
192 | |
193 // When a toolbar button is clicked | |
194 - (IBAction)toolbarButtonSelected:(id)sender; | |
195 | |
196 // Usable from cocoa bindings to hook up the custom home pages table. | |
197 @property (nonatomic, readonly) CustomHomePagesModel* customPagesSource; | |
198 | |
199 // Properties for the enabled state of various UI elements. Keep these ordered | |
200 // by occurrence on the dialog. | |
201 @property (nonatomic) BOOL restoreButtonsEnabled; | |
202 @property (nonatomic) BOOL restoreURLsEnabled; | |
203 @property (nonatomic) BOOL showHomeButtonEnabled; | |
204 @property (nonatomic) BOOL defaultSearchEngineEnabled; | |
205 @property (nonatomic) BOOL passwordManagerChoiceEnabled; | |
206 @property (nonatomic) BOOL passwordManagerButtonEnabled; | |
207 @property (nonatomic) BOOL autoFillSettingsButtonEnabled; | |
208 @property (nonatomic) BOOL showAlternateErrorPagesEnabled; | |
209 @property (nonatomic) BOOL useSuggestEnabled; | |
210 @property (nonatomic) BOOL dnsPrefetchEnabled; | |
211 @property (nonatomic) BOOL safeBrowsingEnabled; | |
212 @property (nonatomic) BOOL metricsReportingEnabled; | |
213 @property (nonatomic) BOOL proxiesConfigureButtonEnabled; | |
214 @end | |
215 | |
216 @interface PreferencesWindowController(Testing) | |
217 | |
218 - (IntegerPrefMember*)lastSelectedPage; | |
219 - (NSToolbar*)toolbar; | |
220 - (NSView*)basicsView; | |
221 - (NSView*)personalStuffView; | |
222 - (NSView*)underTheHoodView; | |
223 | |
224 // Converts the given OptionsPage value (which may be OPTIONS_PAGE_DEFAULT) | |
225 // into a concrete OptionsPage value. | |
226 - (OptionsPage)normalizePage:(OptionsPage)page; | |
227 | |
228 // Returns the toolbar item corresponding to the given page. Should be | |
229 // called only after awakeFromNib is. | |
230 - (NSToolbarItem*)getToolbarItemForPage:(OptionsPage)page; | |
231 | |
232 // Returns the (normalized) page corresponding to the given toolbar item. | |
233 // Should be called only after awakeFromNib is. | |
234 - (OptionsPage)getPageForToolbarItem:(NSToolbarItem*)toolbarItem; | |
235 | |
236 // Returns the view corresponding to the given page. Should be called | |
237 // only after awakeFromNib is. | |
238 - (NSView*)getPrefsViewForPage:(OptionsPage)page; | |
239 | |
240 @end | |
OLD | NEW |