summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-26 20:10:08 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-26 20:10:08 +0000
commit62299d40f271bfaae651f8dcfea4da8170a7bc14 (patch)
tree2552bfb2f99cebdc467128434d1b27580a32bf07 /chrome
parent4b25d8a0e3954038eea0ffbb4c79ff06fac68384 (diff)
downloadchromium_src-62299d40f271bfaae651f8dcfea4da8170a7bc14.zip
chromium_src-62299d40f271bfaae651f8dcfea4da8170a7bc14.tar.gz
chromium_src-62299d40f271bfaae651f8dcfea4da8170a7bc14.tar.bz2
[Mac] Give the cookies manager a search field.
XIB changes: * Add an NSSearchField and adjust window size. * Add an outlet for the NSOutlineView so we can clear the delegate to avoid potential crashes during sheet closing. * Change the control size of the NSOutlineView to small (looks better). BUG=32328 TEST=Chromium-->Preferences-->Under the Hood-->Show cookies... Enter a domain or domain substring and, without hitting enter, results should be filtered. Review URL: http://codereview.chromium.org/557002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/nibs/Cookies.xib178
-rw-r--r--chrome/browser/cocoa/cookies_window_controller.h5
-rw-r--r--chrome/browser/cocoa/cookies_window_controller.mm8
-rw-r--r--chrome/browser/cocoa/cookies_window_controller_unittest.mm52
4 files changed, 222 insertions, 21 deletions
diff --git a/chrome/app/nibs/Cookies.xib b/chrome/app/nibs/Cookies.xib
index b8e9ae4..de9ab40 100644
--- a/chrome/app/nibs/Cookies.xib
+++ b/chrome/app/nibs/Cookies.xib
@@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="130"/>
+ <integer value="5"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -41,7 +41,7 @@
<object class="NSWindowTemplate" id="1005">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{476, 247}, {499, 524}}</string>
+ <string key="NSWindowRect">{{476, 219}, {499, 552}}</string>
<int key="NSWTFlags">544735232</int>
<string key="NSWindowTitle">^IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE</string>
<string key="NSWindowClass">NSWindow</string>
@@ -56,7 +56,7 @@
<object class="NSTextField" id="91932637">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">268</int>
- <string key="NSFrame">{{17, 499}, {465, 17}}</string>
+ <string key="NSFrame">{{17, 527}, {465, 17}}</string>
<reference key="NSSuperview" ref="1006"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="901192651">
@@ -138,9 +138,9 @@
</object>
<object class="NSTextFieldCell" key="NSDataCell" id="363879356">
<int key="NSCellFlags">69336641</int>
- <int key="NSCellFlags2">2048</int>
+ <int key="NSCellFlags2">133120</int>
<string key="NSContents">Text Cell</string>
- <reference key="NSSupport" ref="743256162"/>
+ <reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="120560"/>
<object class="NSColor" key="NSBackgroundColor" id="657409763">
<int key="NSColorSpace">6</int>
@@ -170,7 +170,7 @@
<bytes key="NSWhite">MC41AA</bytes>
</object>
</object>
- <double key="NSRowHeight">17</double>
+ <double key="NSRowHeight">14</double>
<int key="NSTvFlags">-767557632</int>
<reference key="NSDelegate"/>
<reference key="NSDataSource"/>
@@ -191,9 +191,9 @@
<object class="NSScroller" id="342557255">
<reference key="NSNextResponder" ref="1002552068"/>
<int key="NSvFlags">-2147483392</int>
- <string key="NSFrame">{{443, 1}, {15, 222}}</string>
+ <string key="NSFrame">{{447, 1}, {11, 222}}</string>
<reference key="NSSuperview" ref="1002552068"/>
- <int key="NSsFlags">512</int>
+ <int key="NSsFlags">256</int>
<reference key="NSTarget" ref="1002552068"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">1</double>
@@ -201,22 +201,23 @@
<object class="NSScroller" id="33257460">
<reference key="NSNextResponder" ref="1002552068"/>
<int key="NSvFlags">-2147483392</int>
- <string key="NSFrame">{{1, 223}, {442, 15}}</string>
+ <string key="NSFrame">{{1, 223}, {446, 15}}</string>
<reference key="NSSuperview" ref="1002552068"/>
<int key="NSsFlags">513</int>
<reference key="NSTarget" ref="1002552068"/>
<string key="NSAction">_doScroller:</string>
+ <double key="NSCurValue">0.035010940919037198</double>
<double key="NSPercent">1</double>
</object>
</object>
- <string key="NSFrame">{{20, 252}, {459, 239}}</string>
+ <string key="NSFrame">{{20, 250}, {459, 239}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSNextKeyView" ref="68591532"/>
<int key="NSsFlags">562</int>
<reference key="NSVScroller" ref="342557255"/>
<reference key="NSHScroller" ref="33257460"/>
<reference key="NSContentView" ref="68591532"/>
- <bytes key="NSScrollAmts">QSAAAEEgAABBoAAAQaAAAA</bytes>
+ <bytes key="NSScrollAmts">QSAAAEEgAABBiAAAQYgAAA</bytes>
</object>
<object class="NSBox" id="271096905">
<reference key="NSNextResponder" ref="1006"/>
@@ -481,7 +482,7 @@
<reference key="NSSuperview" ref="271096905"/>
</object>
</object>
- <string key="NSFrame">{{17, 47}, {465, 191}}</string>
+ <string key="NSFrame">{{17, 45}, {465, 191}}</string>
<reference key="NSSuperview" ref="1006"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
@@ -489,7 +490,7 @@
<int key="NSCellFlags2">0</int>
<string key="NSContents">Box</string>
<reference key="NSSupport" ref="26"/>
- <object class="NSColor" key="NSBackgroundColor">
+ <object class="NSColor" key="NSBackgroundColor" id="973119454">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">textBackgroundColor</string>
@@ -552,7 +553,7 @@
</object>
</object>
</object>
- <string key="NSFrame">{{0, -3}, {235, 51}}</string>
+ <string key="NSFrame">{{0, -5}, {235, 51}}</string>
<reference key="NSSuperview" ref="1006"/>
<string key="NSClassName">GTMWidthBasedTweaker</string>
</object>
@@ -582,12 +583,75 @@
</object>
</object>
</object>
- <string key="NSFrame">{{375, -3}, {124, 51}}</string>
+ <string key="NSFrame">{{375, -5}, {124, 51}}</string>
<reference key="NSSuperview" ref="1006"/>
<string key="NSClassName">GTMWidthBasedTweaker</string>
</object>
+ <object class="NSSearchField" id="597690044">
+ <reference key="NSNextResponder" ref="1006"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{20, 499}, {459, 22}}</string>
+ <reference key="NSSuperview" ref="1006"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSSearchFieldCell" key="NSCell" id="3052569">
+ <int key="NSCellFlags">343014976</int>
+ <int key="NSCellFlags2">272630848</int>
+ <string key="NSContents"/>
+ <reference key="NSSupport" ref="743256162"/>
+ <string key="NSPlaceholderString">^IDS_COOKIES_SEARCH_LABEL</string>
+ <reference key="NSControlView" ref="597690044"/>
+ <bool key="NSDrawsBackground">YES</bool>
+ <int key="NSTextBezelStyle">1</int>
+ <reference key="NSBackgroundColor" ref="973119454"/>
+ <reference key="NSTextColor" ref="593135112"/>
+ <object class="NSButtonCell" key="NSSearchButtonCell">
+ <int key="NSCellFlags">130560</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">search</string>
+ <reference key="NSControlView" ref="597690044"/>
+ <string key="NSAction">_searchFieldSearch:</string>
+ <reference key="NSTarget" ref="3052569"/>
+ <int key="NSButtonFlags">138690815</int>
+ <int key="NSButtonFlags2">0</int>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ </object>
+ <object class="NSButtonCell" key="NSCancelButtonCell">
+ <int key="NSCellFlags">130560</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">clear</string>
+ <object class="NSMutableArray" key="NSAccessibilityOverriddenAttributes">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableDictionary">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>AXDescription</string>
+ <string>NSAccessibilityEncodedAttributesValueType</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>cancel</string>
+ <integer value="1"/>
+ </object>
+ </object>
+ </object>
+ <reference key="NSControlView" ref="597690044"/>
+ <string key="NSAction">_searchFieldCancel:</string>
+ <reference key="NSTarget" ref="3052569"/>
+ <int key="NSButtonFlags">138690815</int>
+ <int key="NSButtonFlags2">0</int>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ </object>
+ <int key="NSMaximumRecents">255</int>
+ <bytes key="NSSearchFieldFlags">CAAAAA</bytes>
+ </object>
+ </object>
</object>
- <string key="NSFrameSize">{499, 524}</string>
+ <string key="NSFrameSize">{499, 552}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
@@ -999,6 +1063,30 @@
</object>
<int key="connectionID">176</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">updateFilter:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="597690044"/>
+ </object>
+ <int key="connectionID">179</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">searchField_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="597690044"/>
+ </object>
+ <int key="connectionID">180</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">outlineView_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="120560"/>
+ </object>
+ <int key="connectionID">181</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1046,6 +1134,7 @@
<reference ref="271096905"/>
<reference ref="585842275"/>
<reference ref="351729448"/>
+ <reference ref="597690044"/>
</object>
<reference key="parent" ref="1005"/>
</object>
@@ -1419,6 +1508,20 @@
<reference key="object" ref="505547508"/>
<reference key="parent" ref="0"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">177</int>
+ <reference key="object" ref="597690044"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="3052569"/>
+ </object>
+ <reference key="parent" ref="1006"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">178</int>
+ <reference key="object" ref="3052569"/>
+ <reference key="parent" ref="597690044"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1445,6 +1548,8 @@
<string>15.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
<string>17.IBPluginDependency</string>
+ <string>177.IBPluginDependency</string>
+ <string>178.IBPluginDependency</string>
<string>18.IBPluginDependency</string>
<string>19.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
@@ -1490,9 +1595,9 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{498, 183}, {499, 524}}</string>
+ <string>{{498, 155}, {499, 552}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{498, 183}, {499, 524}}</string>
+ <string>{{498, 155}, {499, 552}}</string>
<boolean value="NO"/>
<string>{196, 240}</string>
<string>{{357, 418}, {480, 270}}</string>
@@ -1546,6 +1651,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
@@ -1564,7 +1671,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">176</int>
+ <int key="maxID">181</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1587,17 +1694,30 @@
<string>closeSheet:</string>
<string>deleteAllCookies:</string>
<string>deleteCookie:</string>
+ <string>updateFilter:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
- <string key="NS.key.0">treeController_</string>
- <string key="NS.object.0">NSTreeController</string>
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>outlineView_</string>
+ <string>searchField_</string>
+ <string>treeController_</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSOutlineView</string>
+ <string>NSSearchField</string>
+ <string>NSTreeController</string>
+ </object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
@@ -2337,6 +2457,22 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">NSSearchField</string>
+ <string key="superclassName">NSTextField</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSSearchField.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSSearchFieldCell</string>
+ <string key="superclassName">NSTextFieldCell</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSSearchFieldCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">NSTableColumn</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
diff --git a/chrome/browser/cocoa/cookies_window_controller.h b/chrome/browser/cocoa/cookies_window_controller.h
index 0ddd6c6..47af458 100644
--- a/chrome/browser/cocoa/cookies_window_controller.h
+++ b/chrome/browser/cocoa/cookies_window_controller.h
@@ -85,6 +85,8 @@ class CookiesTreeModelObserverBridge : public TreeModelObserver {
BOOL removeButtonEnabled_;
IBOutlet NSTreeController* treeController_;
+ IBOutlet NSOutlineView* outlineView_;
+ IBOutlet NSSearchField* searchField_;
Profile* profile_; // weak
BrowsingDataLocalStorageHelper* storageHelper_; // weak
@@ -99,6 +101,9 @@ class CookiesTreeModelObserverBridge : public TreeModelObserver {
// Shows the cookies window as a modal sheet attached to |window|.
- (void)attachSheetTo:(NSWindow*)window;
+// Updates the filter from the search field.
+- (IBAction)updateFilter:(id)sender;
+
// Delete cookie actions.
- (IBAction)deleteCookie:(id)sender;
- (IBAction)deleteAllCookies:(id)sender;
diff --git a/chrome/browser/cocoa/cookies_window_controller.mm b/chrome/browser/cocoa/cookies_window_controller.mm
index 998edf4..a8a7a31 100644
--- a/chrome/browser/cocoa/cookies_window_controller.mm
+++ b/chrome/browser/cocoa/cookies_window_controller.mm
@@ -167,6 +167,8 @@ CocoaCookieTreeNode* CookiesTreeModelObserverBridge::FindCocoaNode(
}
- (void)windowWillClose:(NSNotification*)notif {
+ [searchField_ setTarget:nil];
+ [outlineView_ setDelegate:nil];
[self autorelease];
}
@@ -185,6 +187,12 @@ CocoaCookieTreeNode* CookiesTreeModelObserverBridge::FindCocoaNode(
[sheet orderOut:self];
}
+- (IBAction)updateFilter:(id)sender {
+ DCHECK([sender isKindOfClass:[NSSearchField class]]);
+ NSString* string = [sender stringValue];
+ treeModel_->UpdateSearchResults(base::SysNSStringToWide(string));
+}
+
- (IBAction)deleteCookie:(id)sender {
NSIndexPath* selectionPath = [treeController_ selectionIndexPath];
// N.B.: I suspect that |-selectedObjects| does not retain/autorelease the
diff --git a/chrome/browser/cocoa/cookies_window_controller_unittest.mm b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
index de009c4..5e127a3 100644
--- a/chrome/browser/cocoa/cookies_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/cookies_window_controller_unittest.mm
@@ -501,4 +501,56 @@ TEST_F(CookiesWindowControllerTest, RemoveButtonEnabled) {
[controller closeSheet:nil];
}
+TEST_F(CookiesWindowControllerTest, UpdateFilter)
+{
+ const GURL url = GURL("http://foo.com");
+ TestingProfile* profile = browser_helper_.profile();
+ net::CookieMonster* cm = profile->GetCookieMonster();
+ cm->SetCookie(GURL("http://a.com"), "A=B");
+ cm->SetCookie(GURL("http://aa.com"), "C=D");
+ cm->SetCookie(GURL("http://b.com"), "E=F");
+ cm->SetCookie(GURL("http://d.com"), "G=H");
+ cm->SetCookie(GURL("http://dd.com"), "I=J");
+
+ controller_.reset(
+ [[CookiesWindowController alloc] initWithProfile:profile
+ storageHelper:local_storage_helper_]);
+
+ // Make sure we registered all five cookies.
+ EXPECT_EQ(5U, [[[controller_ cocoaTreeModel] childs] count]);
+
+ NSSearchField* field =
+ [[NSSearchField alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
+
+ // Make sure we still have five cookies.
+ [field setStringValue:@""];
+ [controller_ updateFilter:field];
+ EXPECT_EQ(5U, [[[controller_ cocoaTreeModel] childs] count]);
+
+ // Search for "a".
+ [field setStringValue:@"a"];
+ [controller_ updateFilter:field];
+ EXPECT_EQ(2U, [[[controller_ cocoaTreeModel] childs] count]);
+
+ // Search for "b".
+ [field setStringValue:@"b"];
+ [controller_ updateFilter:field];
+ EXPECT_EQ(1U, [[[controller_ cocoaTreeModel] childs] count]);
+
+ // Search for "d".
+ [field setStringValue:@"d"];
+ [controller_ updateFilter:field];
+ EXPECT_EQ(2U, [[[controller_ cocoaTreeModel] childs] count]);
+
+ // Search for "e".
+ [field setStringValue:@"e"];
+ [controller_ updateFilter:field];
+ EXPECT_EQ(0U, [[[controller_ cocoaTreeModel] childs] count]);
+
+ // Search for "aa".
+ [field setStringValue:@"aa"];
+ [controller_ updateFilter:field];
+ EXPECT_EQ(1U, [[[controller_ cocoaTreeModel] childs] count]);
+}
+
} // namespace