| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
| 9 #include "chrome/browser/options_window.h" |
| 9 #include "chrome/common/pref_member.h" | 10 #include "chrome/common/pref_member.h" |
| 10 | 11 |
| 11 @class CustomHomePagesModel; | 12 @class CustomHomePagesModel; |
| 12 class PrefObserverBridge; | 13 class PrefObserverBridge; |
| 13 class PrefService; | 14 class PrefService; |
| 14 class Profile; | 15 class Profile; |
| 15 class ProfileSyncService; | 16 class ProfileSyncService; |
| 16 @class SearchEngineListModel; | 17 @class SearchEngineListModel; |
| 17 | 18 |
| 18 // A window controller that handles the preferences window. The bulk of the | 19 // A window controller that handles the preferences window. The bulk of the |
| 19 // work is handled via Cocoa Bindings and getter/setter methods that wrap | 20 // work is handled via Cocoa Bindings and getter/setter methods that wrap |
| 20 // cross-platform PrefMember objects. When prefs change in the back-end | 21 // cross-platform PrefMember objects. When prefs change in the back-end |
| 21 // (that is, outside of this UI), our observer recieves a notification and can | 22 // (that is, outside of this UI), our observer recieves a notification and can |
| 22 // tickle the KVO to update the UI so we are always in sync. The bindings are | 23 // tickle the KVO to update the UI so we are always in sync. The bindings are |
| 23 // specified in the nib file. Preferences are persisted into the back-end | 24 // specified in the nib file. Preferences are persisted into the back-end |
| 24 // as they are changed in the UI, and are thus immediately available even while | 25 // as they are changed in the UI, and are thus immediately available even while |
| 25 // the window is still open. When the window closes, a notification is sent | 26 // the window is still open. When the window closes, a notification is sent |
| 26 // via the system NotificationCenter. This can be used as a signal to | 27 // via the system NotificationCenter. This can be used as a signal to |
| 27 // release this controller, as it's likely the client wants to enforce there | 28 // release this controller, as it's likely the client wants to enforce there |
| 28 // only being one (we don't do that internally as it makes it very difficult | 29 // only being one (we don't do that internally as it makes it very difficult |
| 29 // to unit test). | 30 // to unit test). |
| 30 @interface PreferencesWindowController : NSWindowController { | 31 @interface PreferencesWindowController : NSWindowController { |
| 31 @private | 32 @private |
| 32 Profile* profile_; // weak ref | 33 Profile* profile_; // weak ref |
| 34 OptionsPage initialPage_; |
| 33 PrefService* prefs_; // weak ref - Obtained from profile_ for convenience. | 35 PrefService* prefs_; // weak ref - Obtained from profile_ for convenience. |
| 34 // weak ref - Also obtained from profile_ for convenience. May be NULL. | 36 // weak ref - Also obtained from profile_ for convenience. May be NULL. |
| 35 ProfileSyncService* syncService_; | 37 ProfileSyncService* syncService_; |
| 36 scoped_ptr<PrefObserverBridge> observer_; // Watches for pref changes. | 38 scoped_ptr<PrefObserverBridge> observer_; // Watches for pref changes. |
| 37 | 39 |
| 38 IBOutlet NSToolbar* toolbar_; | 40 IBOutlet NSToolbar* toolbar_; |
| 39 | 41 |
| 40 // The views we'll rotate through | 42 // The views we'll rotate through |
| 41 IBOutlet NSView* basicsView_; | 43 IBOutlet NSView* basicsView_; |
| 42 IBOutlet NSView* personalStuffView_; | 44 IBOutlet NSView* personalStuffView_; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 IntegerPrefMember cookieBehavior_; | 93 IntegerPrefMember cookieBehavior_; |
| 92 IBOutlet NSPathControl* downloadLocationControl_; | 94 IBOutlet NSPathControl* downloadLocationControl_; |
| 93 IBOutlet NSButton* downloadLocationButton_; | 95 IBOutlet NSButton* downloadLocationButton_; |
| 94 StringPrefMember defaultDownloadLocation_; | 96 StringPrefMember defaultDownloadLocation_; |
| 95 BooleanPrefMember askForSaveLocation_; | 97 BooleanPrefMember askForSaveLocation_; |
| 96 StringPrefMember currentTheme_; | 98 StringPrefMember currentTheme_; |
| 97 IBOutlet NSButton* enableLoggingCheckbox_; | 99 IBOutlet NSButton* enableLoggingCheckbox_; |
| 98 } | 100 } |
| 99 | 101 |
| 100 // Designated initializer. |profile| should not be NULL. | 102 // Designated initializer. |profile| should not be NULL. |
| 101 - (id)initWithProfile:(Profile*)profile; | 103 - (id)initWithProfile:(Profile*)profile initialPage:(OptionsPage)initialPage; |
| 102 | 104 |
| 103 // Show the preferences window. | 105 // Show the preferences window. |
| 104 - (void)showPreferences:(id)sender; | 106 - (void)showPreferences:(id)sender; |
| 105 | 107 |
| 108 // Switch to the given preference page. |
| 109 - (void)switchToPage:(OptionsPage)page animate:(BOOL)animate; |
| 110 |
| 106 // IBAction methods for responding to user actions. | 111 // IBAction methods for responding to user actions. |
| 107 | 112 |
| 108 // Basics panel | 113 // Basics panel |
| 109 - (IBAction)makeDefaultBrowser:(id)sender; | 114 - (IBAction)makeDefaultBrowser:(id)sender; |
| 110 - (IBAction)addHomepage:(id)sender; | 115 - (IBAction)addHomepage:(id)sender; |
| 111 - (IBAction)removeSelectedHomepages:(id)sender; | 116 - (IBAction)removeSelectedHomepages:(id)sender; |
| 112 - (IBAction)useCurrentPagesAsHomepage:(id)sender; | 117 - (IBAction)useCurrentPagesAsHomepage:(id)sender; |
| 113 - (IBAction)manageSearchEngines:(id)sender; | 118 - (IBAction)manageSearchEngines:(id)sender; |
| 114 | 119 |
| 115 // User Data panel | 120 // User Data panel |
| (...skipping 11 matching lines...) Expand all Loading... |
| 127 // When a toolbar button is clicked | 132 // When a toolbar button is clicked |
| 128 - (IBAction)toolbarButtonSelected:(id)sender; | 133 - (IBAction)toolbarButtonSelected:(id)sender; |
| 129 | 134 |
| 130 // Usable from cocoa bindings to hook up the custom home pages table. | 135 // Usable from cocoa bindings to hook up the custom home pages table. |
| 131 @property(readonly) CustomHomePagesModel* customPagesSource; | 136 @property(readonly) CustomHomePagesModel* customPagesSource; |
| 132 | 137 |
| 133 // NSNotification sent when the prefs window is closed. | 138 // NSNotification sent when the prefs window is closed. |
| 134 extern NSString* const kUserDoneEditingPrefsNotification; | 139 extern NSString* const kUserDoneEditingPrefsNotification; |
| 135 | 140 |
| 136 @end | 141 @end |
| 142 |
| 143 @interface PreferencesWindowController(Testing) |
| 144 |
| 145 - (IntegerPrefMember*)lastSelectedPage; |
| 146 - (NSToolbar*)toolbar; |
| 147 - (NSView*)basicsView; |
| 148 - (NSView*)personalStuffView; |
| 149 - (NSView*)underTheHoodView; |
| 150 |
| 151 // Converts the given OptionsPage value (which may be OPTIONS_PAGE_DEFAULT) |
| 152 // into a concrete OptionsPage value. |
| 153 - (OptionsPage)normalizePage:(OptionsPage)page; |
| 154 |
| 155 // Returns the toolbar item corresponding to the given page. Should be |
| 156 // called only after awakeFromNib is. |
| 157 - (NSToolbarItem*)getToolbarItemForPage:(OptionsPage)page; |
| 158 |
| 159 // Returns the (normalized) page corresponding to the given toolbar item. |
| 160 // Should be called only after awakeFromNib is. |
| 161 - (OptionsPage)getPageForToolbarItem:(NSToolbarItem*)toolbarItem; |
| 162 |
| 163 // Returns the view corresponding to the given page. Should be called |
| 164 // only after awakeFromNib is. |
| 165 - (NSView*)getPrefsViewForPage:(OptionsPage)page; |
| 166 |
| 167 @end |
| 168 |
| OLD | NEW |