| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #import <PreferencePanes/PreferencePanes.h> | 6 #import <PreferencePanes/PreferencePanes.h> |
| 7 #import <SecurityInterface/SFAuthorizationView.h> | 7 #import <SecurityInterface/SFAuthorizationView.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // update...Status methods. | 58 // update...Status methods. |
| 59 BOOL is_service_running_; | 59 BOOL is_service_running_; |
| 60 BOOL is_pane_unlocked_; | 60 BOOL is_pane_unlocked_; |
| 61 | 61 |
| 62 // True if a new proposed config file has been loaded into memory. | 62 // True if a new proposed config file has been loaded into memory. |
| 63 BOOL have_new_config_; | 63 BOOL have_new_config_; |
| 64 | 64 |
| 65 // True if launchd has been instructed to stop the service and we are waiting | 65 // True if launchd has been instructed to stop the service and we are waiting |
| 66 // for the operation to complete. | 66 // for the operation to complete. |
| 67 BOOL awaiting_service_stop_; | 67 BOOL awaiting_service_stop_; |
| 68 |
| 69 // True if a version-mismatch has been detected. If true, this causes all |
| 70 // controls to be greyed out, and also prevents any config file from being |
| 71 // deleted, pending a restart of the preference pane. |
| 72 BOOL is_pane_disabled_; |
| 68 } | 73 } |
| 69 | 74 |
| 70 - (void)mainViewDidLoad; | 75 - (void)mainViewDidLoad; |
| 71 - (void)willSelect; | 76 - (void)willSelect; |
| 77 - (void)didSelect; |
| 72 - (void)willUnselect; | 78 - (void)willUnselect; |
| 73 - (void)onDisable:(id)sender; | 79 - (void)onDisable:(id)sender; |
| 74 - (void)applyConfiguration:(id)sender | 80 - (void)applyConfiguration:(id)sender |
| 75 pin:(NSString*)pin; | 81 pin:(NSString*)pin; |
| 76 - (void)onNewConfigFile:(NSNotification*)notification; | 82 - (void)onNewConfigFile:(NSNotification*)notification; |
| 77 - (void)refreshServiceStatus:(NSTimer*)timer; | 83 - (void)refreshServiceStatus:(NSTimer*)timer; |
| 78 - (void)authorizationViewDidAuthorize:(SFAuthorizationView*)view; | 84 - (void)authorizationViewDidAuthorize:(SFAuthorizationView*)view; |
| 79 - (void)authorizationViewDidDeauthorize:(SFAuthorizationView*)view; | 85 - (void)authorizationViewDidDeauthorize:(SFAuthorizationView*)view; |
| 80 - (void)updateServiceStatus; | 86 - (void)updateServiceStatus; |
| 81 - (void)updateAuthorizationStatus; | 87 - (void)updateAuthorizationStatus; |
| 82 | 88 |
| 83 // Read any new config file if present. If a config file is successfully read, | 89 // Read any new config file if present. If a config file is successfully read, |
| 84 // this deletes the file and keeps the config data loaded in memory. If this | 90 // this deletes the file and keeps the config data loaded in memory. If this |
| 85 // method is called a second time (when the file has been deleted), the current | 91 // method is called a second time (when the file has been deleted), the current |
| 86 // config is remembered, so this method acts as a latch: it can change | 92 // config is remembered, so this method acts as a latch: it can change |
| 87 // |have_new_config_| from NO to YES, but never from YES to NO. | 93 // |have_new_config_| from NO to YES, but never from YES to NO. |
| 88 // | 94 // |
| 89 // This scheme means that this method can delete the file immediately (to avoid | 95 // This scheme means that this method can delete the file immediately (to avoid |
| 90 // leaving a stale file around in case of a crash), but this method can safely | 96 // leaving a stale file around in case of a crash), but this method can safely |
| 91 // be called multiple times without forgetting the loaded config. To explicitly | 97 // be called multiple times without forgetting the loaded config. To explicitly |
| 92 // forget the current config, set |have_new_config_| to NO. | 98 // forget the current config, set |have_new_config_| to NO. |
| 99 // |
| 100 // This method first checks that the pane has not been disabled due to a |
| 101 // pending restart. If |is_pane_disabled_| is YES, this method does nothing, |
| 102 // leaving the config file untouched. |
| 93 - (void)readNewConfig; | 103 - (void)readNewConfig; |
| 94 | 104 |
| 95 // Update all UI controls according to any stored flags and loaded config. | 105 // Update all UI controls according to any stored flags and loaded config. |
| 96 // This should be called after any sequence of operations that might change the | 106 // This should be called after any sequence of operations that might change the |
| 97 // UI state. | 107 // UI state. |
| 98 - (void)updateUI; | 108 - (void)updateUI; |
| 99 | 109 |
| 100 // Alert the user to a generic error condition. | 110 // Alert the user to a generic error condition. |
| 101 - (void)showError; | 111 - (void)showError; |
| 102 | 112 |
| 103 // Alert the user that the typed PIN is incorrect. | 113 // Alert the user that the typed PIN is incorrect. |
| 104 - (void)showIncorrectPinMessage; | 114 - (void)showIncorrectPinMessage; |
| 105 | 115 |
| 106 // Save the new config to the system, and either start the service or inform | 116 // Save the new config to the system, and either start the service or inform |
| 107 // the currently-running service of the new config. | 117 // the currently-running service of the new config. |
| 108 - (void)applyNewServiceConfig; | 118 - (void)applyNewServiceConfig; |
| 109 | 119 |
| 110 - (BOOL)runHelperAsRootWithCommand:(const char*)command | 120 - (BOOL)runHelperAsRootWithCommand:(const char*)command |
| 111 inputData:(const std::string&)input_data; | 121 inputData:(const std::string&)input_data; |
| 112 - (BOOL)sendJobControlMessage:(const char*)launch_key; | 122 - (BOOL)sendJobControlMessage:(const char*)launch_key; |
| 113 | 123 |
| 114 // Compare the version of the running pref-pane against the installed version. | 124 // Compare the version of the running pref-pane against the installed version. |
| 115 // If the versions are mismatched, return YES and restart the System | 125 // If the versions are mismatched and the pref-pane is visible, disable the |
| 116 // Preferences application, so the correct version of this pref-pane is loaded. | 126 // pane to prevent interaction, and prompt the user to restart System |
| 117 - (BOOL)restartPanelIfDifferentVersionInstalled; | 127 // Preferences. |
| 128 // |
| 129 // This should be called on notification of a new config, and also in |
| 130 // |didSelect| when the pane becomes visible. The pane needs to be visible so |
| 131 // that the alert appears as a sheet over the pane (instead of a detached |
| 132 // window), which gives the user an appropriate context for the alert. |
| 133 // |
| 134 // In the case of a version-mismatch, the new config file should be kept until |
| 135 // System Preferences is restarted, or thrown away when the user cancels the |
| 136 // alert. This method sets the |is_pane_disabled_| flag on version-mismatch, |
| 137 // which is checked by |readNewConfig|. |
| 138 - (void)checkInstalledVersion; |
| 139 |
| 140 - (void)mismatchAlertDidEnd:(NSAlert*)alert |
| 141 returnCode:(NSInteger)returnCode |
| 142 contextInfo:(void*)contextInfo; |
| 143 |
| 144 // Called when the user chooses OK when prompted to restart System Preferences. |
| 145 - (void)restartSystemPreferences; |
| 118 | 146 |
| 119 @end | 147 @end |
| OLD | NEW |