diff options
author | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 01:33:35 +0000 |
---|---|---|
committer | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 01:33:35 +0000 |
commit | 690aa5c82084132146296cc439b54d5231659d61 (patch) | |
tree | 61737eab49f9badad51a228a55304bcb9b29bb41 | |
parent | 403d62efdc9bb84ad624c3f54fff604f50217c4e (diff) | |
download | chromium_src-690aa5c82084132146296cc439b54d5231659d61.zip chromium_src-690aa5c82084132146296cc439b54d5231659d61.tar.gz chromium_src-690aa5c82084132146296cc439b54d5231659d61.tar.bz2 |
Have the background for the URL text field in the bookmark editor present as red when the URL is not properly formed.
BUG=17612
TEST=Type an unacceptable character in the URL field or leave the URL field blank and observe a red background.
Review URL: http://codereview.chromium.org/837010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43043 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/nibs/BookmarkEditor.xib | 29 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_controller.h | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_controller.mm | 11 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_controller_unittest.mm | 17 |
4 files changed, 57 insertions, 5 deletions
diff --git a/chrome/app/nibs/BookmarkEditor.xib b/chrome/app/nibs/BookmarkEditor.xib index 0639ab7..09d969c 100644 --- a/chrome/app/nibs/BookmarkEditor.xib +++ b/chrome/app/nibs/BookmarkEditor.xib @@ -3,12 +3,12 @@ <data> <int key="IBDocument.SystemTarget">1050</int> <string key="IBDocument.SystemVersion">9L31a</string> - <string key="IBDocument.InterfaceBuilderVersion">677</string> + <string key="IBDocument.InterfaceBuilderVersion">680</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="70"/> + <integer value="42"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -302,7 +302,7 @@ <object class="NSMutableArray" key="NSTableColumns"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSTableColumn" id="500451419"> - <double key="NSWidth">4.040000e+02</double> + <double key="NSWidth">4.200000e+02</double> <double key="NSMinWidth">1.600000e+01</double> <double key="NSMaxWidth">1.000000e+03</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> @@ -684,6 +684,14 @@ </object> <int key="connectionID">111</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">urlField_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="812603726"/> + </object> + <int key="connectionID">112</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -1044,7 +1052,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">111</int> + <int key="maxID">112</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -1092,6 +1100,10 @@ <object class="IBPartialClassDescription"> <string key="className">BookmarkEditorController</string> <string key="superclassName">BookmarkEditorBaseController</string> + <object class="NSMutableDictionary" key="outlets"> + <string key="NS.key.0">urlField_</string> + <string key="NS.object.0">NSTextField</string> + </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> <string key="minorKey">browser/cocoa/bookmark_editor_controller.h</string> @@ -1189,7 +1201,14 @@ <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> + <string key="minorKey">browser/cocoa/chrome_browser_window.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/themed_window.h</string> </object> </object> </object> diff --git a/chrome/browser/cocoa/bookmark_editor_controller.h b/chrome/browser/cocoa/bookmark_editor_controller.h index 1fcf5f7..864840e 100644 --- a/chrome/browser/cocoa/bookmark_editor_controller.h +++ b/chrome/browser/cocoa/bookmark_editor_controller.h @@ -15,6 +15,7 @@ const BookmarkNode* node_; // weak; owned by the model scoped_nsobject<NSString> initialUrl_; NSString* displayURL_; // Bound to a text field in the dialog. + IBOutlet NSTextField* urlField_; } @property (copy) NSString* displayURL; @@ -28,4 +29,8 @@ @end +@interface BookmarkEditorController (UnitTesting) +- (NSColor *)urlFieldColor; +@end + #endif /* CHROME_BROWSER_COCOA_BOOKMARK_EDITOR_CONTROLLER_H_ */ diff --git a/chrome/browser/cocoa/bookmark_editor_controller.mm b/chrome/browser/cocoa/bookmark_editor_controller.mm index 3cfe881..521f93c 100644 --- a/chrome/browser/cocoa/bookmark_editor_controller.mm +++ b/chrome/browser/cocoa/bookmark_editor_controller.mm @@ -88,6 +88,13 @@ GURL newURL = [self GURLFromUrlField]; okEnabled = (newURL.is_valid()) ? YES : NO; } + if (okEnabled) + [urlField_ setBackgroundColor:[NSColor whiteColor]]; + else + [urlField_ setBackgroundColor:[NSColor colorWithCalibratedRed:1.0 + green:0.67 + blue:0.67 + alpha:1.0]]; return okEnabled; } @@ -129,5 +136,9 @@ return [NSNumber numberWithBool:YES]; } +- (NSColor *)urlFieldColor { + return [urlField_ backgroundColor]; +} + @end // BookmarkEditorController diff --git a/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm b/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm index 8aac9ab..2405625 100644 --- a/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm @@ -110,6 +110,23 @@ TEST_F(BookmarkEditorControllerTest, EditAndConfirmOKButton) { [controller_ cancel:nil]; } +TEST_F(BookmarkEditorControllerTest, GoodAndBadURLsChangeColor) { + // Confirm that the background color of the URL edit field changes + // based on whether it contains a valid or invalid URL. + [controller_ setDisplayURL:@"http://www.cnn.com"]; + NSColor *urlColorA = [controller_ urlFieldColor]; + EXPECT_TRUE(urlColorA); + [controller_ setDisplayURL:@""]; + NSColor *urlColorB = [controller_ urlFieldColor]; + EXPECT_TRUE(urlColorB); + EXPECT_FALSE([urlColorB isEqual:urlColorA]); + [controller_ setDisplayURL:@"http://www.google.com"]; + [controller_ cancel:nil]; + urlColorB = [controller_ urlFieldColor]; + EXPECT_TRUE(urlColorB); + EXPECT_TRUE([urlColorB isEqual:urlColorA]); +} + class BookmarkEditorControllerNoNodeTest : public CocoaTest { public: BrowserTestHelper browser_helper_; |