diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 01:09:25 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 01:09:25 +0000 |
commit | 730aef2589a2e544797931eab99ea3d770040d99 (patch) | |
tree | a1563f19f90580aa02840a13a8139674c08251a1 | |
parent | 180d0acbeadc434f7a855442e5f4a2c7bcc89d5a (diff) | |
download | chromium_src-730aef2589a2e544797931eab99ea3d770040d99.zip chromium_src-730aef2589a2e544797931eab99ea3d770040d99.tar.gz chromium_src-730aef2589a2e544797931eab99ea3d770040d99.tar.bz2 |
Enable and implement last 2 items in bookmark bar context menu: "Open
All In New Window" and "Open All In Incognito Window" (17616).
Bookmark Folders have the bar context menu, not the bookmark context
menu (26748).
Disable bookmark manager item on bookmark contextual menus (26944).
BUG=http://crbug.com/17616, http://crbug.com/26748, http://crbug.com/26944
TEST=Add some bookmarks.
Make sure "Open All In New Window" and "Open All In Incognito Window" work from the bar context menu.
Add a bookmark folder.
Make sure the context menu of the folder is the bar conetxt menu, not the 'mark context menu.
Make sure Bookmark Manager item is DISabled in both context menus.
nib change: hook up actions in the "Open All Blah" items just like the normal "Open All".
Review URL: http://codereview.chromium.org/373022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31748 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/nibs/BookmarkBar.xib | 594 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.h | 17 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 79 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller_unittest.mm | 73 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 9 |
8 files changed, 626 insertions, 155 deletions
diff --git a/chrome/app/nibs/BookmarkBar.xib b/chrome/app/nibs/BookmarkBar.xib index 3f2075c..127d24f 100644 --- a/chrome/app/nibs/BookmarkBar.xib +++ b/chrome/app/nibs/BookmarkBar.xib @@ -1,21 +1,34 @@ <?xml version="1.0" encoding="UTF-8"?> -<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02"> +<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9L30</string> - <string key="IBDocument.InterfaceBuilderVersion">670</string> - <string key="IBDocument.AppKitVersion">949.54</string> - <string key="IBDocument.HIToolboxVersion">353.00</string> + <string key="IBDocument.SystemVersion">10B504</string> + <string key="IBDocument.InterfaceBuilderVersion">732</string> + <string key="IBDocument.AppKitVersion">1038.2</string> + <string key="IBDocument.HIToolboxVersion">437.00</string> + <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> + <string key="NS.object.0">732</string> + </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="18"/> - <integer value="62"/> <integer value="4"/> + <integer value="62"/> + <integer value="18"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> </object> + <object class="NSMutableDictionary" key="IBDocument.Metadata"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys" id="0"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSCustomObject" id="1001"> @@ -49,7 +62,7 @@ <string key="NSContents">^IDS_BOOKMARKS_NO_ITEMS</string> <object class="NSFont" key="NSSupport"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">1.100000e+01</double> + <double key="NSSize">11</double> <int key="NSfFlags">3100</int> </object> <reference key="NSControlView" ref="1013234954"/> @@ -59,7 +72,7 @@ <string key="NSColorName">controlColor</string> <object class="NSColor" key="NSColor"> <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes> + <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> </object> </object> <object class="NSColor" key="NSTextColor"> @@ -373,22 +386,6 @@ <object class="IBActionConnection" key="connection"> <string key="label">commandDispatch:</string> <reference key="source" ref="1003"/> - <reference key="destination" ref="115646576"/> - </object> - <int key="connectionID">33</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">commandDispatch:</string> - <reference key="source" ref="1003"/> - <reference key="destination" ref="509003741"/> - </object> - <int key="connectionID">34</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">commandDispatch:</string> - <reference key="source" ref="1003"/> <reference key="destination" ref="112128065"/> </object> <int key="connectionID">35</int> @@ -633,34 +630,48 @@ </object> <int key="connectionID">98</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">openAllBookmarksNewWindow:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="115646576"/> + </object> + <int key="connectionID">99</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">openAllBookmarksIncognitoWindow:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="509003741"/> + </object> + <int key="connectionID">100</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBObjectRecord"> <int key="objectID">0</int> - <object class="NSArray" key="object" id="360811110"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> + <reference key="object" ref="0"/> <reference key="children" ref="1000"/> <nil key="parent"/> </object> <object class="IBObjectRecord"> <int key="objectID">-2</int> <reference key="object" ref="1001"/> - <reference key="parent" ref="360811110"/> - <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> + <reference key="parent" ref="0"/> + <string key="objectName">File's Owner</string> </object> <object class="IBObjectRecord"> <int key="objectID">-1</int> <reference key="object" ref="1003"/> - <reference key="parent" ref="360811110"/> + <reference key="parent" ref="0"/> <string key="objectName">First Responder</string> </object> <object class="IBObjectRecord"> <int key="objectID">-3</int> <reference key="object" ref="1004"/> - <reference key="parent" ref="360811110"/> + <reference key="parent" ref="0"/> <string key="objectName">Application</string> </object> <object class="IBObjectRecord"> @@ -671,7 +682,7 @@ <reference ref="610146462"/> <reference ref="1071220197"/> </object> - <reference key="parent" ref="360811110"/> + <reference key="parent" ref="0"/> </object> <object class="IBObjectRecord"> <int key="objectID">4</int> @@ -691,7 +702,7 @@ <reference ref="23014313"/> <reference ref="149427359"/> </object> - <reference key="parent" ref="360811110"/> + <reference key="parent" ref="0"/> <string key="objectName">Bar Menu</string> </object> <object class="IBObjectRecord"> @@ -773,7 +784,7 @@ <reference ref="1071747565"/> <reference ref="377013426"/> </object> - <reference key="parent" ref="360811110"/> + <reference key="parent" ref="0"/> <string key="objectName">Button Menu</string> </object> <object class="IBObjectRecord"> @@ -862,7 +873,7 @@ <object class="IBObjectRecord"> <int key="objectID">72</int> <reference key="object" ref="849863465"/> - <reference key="parent" ref="360811110"/> + <reference key="parent" ref="0"/> </object> <object class="IBObjectRecord"> <int key="objectID">75</int> @@ -871,7 +882,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="582055256"/> </object> - <reference key="parent" ref="360811110"/> + <reference key="parent" ref="0"/> <string key="objectName">Off-the-side Menu</string> </object> <object class="IBObjectRecord"> @@ -902,7 +913,7 @@ </object> <object class="NSMutableDictionary" key="flattenedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>-1.IBPluginDependency</string> <string>-2.IBPluginDependency</string> @@ -964,7 +975,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{364, 332}, {365, 233}}</string> + <string>{{364, 332}, {362, 233}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -978,7 +989,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{40, 636}, {375, 213}}</string> + <string>{{40, 636}, {372, 213}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -1001,9 +1012,7 @@ </object> <object class="NSMutableDictionary" key="unlocalizedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> + <reference key="dict.sortedKeys" ref="0"/> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> @@ -1011,15 +1020,13 @@ <nil key="activeLocalization"/> <object class="NSMutableDictionary" key="localizations"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> - <bool key="EncodedWithXMLCoder">YES</bool> - </object> + <reference key="dict.sortedKeys" ref="0"/> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> </object> <nil key="sourceID"/> - <int key="maxID">98</int> + <int key="maxID">100</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -1037,7 +1044,7 @@ <string key="superclassName">NSViewController</string> <object class="NSMutableDictionary" key="actions"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>addFolder:</string> <string>addPage:</string> @@ -1045,6 +1052,8 @@ <string>deleteBookmark:</string> <string>editBookmark:</string> <string>openAllBookmarks:</string> + <string>openAllBookmarksIncognitoWindow:</string> + <string>openAllBookmarksNewWindow:</string> <string>openBookmark:</string> <string>openBookmarkInIncognitoWindow:</string> <string>openBookmarkInNewForegroundTab:</string> @@ -1064,18 +1073,19 @@ <string>id</string> <string>id</string> <string>id</string> + <string>id</string> + <string>id</string> </object> </object> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>buttonContextMenu_</string> <string>buttonView_</string> <string>compressDelegate_</string> <string>offTheSideButton_</string> <string>resizeDelegate_</string> - <string>urlDelegate_</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -1084,7 +1094,6 @@ <string>id</string> <string>MenuButton</string> <string>id</string> - <string>id</string> </object> </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> @@ -1109,7 +1118,7 @@ <string key="superclassName">NSView</string> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>controller_</string> <string>noItemTextfield_</string> @@ -1158,7 +1167,7 @@ <string key="superclassName">NSObject</string> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>otherObjectToLocalize_</string> <string>owner_</string> @@ -1222,7 +1231,7 @@ <string key="superclassName">NSViewController</string> <object class="NSMutableDictionary" key="actions"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>closeTab:</string> <string>commandDispatch:</string> @@ -1235,7 +1244,7 @@ </object> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSMutableArray" key="dict.sortedKeys"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>closeButton_</string> <string>contextMenu_</string> @@ -1258,8 +1267,483 @@ </object> </object> </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">NSActionCell</string> + <string key="superclassName">NSCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <string key="superclassName">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="801885704"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSApplication.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="447441832"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSApplicationScripting.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="975965104"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSColorPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSHelpManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSPageLayout.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSApplication</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSUserInterfaceItemSearching.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSButton</string> + <string key="superclassName">NSControl</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSButton.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSButtonCell</string> + <string key="superclassName">NSActionCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSCell</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSControl</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="110824619"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSControl.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSFormatter</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSMenu</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="1018913278"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSMenu.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSMenuItem</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="921599287"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSMenuItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSAccessibility.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="801885704"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="447441832"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="975965104"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="110824619"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDictionaryController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSDragging.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSFontPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSKeyValueBinding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <reference key="sourceIdentifier" ref="1018913278"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSNibLoading.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSOutlineView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSPasteboard.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSSavePanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTableView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSToolbarItem.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="602172652"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSError.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObject.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSThread.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURL.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CAAnimation.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CALayer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">QuartzCore.framework/Headers/CIImageProvider.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">SecurityInterface.framework/Headers/SFAuthorizationView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">SecurityInterface.framework/Headers/SFCertificatePanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">SecurityInterface.framework/Headers/SFChooseIdentityPanel.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSResponder</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSInterfaceStyle.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSResponder</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSTextField</string> + <string key="superclassName">NSControl</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTextField.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSTextFieldCell</string> + <string key="superclassName">NSActionCell</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSClipView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <reference key="sourceIdentifier" ref="921599287"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSRulerView.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSView</string> + <string key="superclassName">NSResponder</string> + <reference key="sourceIdentifier" ref="602172652"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSViewController</string> + <string key="superclassName">NSResponder</string> + <object class="NSMutableDictionary" key="outlets"> + <string key="NS.key.0">view</string> + <string key="NS.object.0">NSView</string> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBFrameworkSource</string> + <string key="minorKey">AppKit.framework/Headers/NSViewController.h</string> + </object> + </object> + </object> </object> <int key="IBDocument.localizationMode">0</int> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> + <integer value="1050" key="NS.object.0"/> + </object> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> + <integer value="1050" key="NS.object.0"/> + </object> + <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> + <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string> + <integer value="3000" key="NS.object.0"/> + </object> + <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> <string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string> <int key="IBDocument.defaultPropertyAccessControl">3</int> </data> diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index f2c8f76..7010deb 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -2410,7 +2410,9 @@ void Browser::InitCommandState() { command_updater_.UpdateCommandEnabled(IDC_TASK_MANAGER, true); command_updater_.UpdateCommandEnabled(IDC_SELECT_PROFILE, true); command_updater_.UpdateCommandEnabled(IDC_SHOW_HISTORY, true); +#if !defined(OS_MACOSX) // http://crbug.com/13149 command_updater_.UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true); +#endif command_updater_.UpdateCommandEnabled(IDC_SHOW_EXTENSION_SHELF, true); command_updater_.UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); command_updater_.UpdateCommandEnabled(IDC_HELP_PAGE, true); diff --git a/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm b/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm index 627775a..2b03429 100644 --- a/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm @@ -23,8 +23,7 @@ typedef std::pair<GURL,WindowOpenDisposition> OpenInfo; // Objective-C declarations may only appear in global scope") // Oddly, we are our own delegate. -@interface FakeBookmarkBarController : - BookmarkBarController<BookmarkURLOpener> { +@interface FakeBookmarkBarController : BookmarkBarController { @public scoped_nsobject<NSMutableArray> callbacks_; std::vector<OpenInfo> opens_; @@ -37,8 +36,7 @@ typedef std::pair<GURL,WindowOpenDisposition> OpenInfo; if ((self = [super initWithBrowser:browser initialWidth:100 // arbitrary compressDelegate:nil - resizeDelegate:nil - urlDelegate:self])) { + resizeDelegate:nil])) { callbacks_.reset([[NSMutableArray alloc] init]); } return self; diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h index 07d961a..3134353 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.h +++ b/chrome/browser/cocoa/bookmark_bar_controller.h @@ -42,12 +42,6 @@ const CGFloat kNoBookmarksNTPVerticalOffset = 27.0; } // namespace -// The interface for an object which can open URLs for a bookmark. -@protocol BookmarkURLOpener -- (void)openBookmarkURL:(const GURL&)url - disposition:(WindowOpenDisposition)disposition; -@end - // A controller for the bookmark bar in the browser window. Handles showing // and hiding based on the preference in the given profile. @interface BookmarkBarController : @@ -91,9 +85,6 @@ const CGFloat kNoBookmarksNTPVerticalOffset = 27.0; // Delegate that can resize us. id<ViewResizer> resizeDelegate_; // weak - // Delegate that can open URLs for us. - id<BookmarkURLOpener> urlDelegate_; // weak - // Lets us get TabSelectedAt notifications. scoped_ptr<TabStripModelObserverBridge> tabObserver_; @@ -110,8 +101,7 @@ const CGFloat kNoBookmarksNTPVerticalOffset = 27.0; - (id)initWithBrowser:(Browser*)browser initialWidth:(float)initialWidth compressDelegate:(id<ToolbarCompressable>)compressDelegate - resizeDelegate:(id<ViewResizer>)resizeDelegate - urlDelegate:(id<BookmarkURLOpener>)urlDelegate; + resizeDelegate:(id<ViewResizer>)resizeDelegate; // Returns the backdrop to the bookmark bar. - (BackgroundGradientView*)backgroundGradientView; @@ -159,6 +149,8 @@ const CGFloat kNoBookmarksNTPVerticalOffset = 27.0; - (IBAction)deleteBookmark:(id)sender; // From a context menu over the bar, ... - (IBAction)openAllBookmarks:(id)sender; +- (IBAction)openAllBookmarksNewWindow:(id)sender; +- (IBAction)openAllBookmarksIncognitoWindow:(id)sender; // Or from a context menu over either the bar or a button. - (IBAction)addPage:(id)sender; - (IBAction)addFolder:(id)sender; @@ -188,8 +180,7 @@ const CGFloat kNoBookmarksNTPVerticalOffset = 27.0; // These APIs should only be used by unit tests (or used internally). @interface BookmarkBarController(InternalOrTestingAPI) -// Set the delegate for a unit test. -- (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate; +- (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition; - (NSCell*)cellForBookmarkNode:(const BookmarkNode*)node; - (void)clearBookmarkBar; - (BookmarkBarView*)buttonView; diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index 8a8bb95..7a616de 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -23,6 +23,7 @@ #import "chrome/browser/cocoa/menu_button.h" #import "chrome/browser/cocoa/toolbar_controller.h" #import "chrome/browser/cocoa/view_resizer.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" @@ -64,8 +65,7 @@ - (id)initWithBrowser:(Browser*)browser initialWidth:(float)initialWidth compressDelegate:(id<ToolbarCompressable>)compressDelegate - resizeDelegate:(id<ViewResizer>)resizeDelegate - urlDelegate:(id<BookmarkURLOpener>)urlDelegate { + resizeDelegate:(id<ViewResizer>)resizeDelegate { if ((self = [super initWithNibName:@"BookmarkBar" bundle:mac_util::MainAppBundle()])) { browser_ = browser; @@ -74,7 +74,6 @@ buttons_.reset([[NSMutableArray alloc] init]); compressDelegate_ = compressDelegate; resizeDelegate_ = resizeDelegate; - urlDelegate_ = urlDelegate; tabObserver_.reset( new TabStripModelObserverBridge(browser_->tabstrip_model(), self)); @@ -305,22 +304,31 @@ return node; } -// At this time, the only item which ever gets disabled is "Open All -// Bookmarks". +// At this time, the only items which ever get disabled are the "Open All +// Bookmarks" options. - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { SEL action = [item action]; - if ((action == @selector(openAllBookmarks:)) && + if (((action == @selector(openAllBookmarks:)) || + (action == @selector(openAllBookmarksNewWindow:)) || + (action == @selector(openAllBookmarksIncognitoWindow:))) && (![buttons_ count])) { return NO; } return YES; } +// Actually open the URL. This is the last chance for a unit test to +// override. +- (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition { + BrowserList::GetLastActive()->OpenURL(url, GURL(), disposition, + PageTransition::AUTO_BOOKMARK); +} + - (IBAction)openBookmark:(id)sender { BookmarkNode* node = [self nodeFromButton:sender]; - [urlDelegate_ openBookmarkURL:node->GetURL() - disposition:event_utils::WindowOpenDispositionFromNSEvent( - [NSApp currentEvent])]; + WindowOpenDisposition disposition = + event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); + [self openURL:node->GetURL() disposition:disposition]; } // Given a NSMenuItem tag, return the appropriate bookmark node id. @@ -475,17 +483,17 @@ - (IBAction)openBookmarkInNewForegroundTab:(id)sender { BookmarkNode* node = [self nodeFromMenuItem:sender]; - [urlDelegate_ openBookmarkURL:node->GetURL() disposition:NEW_FOREGROUND_TAB]; + [self openURL:node->GetURL() disposition:NEW_FOREGROUND_TAB]; } - (IBAction)openBookmarkInNewWindow:(id)sender { BookmarkNode* node = [self nodeFromMenuItem:sender]; - [urlDelegate_ openBookmarkURL:node->GetURL() disposition:NEW_WINDOW]; + [self openURL:node->GetURL() disposition:NEW_WINDOW]; } - (IBAction)openBookmarkInIncognitoWindow:(id)sender { BookmarkNode* node = [self nodeFromMenuItem:sender]; - [urlDelegate_ openBookmarkURL:node->GetURL() disposition:OFF_THE_RECORD]; + [self openURL:node->GetURL() disposition:OFF_THE_RECORD]; } - (IBAction)editBookmark:(id)sender { @@ -533,14 +541,19 @@ node->GetParent()->IndexOfChild(node)); } -- (void)openBookmarkNodesRecursive:(BookmarkNode*)node { +// An ObjC version of bookmark_utils::OpenAllImpl(). +- (void)openBookmarkNodesRecursive:(BookmarkNode*)node + disposition:(WindowOpenDisposition)disposition { for (int i = 0; i < node->GetChildCount(); i++) { BookmarkNode* child = node->GetChild(i); - if (child->is_url()) - [urlDelegate_ openBookmarkURL:child->GetURL() - disposition:NEW_BACKGROUND_TAB]; - else - [self openBookmarkNodesRecursive:child]; + if (child->is_url()) { + [self openURL:child->GetURL() disposition:disposition]; + // We revert to a basic disposition in case the initial + // disposition opened a new window. + disposition = NEW_BACKGROUND_TAB; + } else { + [self openBookmarkNodesRecursive:child disposition:disposition]; + } } } @@ -548,9 +561,24 @@ // TODO(jrg): // Is there an easier way to get a non-const root node for the bookmark bar? // I can't iterate over them unless it's non-const. + BookmarkNode* node = const_cast<BookmarkNode*>( + bookmarkModel_->GetBookmarkBarNode()); + [self openBookmarkNodesRecursive:node disposition:NEW_FOREGROUND_TAB]; + UserMetrics::RecordAction(L"OpenAllBookmarks", browser_->profile()); +} + +- (IBAction)openAllBookmarksNewWindow:(id)sender { + BookmarkNode* node = const_cast<BookmarkNode*>( + bookmarkModel_->GetBookmarkBarNode()); + [self openBookmarkNodesRecursive:node disposition:NEW_WINDOW]; + UserMetrics::RecordAction(L"OpenAllBookmarksNewWindow", browser_->profile()); +} - BookmarkNode* node = (BookmarkNode*)bookmarkModel_->GetBookmarkBarNode(); - [self openBookmarkNodesRecursive:node]; +- (IBAction)openAllBookmarksIncognitoWindow:(id)sender { + BookmarkNode* node = const_cast<BookmarkNode*>( + bookmarkModel_->GetBookmarkBarNode()); + [self openBookmarkNodesRecursive:node disposition:OFF_THE_RECORD]; + UserMetrics::RecordAction(L"OpenAllBookmarksIncognitoWindow", browser_->profile()); } // May be called from the bar or from a folder button. @@ -600,7 +628,10 @@ NSImage* image = [self getFavIconForNode:node]; [cell setBookmarkCellText:title image:image]; - [cell setMenu:buttonContextMenu_]; + if (node->is_folder()) + [cell setMenu:[[self view] menu]]; + else + [cell setMenu:buttonContextMenu_]; return cell; } @@ -670,7 +701,7 @@ const BookmarkNode* node = bookmarkModel_->GetNodeByID(tag); WindowOpenDisposition disposition = event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); - [urlDelegate_ openBookmarkURL:node->GetURL() disposition:disposition]; + [self openURL:node->GetURL() disposition:disposition]; } // Create buttons for all items in the bookmark node tree. @@ -880,10 +911,6 @@ [self loaded:model]; } -- (void)setUrlDelegate:(id<BookmarkURLOpener>)urlDelegate { - urlDelegate_ = urlDelegate; -} - - (NSArray*)buttons { return buttons_.get(); } diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm index 5f645bf..5bfd58c 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm @@ -19,17 +19,16 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" -// Pretend BookmarkURLOpener delegate to keep track of requests -@interface BookmarkURLOpenerPong : NSObject<BookmarkURLOpener> { +// Just like a BookmarkBarController but openURL: is stubbed out. +@interface BookmarkBarControllerNoOpen : BookmarkBarController { @public std::vector<GURL> urls_; std::vector<WindowOpenDisposition> dispositions_; } @end -@implementation BookmarkURLOpenerPong -- (void)openBookmarkURL:(const GURL&)url - disposition:(WindowOpenDisposition)disposition { +@implementation BookmarkBarControllerNoOpen +- (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition { urls_.push_back(url); dispositions_.push_back(disposition); } @@ -63,7 +62,7 @@ @end // Remember the number of times we've gotten a frameDidChange notification. -@interface BookmarkBarControllerTogglePong : BookmarkBarController { +@interface BookmarkBarControllerTogglePong : BookmarkBarControllerNoOpen { @private int toggles_; } @@ -81,7 +80,7 @@ @end // A BookmarkBarController that always beleives that it's on the new tab page. -@interface AlwaysNewTabPageBookmarkBarController : BookmarkBarController { +@interface AlwaysNewTabPageBookmarkBarController : BookmarkBarControllerNoOpen { } @end @@ -122,11 +121,11 @@ class BookmarkBarControllerTest : public PlatformTest { parent_view_.reset([[NSView alloc] initWithFrame:parent_frame]); [parent_view_ setHidden:YES]; bar_.reset( - [[BookmarkBarController alloc] initWithBrowser:helper_.browser() - initialWidth:NSWidth(parent_frame) - compressDelegate:compressDelegate_.get() - resizeDelegate:resizeDelegate_.get() - urlDelegate:nil]); + [[BookmarkBarControllerNoOpen alloc] + initWithBrowser:helper_.browser() + initialWidth:NSWidth(parent_frame) + compressDelegate:compressDelegate_.get() + resizeDelegate:resizeDelegate_.get()]); InstallAndToggleBar(bar_.get()); @@ -173,7 +172,7 @@ class BookmarkBarControllerTest : public PlatformTest { BrowserTestHelper helper_; scoped_nsobject<ViewResizerPong> resizeDelegate_; scoped_nsobject<CompressablePong> compressDelegate_; - scoped_nsobject<BookmarkBarController> bar_; + scoped_nsobject<BookmarkBarControllerNoOpen> bar_; scoped_nsobject<NSMenu> menu_; scoped_nsobject<NSMenuItem> menu_item_; scoped_nsobject<NSButtonCell> cell_; @@ -220,8 +219,7 @@ TEST_F(BookmarkBarControllerTest, ShowOnNewTabPage) { initWithBrowser:helper_.browser() initialWidth:800 // arbitrary compressDelegate:compressDelegate_.get() - resizeDelegate:resizeDelegate_.get() - urlDelegate:nil]); + resizeDelegate:resizeDelegate_.get()]); InstallAndToggleBar(bar.get()); [bar setBookmarkBarEnabled:NO]; @@ -267,8 +265,7 @@ TEST_F(BookmarkBarControllerTest, FrameChangeNotification) { initWithBrowser:helper_.browser() initialWidth:100 // arbitrary compressDelegate:compressDelegate_.get() - resizeDelegate:resizeDelegate_.get() - urlDelegate:nil]); + resizeDelegate:resizeDelegate_.get()]); InstallAndToggleBar(bar.get()); // Send a frame did change notification for the pong's view. @@ -371,9 +368,6 @@ TEST_F(BookmarkBarControllerTest, MenuForFolderNode) { TEST_F(BookmarkBarControllerTest, OpenBookmark) { GURL gurl("http://walla.walla.ding.dong.com"); scoped_ptr<BookmarkNode> node(new BookmarkNode(gurl)); - scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc] - init]); - [bar_ setUrlDelegate:pong.get()]; scoped_nsobject<NSButtonCell> cell([[NSButtonCell alloc] init]); scoped_nsobject<NSButton> button([[NSButton alloc] init]); @@ -381,19 +375,13 @@ TEST_F(BookmarkBarControllerTest, OpenBookmark) { [cell setRepresentedObject:[NSValue valueWithPointer:node.get()]]; [bar_ openBookmark:button]; - EXPECT_EQ(pong.get()->urls_[0], node->GetURL()); - EXPECT_EQ(pong.get()->dispositions_[0], CURRENT_TAB); - - [bar_ setUrlDelegate:nil]; + EXPECT_EQ(bar_.get()->urls_[0], node->GetURL()); + EXPECT_EQ(bar_.get()->dispositions_[0], CURRENT_TAB); } // Confirm opening of bookmarks works from the menus (different // dispositions than clicking on the button). TEST_F(BookmarkBarControllerTest, OpenBookmarkFromMenus) { - scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc] - init]); - [bar_ setUrlDelegate:pong.get()]; - const char* urls[] = { "http://walla.walla.ding.dong.com", "http://i_dont_know.com", "http://cee.enn.enn.dot.com" }; @@ -409,11 +397,10 @@ TEST_F(BookmarkBarControllerTest, OpenBookmarkFromMenus) { GURL gurl(urls[i]); [bar_ performSelector:selectors[i] withObject:ItemForBookmarkBarMenu(gurl)]; - EXPECT_EQ(pong.get()->urls_[0], gurl); - EXPECT_EQ(pong.get()->dispositions_[0], dispositions[i]); - [pong clear]; + EXPECT_EQ(bar_.get()->urls_[0], gurl); + EXPECT_EQ(bar_.get()->dispositions_[0], dispositions[i]); + [bar_ clear]; } - [bar_ setUrlDelegate:nil]; } TEST_F(BookmarkBarControllerTest, TestAddRemoveAndClear) { @@ -535,10 +522,6 @@ TEST_F(BookmarkBarControllerTest, DeleteBookmark) { } TEST_F(BookmarkBarControllerTest, OpenAllBookmarks) { - scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc] - init]); - [bar_ setUrlDelegate:pong.get()]; - BookmarkModel* model = helper_.profile()->GetBookmarkModel(); const BookmarkNode* parent = model->GetBookmarkBarNode(); // { one, { two-one, two-two }, three } @@ -555,14 +538,14 @@ TEST_F(BookmarkBarControllerTest, OpenAllBookmarks) { L"title", GURL("https://three.com")); [bar_ openAllBookmarks:nil]; - EXPECT_EQ(pong.get()->urls_.size(), 4U); - EXPECT_EQ(pong.get()->dispositions_.size(), 4U); + EXPECT_EQ(bar_.get()->urls_.size(), 4U); + EXPECT_EQ(bar_.get()->dispositions_.size(), 4U); // I can't use EXPECT_EQ() here since the macro can't expand // properly (no way to print the value of an iterator). std::vector<GURL>::iterator i; - std::vector<GURL>::iterator begin = pong.get()->urls_.begin(); - std::vector<GURL>::iterator end = pong.get()->urls_.end(); + std::vector<GURL>::iterator begin = bar_.get()->urls_.begin(); + std::vector<GURL>::iterator end = bar_.get()->urls_.end(); i = find(begin, end, GURL("http://two-one.com")); EXPECT_FALSE(i == end); i = find(begin, end, GURL("https://three.com")); @@ -570,9 +553,7 @@ TEST_F(BookmarkBarControllerTest, OpenAllBookmarks) { i = find(begin, end, GURL("https://will-not-be-found.com")); EXPECT_TRUE(i == end); - EXPECT_EQ(pong.get()->dispositions_[3], NEW_BACKGROUND_TAB); - - [bar_ setUrlDelegate:nil]; + EXPECT_EQ(bar_.get()->dispositions_[3], NEW_BACKGROUND_TAB); } // TODO(jrg): write a test to confirm that nodeFavIconLoaded calls @@ -612,12 +593,8 @@ TEST_F(BookmarkBarControllerTest, MiddleClick) { NSButton* first = [[bar_ buttons] objectAtIndex:0]; EXPECT_TRUE(first); - scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc] - init]); - [bar_ setUrlDelegate:pong.get()]; [first otherMouseUp:test_event_utils::MakeMouseEvent(NSOtherMouseUp, 0)]; - EXPECT_EQ(pong.get()->urls_.size(), 1U); - [bar_ setUrlDelegate:nil]; + EXPECT_EQ(bar_.get()->urls_.size(), 1U); } TEST_F(BookmarkBarControllerTest, TestBuildOffTheSideMenu) { diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index de3451d..849ba04 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -44,7 +44,6 @@ class TabStripModelObserverBridge; @interface BrowserWindowController : TabWindowController<NSUserInterfaceValidations, - BookmarkURLOpener, BookmarkBubbleControllerDelegate, BrowserCommandExecutor, ViewResizer, diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index b9f6026..b3cc20c 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -177,8 +177,7 @@ willPositionSheet:(NSWindow*)sheet initWithBrowser:browser_.get() initialWidth:NSWidth([[[self window] contentView] frame]) compressDelegate:toolbarController_.get() - resizeDelegate:self - urlDelegate:self]); + resizeDelegate:self]); // Add bookmark bar to the view hierarchy. This also triggers the // nib load. The bookmark bar is defined (in the nib) to be @@ -1045,12 +1044,6 @@ willPositionSheet:(NSWindow*)sheet return savedRegularWindow_ != nil; } -// Called by the bookmark bar to open a URL. -- (void)openBookmarkURL:(const GURL&)url - disposition:(WindowOpenDisposition)disposition { - browser_->OpenURL(url, GURL(), disposition, PageTransition::AUTO_BOOKMARK); -} - - (NSInteger)numberOfTabs { return browser_->tabstrip_model()->count(); } |