summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-22 21:15:36 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-22 21:15:36 +0000
commitdf18b5cf26cb1b38dc6a82c4647c1e90c40aea3c (patch)
treeecbe0971a69269b2faae698901bdc0fb39422754 /chrome
parent3c55c1579d19a44743d88a6927671ded883b6048 (diff)
downloadchromium_src-df18b5cf26cb1b38dc6a82c4647c1e90c40aea3c.zip
chromium_src-df18b5cf26cb1b38dc6a82c4647c1e90c40aea3c.tar.gz
chromium_src-df18b5cf26cb1b38dc6a82c4647c1e90c40aea3c.tar.bz2
Ensure OK is only enabled when there is text in the text field for folders and items (whitespace is ok).
BUG=19558 TEST=per bug, test existing folders and new folders alike. Review URL: http://codereview.chromium.org/292046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/nibs/BookmarkNameFolder.xib42
-rw-r--r--chrome/browser/cocoa/bookmark_name_folder_controller.h2
-rw-r--r--chrome/browser/cocoa/bookmark_name_folder_controller.mm12
-rw-r--r--chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm22
4 files changed, 73 insertions, 5 deletions
diff --git a/chrome/app/nibs/BookmarkNameFolder.xib b/chrome/app/nibs/BookmarkNameFolder.xib
index 16cd437..2a5655c 100644
--- a/chrome/app/nibs/BookmarkNameFolder.xib
+++ b/chrome/app/nibs/BookmarkNameFolder.xib
@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9L30</string>
+ <string key="IBDocument.SystemVersion">9L31a</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.54</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="18"/>
+ <integer value="17"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -255,6 +255,22 @@
</object>
<int key="connectionID">23</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="781907324"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">25</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">okButton_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="810399603"/>
+ </object>
+ <int key="connectionID">26</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -462,7 +478,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">23</int>
+ <int key="maxID">26</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -484,8 +500,17 @@
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
- <string key="NS.key.0">nameField_</string>
- <string key="NS.object.0">NSTextField</string>
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>nameField_</string>
+ <string>okButton_</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSTextField</string>
+ <string>NSButton</string>
+ </object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
@@ -580,6 +605,13 @@
<string key="minorKey">browser/cocoa/tab_strip_model_observer_bridge.h</string>
</object>
</object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSWindow</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/nswindow_local_state.h</string>
+ </object>
+ </object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
diff --git a/chrome/browser/cocoa/bookmark_name_folder_controller.h b/chrome/browser/cocoa/bookmark_name_folder_controller.h
index 764a04a..0da2b10 100644
--- a/chrome/browser/cocoa/bookmark_name_folder_controller.h
+++ b/chrome/browser/cocoa/bookmark_name_folder_controller.h
@@ -17,6 +17,7 @@
@interface BookmarkNameFolderController : NSWindowController {
@private
IBOutlet NSTextField* nameField_;
+ IBOutlet NSButton* okButton_;
NSWindow* parentWindow_; // weak
Profile* profile_; // weak
@@ -33,6 +34,7 @@
@interface BookmarkNameFolderController(TestingAPI)
- (void)setFolderName:(NSString*)name;
+- (NSButton*)okButton;
@end
#endif /* CHROME_BROWSER_COCOA_BOOKMARK_NAME_FOLDER_CONTROLLER_H_ */
diff --git a/chrome/browser/cocoa/bookmark_name_folder_controller.mm b/chrome/browser/cocoa/bookmark_name_folder_controller.mm
index 859e8e7..720b076a 100644
--- a/chrome/browser/cocoa/bookmark_name_folder_controller.mm
+++ b/chrome/browser/cocoa/bookmark_name_folder_controller.mm
@@ -36,6 +36,13 @@
// title is never seen. If we switch from a sheet, correct the
// title right here.
}
+ [self controlTextDidChange:nil];
+}
+
+// Called as a side-effect of being the delegate of the text field. Ensure the
+// OK button is only enabled when there is a valid name.
+- (void)controlTextDidChange:(NSNotification*)ignore {
+ [okButton_ setEnabled:[[nameField_ stringValue] length]];
}
// TODO(jrg): consider NSModalSession.
@@ -80,6 +87,11 @@
- (void)setFolderName:(NSString*)name {
[nameField_ setStringValue:name];
+ [self controlTextDidChange:nil];
+}
+
+- (NSButton*)okButton {
+ return okButton_;
}
@end // BookmarkNameFolderController
diff --git a/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm b/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm
index 6a543b8..dfb32c2 100644
--- a/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm
+++ b/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm
@@ -62,3 +62,25 @@ TEST_F(BookmarkNameFolderControllerTest, AddAndRename) {
EXPECT_EQ(L"Zobo", parent->GetChild(0)->GetTitle());
}
+TEST_F(BookmarkNameFolderControllerTest, EditAndConfirmOKButton) {
+ BookmarkModel* model = helper_.profile()->GetBookmarkModel();
+ const BookmarkNode* parent = model->GetBookmarkBarNode();
+ const BookmarkNode* node = NULL;
+ EXPECT_EQ(0, parent->GetChildCount());
+
+ scoped_nsobject<BookmarkNameFolderController>
+ controller([[BookmarkNameFolderController alloc]
+ initWithParentWindow:cocoa_helper_.window()
+ profile:helper_.profile()
+ node:node]);
+ [controller window]; // force nib load
+ EXPECT_FALSE([[controller okButton] isEnabled]);
+
+ [controller setFolderName:@"Bozo"];
+ EXPECT_TRUE([[controller okButton] isEnabled]);
+ [controller setFolderName:@" "];
+ EXPECT_TRUE([[controller okButton] isEnabled]);
+
+ [controller setFolderName:@""];
+ EXPECT_FALSE([[controller okButton] isEnabled]);
+}