Chromium Code Reviews| Index: chrome/browser/web_applications/web_app_mac.mm |
| diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm |
| index fcf35684d1f3ae1e278aad18c422ec695b215461..633cbb3e8420269e0edf0fc1f728dd2421c308ce 100644 |
| --- a/chrome/browser/web_applications/web_app_mac.mm |
| +++ b/chrome/browser/web_applications/web_app_mac.mm |
| @@ -554,6 +554,50 @@ void UpdateFileTypes(NSMutableDictionary* plist, |
| } // namespace |
| +@interface CrCreateAppShortcutCheckboxObserver : NSObject { |
| + @private |
| + NSButton* checkbox_; |
| + NSButton* continueButton_; |
| +} |
| + |
| +- (id)initWithCheckbox:(NSButton*)checkbox |
| + withContinueButton:(NSButton*)continueButton; |
|
tapted
2014/09/07 23:54:06
nit: withContinueButton -> continueButton
|
| +- (void)startObserving; |
| +- (void)stopObserving; |
| +@end |
| + |
| +@implementation CrCreateAppShortcutCheckboxObserver |
| + |
| +- (id)initWithCheckbox:(NSButton*)checkbox |
| + withContinueButton:(NSButton*)continueButton { |
| + if ((self = [super init])) { |
| + checkbox_ = checkbox; |
| + continueButton_ = continueButton; |
| + } |
| + return self; |
| +} |
| + |
| +- (void)startObserving { |
| + [checkbox_ addObserver:self |
| + forKeyPath:@"cell.state" |
| + options:0 |
| + context:nil]; |
| +} |
| + |
| +- (void)stopObserving { |
| + [checkbox_ removeObserver:self |
| + forKeyPath:@"cell.state"]; |
| +} |
| + |
| +- (void)observeValueForKeyPath:(NSString*)keyPath |
| + ofObject:(id)object |
| + change:(NSDictionary*)change |
| + context:(void*)context { |
| + [continueButton_ setEnabled:([checkbox_ state] == NSOnState)]; |
| +} |
| + |
| +@end // @implementation CrCreateAppShortcutCheckboxObserver |
|
tapted
2014/09/07 23:54:06
nit: remove comment - it's not typical to add it f
|
| + |
| namespace web_app { |
| WebAppShortcutCreator::WebAppShortcutCreator( |
| @@ -985,6 +1029,13 @@ void CreateAppShortcutInfoLoaded( |
| setTitle:l10n_util::GetNSString(IDS_CREATE_SHORTCUTS_APP_FOLDER_CHKBOX)]; |
| [application_folder_checkbox setState:NSOnState]; |
| [application_folder_checkbox sizeToFit]; |
| + |
| + base::scoped_nsobject<CrCreateAppShortcutCheckboxObserver> checkbox_observer( |
| + [[CrCreateAppShortcutCheckboxObserver alloc] |
| + initWithCheckbox:application_folder_checkbox |
| + withContinueButton:continue_button]); |
| + [checkbox_observer startObserving]; |
| + |
| [alert setAccessoryView:application_folder_checkbox]; |
| const int kIconPreviewSizePixels = 128; |
| @@ -1007,6 +1058,8 @@ void CreateAppShortcutInfoLoaded( |
| SHORTCUT_CREATION_BY_USER, ShortcutLocations(), profile, app); |
| } |
| + [checkbox_observer stopObserving]; |
| + |
| if (!close_callback.is_null()) |
| close_callback.Run(dialog_accepted); |
| } |