OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 #ifndef IOS_CHROME_BROWSER_UI_SETTINGS_SETTINGS_NAVIGATION_CONTROLLER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_SETTINGS_SETTINGS_NAVIGATION_CONTROLLER_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 @class OpenUrlCommand; |
| 11 @protocol ImportDataControllerDelegate; |
| 12 @protocol UserFeedbackDataSource; |
| 13 |
| 14 namespace ios { |
| 15 class ChromeBrowserState; |
| 16 } // namespace ios |
| 17 |
| 18 @protocol SettingsControllerProtocol<NSObject> |
| 19 |
| 20 @optional |
| 21 |
| 22 // Notifies the controller that the settings screen is being dismissed. |
| 23 - (void)settingsWillBeDismissed; |
| 24 |
| 25 @end |
| 26 |
| 27 @protocol SettingsNavigationControllerDelegate<NSObject> |
| 28 |
| 29 // Handles a close settings and open URL command. |
| 30 - (void)closeSettingsAndOpenUrl:(OpenUrlCommand*)command; |
| 31 |
| 32 // Informs the delegate that the settings navigation controller should be |
| 33 // closed and a new incognito window should be opened. |
| 34 - (void)closeSettingsAndOpenNewIncognitoTab; |
| 35 |
| 36 // Informs the delegate that the settings navigation controller should be |
| 37 // closed. |
| 38 - (void)closeSettings; |
| 39 |
| 40 @end |
| 41 |
| 42 // Controller to modify user settings. |
| 43 @interface SettingsNavigationController : UINavigationController |
| 44 |
| 45 // Whether sync changes should be committed when the settings are being |
| 46 // dismissed. Defaults to YES. |
| 47 @property(nonatomic, assign) BOOL shouldCommitSyncChangesOnDismissal; |
| 48 |
| 49 // Creates a new SettingsCollectionViewController and the chrome around it. |
| 50 // |browserState| is used to personalize some settings aspects and should not be |
| 51 // nil. |delegate| may be nil. |
| 52 // clang-format off |
| 53 + (SettingsNavigationController*)newSettingsMainControllerWithMainBrowserState: |
| 54 (ios::ChromeBrowserState*)browserState |
| 55 currentBrowserState: |
| 56 (ios::ChromeBrowserState*)currentBrowserState |
| 57 delegate: |
| 58 (id<SettingsNavigationControllerDelegate>)delegate; |
| 59 // clang-format on |
| 60 |
| 61 // Creates a new AccountsCollectionViewController and the chrome around it. |
| 62 // |browserState| is used to personalize some settings aspects and should not be |
| 63 // nil. |delegate| may be nil. |
| 64 + (SettingsNavigationController*) |
| 65 newAccountsController:(ios::ChromeBrowserState*)browserState |
| 66 delegate:(id<SettingsNavigationControllerDelegate>)delegate; |
| 67 |
| 68 // Creates a new SignInSettingsCollectionViewController and the chrome around |
| 69 // it. |browserState| is used to personalize some settings aspects and should |
| 70 // not be nil. |delegate| may be nil. |
| 71 + (SettingsNavigationController*) |
| 72 newSyncController:(ios::ChromeBrowserState*)browserState |
| 73 allowSwitchSyncAccount:(BOOL)allowSwitchSyncAccount |
| 74 delegate:(id<SettingsNavigationControllerDelegate>)delegate; |
| 75 |
| 76 // Creates a new SyncEncryptionPassphraseCollectionViewController and the chrome |
| 77 // around it. |browserState| is used to personalize some settings aspects and |
| 78 // should not be nil. |delegate| may be nil. |
| 79 + (SettingsNavigationController*) |
| 80 newSyncEncryptionPassphraseController:(ios::ChromeBrowserState*)browserState |
| 81 delegate:(id<SettingsNavigationControllerDelegate>) |
| 82 delegate; |
| 83 |
| 84 // Creates a new NativeAppsCollectionViewController and the chrome around it. |
| 85 // |browserState| is used to personalize some settings aspects and should not be |
| 86 // nil. |delegate| may be nil. |
| 87 + (SettingsNavigationController*) |
| 88 newNativeAppsController:(ios::ChromeBrowserState*)browserState |
| 89 delegate:(id<SettingsNavigationControllerDelegate>)delegate; |
| 90 |
| 91 // Creates a new ClearBrowsingDataCollectionViewController and the chrome around |
| 92 // it. |
| 93 // |browserState| is used to personalize some settings aspects and should not be |
| 94 // nil. |delegate| may be nil. |
| 95 + (SettingsNavigationController*) |
| 96 newClearBrowsingDataController:(ios::ChromeBrowserState*)browserState |
| 97 delegate: |
| 98 (id<SettingsNavigationControllerDelegate>)delegate; |
| 99 |
| 100 + (SettingsNavigationController*) |
| 101 newContextualSearchController:(ios::ChromeBrowserState*)browserState |
| 102 delegate: |
| 103 (id<SettingsNavigationControllerDelegate>)delegate; |
| 104 |
| 105 // Creates a new SavePasswordsCollectionViewController and the chrome around it. |
| 106 // |browserState| is used to personalize some settings aspects and should not be |
| 107 // nil. |delegate| may be nil. |
| 108 + (SettingsNavigationController*) |
| 109 newSavePasswordsController:(ios::ChromeBrowserState*)browserState |
| 110 delegate:(id<SettingsNavigationControllerDelegate>)delegate; |
| 111 |
| 112 // Creates and displays a new UserFeedbackViewController. |browserState| is used |
| 113 // to personalize some settings aspects and should not be nil. |dataSource| is |
| 114 // used to populate the UserFeedbackViewController. |delegate| may be nil. |
| 115 + (SettingsNavigationController*) |
| 116 newUserFeedbackController:(ios::ChromeBrowserState*)browserState |
| 117 delegate:(id<SettingsNavigationControllerDelegate>)delegate |
| 118 feedbackDataSource:(id<UserFeedbackDataSource>)dataSource; |
| 119 |
| 120 // Creates and displays a new ImportDataCollectionViewController. |browserState| |
| 121 // should not be nil. |
| 122 + (SettingsNavigationController*) |
| 123 newImportDataController:(ios::ChromeBrowserState*)browserState |
| 124 delegate:(id<SettingsNavigationControllerDelegate>)delegate |
| 125 importDataDelegate:(id<ImportDataControllerDelegate>)importDataDelegate |
| 126 fromEmail:(NSString*)fromEmail |
| 127 toEmail:(NSString*)toEmail |
| 128 isSignedIn:(BOOL)isSignedIn; |
| 129 |
| 130 // Returns a new Done button for a UINavigationItem which will call |
| 131 // closeSettings when it is pressed. Should only be called by view controllers |
| 132 // owned by SettingsNavigationController. |
| 133 - (UIBarButtonItem*)doneButton; |
| 134 |
| 135 // Returns the current main browser state. |
| 136 - (ios::ChromeBrowserState*)mainBrowserState; |
| 137 |
| 138 // Notifies this |SettingsNavigationController| that it will be dismissed such |
| 139 // that it has a possibility to do necessary clean up. |
| 140 - (void)settingsWillBeDismissed; |
| 141 |
| 142 // Closes this |SettingsNavigationController| by asking its delegate. |
| 143 - (void)closeSettings; |
| 144 |
| 145 // Pops the top view controller if there exists more than one view controller in |
| 146 // the navigation stack. Closes the settings if the top view controller is the |
| 147 // only view controller in the navigation stack. |
| 148 - (void)popViewControllerOrCloseSettingsAnimated:(BOOL)animated; |
| 149 |
| 150 @end |
| 151 |
| 152 @interface SettingsNavigationController (ExposedForTesting) |
| 153 |
| 154 // Initializes the UINavigationController with |rootViewController|. |
| 155 // User of this class should not call the normal |initWithRootViewController|. |
| 156 - (instancetype) |
| 157 initWithRootViewController:(UIViewController*)rootViewController |
| 158 browserState:(ios::ChromeBrowserState*)browserState |
| 159 delegate:(id<SettingsNavigationControllerDelegate>)delegate; |
| 160 |
| 161 @end |
| 162 |
| 163 #endif // IOS_CHROME_BROWSER_UI_SETTINGS_SETTINGS_NAVIGATION_CONTROLLER_H_ |
OLD | NEW |