Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3801)

Unified Diff: chrome/browser/web_applications/web_app_mac.mm

Issue 541913005: Disable the create button when the "Application folder" option is unchecked on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 74422c2aec03c617ca883a870584456714aacac4..89f6e04d7328ac0dbebc23ab1681dbc558f2d0a9 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
+ continueButton:(NSButton*)continueButton;
+- (void)startObserving;
+- (void)stopObserving;
+@end
+
+@implementation CrCreateAppShortcutCheckboxObserver
+
+- (id)initWithCheckbox:(NSButton*)checkbox
+ continueButton:(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
+
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
+ continueButton: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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698