diff options
-rw-r--r-- | chrome/app/nibs/BookmarkAllTabs.xib | 458 | ||||
-rw-r--r-- | chrome/app/nibs/BookmarkEditor.xib | 449 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_all_tabs_controller.h | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_all_tabs_controller.mm | 19 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_all_tabs_controller_unittest.mm | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_base_controller.h | 102 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_base_controller.mm | 507 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_base_controller_unittest.mm | 69 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_controller.h | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_controller.mm | 13 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_editor_controller_unittest.mm | 267 |
11 files changed, 1303 insertions, 596 deletions
diff --git a/chrome/app/nibs/BookmarkAllTabs.xib b/chrome/app/nibs/BookmarkAllTabs.xib index 09e68a6..db46a9f 100644 --- a/chrome/app/nibs/BookmarkAllTabs.xib +++ b/chrome/app/nibs/BookmarkAllTabs.xib @@ -1,9 +1,9 @@ <?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.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9L30</string> - <string key="IBDocument.InterfaceBuilderVersion">670</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"> @@ -14,6 +14,15 @@ <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"> + <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"> @@ -26,7 +35,7 @@ <string key="NSClassName">NSApplication</string> </object> <object class="NSWindowTemplate" id="1005"> - <int key="NSWindowStyleMask">15</int> + <int key="NSWindowStyleMask">9</int> <int key="NSWindowBacking">2</int> <string key="NSWindowRect">{{196, 257}, {480, 253}}</string> <int key="NSWTFlags">536870912</int> @@ -40,30 +49,6 @@ <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSBrowser" id="723395462"> - <reference key="NSNextResponder" ref="1006"/> - <int key="NSvFlags">274</int> - <string key="NSFrame">{{20, 60}, {440, 143}}</string> - <reference key="NSSuperview" ref="1006"/> - <bool key="NSEnabled">YES</bool> - <object class="NSBrowserCell" key="NSCellPrototype"> - <int key="NSCellFlags">67239488</int> - <int key="NSCellFlags2">2048</int> - <string key="NSContents"> </string> - <object class="NSFont" key="NSSupport"> - <string key="NSName">LucidaGrande</string> - <double key="NSSize">1.200000e+01</double> - <int key="NSfFlags">16</int> - </object> - </object> - <string key="NSPathSeparator">/</string> - <int key="NSMinColumnWidth">100</int> - <int key="NSNumberOfVisibleColumns">3</int> - <int key="NSColumnResizingType">1</int> - <double key="NSPreferedColumnWidth">1.000000e+02</double> - <bool key="NSAllowsTypeSelect">YES</bool> - <int key="NSBrFlags">1544765440</int> - </object> <object class="NSCustomView" id="138844528"> <reference key="NSNextResponder" ref="1006"/> <int key="NSvFlags">289</int> @@ -139,12 +124,12 @@ <int key="NSColorSpace">6</int> <string key="NSCatalogName">System</string> <string key="NSColorName">controlColor</string> - <object class="NSColor" key="NSColor"> + <object class="NSColor" key="NSColor" id="22454945"> <int key="NSColorSpace">3</int> <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes> </object> </object> - <object class="NSColor" key="NSTextColor"> + <object class="NSColor" key="NSTextColor" id="902444822"> <int key="NSColorSpace">6</int> <string key="NSCatalogName">System</string> <string key="NSColorName">controlTextColor</string> @@ -207,7 +192,7 @@ <int key="NSColorSpace">6</int> <string key="NSCatalogName">System</string> <string key="NSColorName">textBackgroundColor</string> - <object class="NSColor" key="NSColor"> + <object class="NSColor" key="NSColor" id="261602967"> <int key="NSColorSpace">3</int> <bytes key="NSWhite">MQA</bytes> </object> @@ -220,6 +205,156 @@ </object> </object> </object> + <object class="NSScrollView" id="607350872"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">274</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSClipView" id="144860280"> + <reference key="NSNextResponder" ref="607350872"/> + <int key="NSvFlags">2304</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSOutlineView" id="904735886"> + <reference key="NSNextResponder" ref="144860280"/> + <int key="NSvFlags">256</int> + <string key="NSFrameSize">{423, 114}</string> + <reference key="NSSuperview" ref="144860280"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTableHeaderView" key="NSHeaderView" id="329152418"> + <reference key="NSNextResponder" ref="88791154"/> + <int key="NSvFlags">256</int> + <string key="NSFrameSize">{423, 17}</string> + <reference key="NSSuperview" ref="88791154"/> + <reference key="NSTableView" ref="904735886"/> + </object> + <object class="_NSCornerView" key="NSCornerView" id="822439151"> + <reference key="NSNextResponder" ref="607350872"/> + <int key="NSvFlags">256</int> + <string key="NSFrame">{{424, 0}, {16, 17}}</string> + <reference key="NSSuperview" ref="607350872"/> + </object> + <object class="NSMutableArray" key="NSTableColumns"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSTableColumn" id="612858300"> + <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"> + <int key="NSCellFlags">75628032</int> + <int key="NSCellFlags2">0</int> + <string key="NSContents"/> + <object class="NSFont" key="NSSupport"> + <string key="NSName">LucidaGrande</string> + <double key="NSSize">1.100000e+01</double> + <int key="NSfFlags">3100</int> + </object> + <object class="NSColor" key="NSBackgroundColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes> + </object> + <object class="NSColor" key="NSTextColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">headerTextColor</string> + <reference key="NSColor" ref="528526553"/> + </object> + </object> + <object class="NSTextFieldCell" key="NSDataCell" id="511905862"> + <int key="NSCellFlags">337772096</int> + <int key="NSCellFlags2">2048</int> + <string key="NSContents">Text Cell</string> + <reference key="NSSupport" ref="899171858"/> + <reference key="NSControlView" ref="904735886"/> + <object class="NSColor" key="NSBackgroundColor" id="806483849"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlBackgroundColor</string> + <reference key="NSColor" ref="22454945"/> + </object> + <reference key="NSTextColor" ref="902444822"/> + </object> + <int key="NSResizingMask">3</int> + <bool key="NSIsResizeable">YES</bool> + <bool key="NSIsEditable">YES</bool> + <reference key="NSTableView" ref="904735886"/> + </object> + </object> + <double key="NSIntercellSpacingWidth">3.000000e+00</double> + <double key="NSIntercellSpacingHeight">2.000000e+00</double> + <reference key="NSBackgroundColor" ref="261602967"/> + <object class="NSColor" key="NSGridColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">gridColor</string> + <object class="NSColor" key="NSColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC41AA</bytes> + </object> + </object> + <double key="NSRowHeight">1.700000e+01</double> + <int key="NSTvFlags">306184192</int> + <int key="NSColumnAutoresizingStyle">5</int> + <int key="NSDraggingSourceMaskForLocal">15</int> + <int key="NSDraggingSourceMaskForNonLocal">0</int> + <bool key="NSAllowsTypeSelect">YES</bool> + </object> + </object> + <string key="NSFrame">{{1, 17}, {423, 114}}</string> + <reference key="NSSuperview" ref="607350872"/> + <reference key="NSNextKeyView" ref="904735886"/> + <reference key="NSDocView" ref="904735886"/> + <reference key="NSBGColor" ref="806483849"/> + <int key="NScvFlags">4</int> + </object> + <object class="NSScroller" id="316831958"> + <reference key="NSNextResponder" ref="607350872"/> + <int key="NSvFlags">256</int> + <string key="NSFrame">{{424, 17}, {15, 114}}</string> + <reference key="NSSuperview" ref="607350872"/> + <reference key="NSTarget" ref="607350872"/> + <string key="NSAction">_doScroller:</string> + <double key="NSCurValue">3.700000e+01</double> + <double key="NSPercent">1.390978e-01</double> + </object> + <object class="NSScroller" id="792927203"> + <reference key="NSNextResponder" ref="607350872"/> + <int key="NSvFlags">256</int> + <string key="NSFrame">{{1, 131}, {423, 15}}</string> + <reference key="NSSuperview" ref="607350872"/> + <int key="NSsFlags">1</int> + <reference key="NSTarget" ref="607350872"/> + <string key="NSAction">_doScroller:</string> + <double key="NSCurValue">1.000000e+00</double> + <double key="NSPercent">9.837210e-01</double> + </object> + <object class="NSClipView" id="88791154"> + <reference key="NSNextResponder" ref="607350872"/> + <int key="NSvFlags">2304</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="329152418"/> + </object> + <string key="NSFrame">{{1, 0}, {423, 17}}</string> + <reference key="NSSuperview" ref="607350872"/> + <reference key="NSNextKeyView" ref="329152418"/> + <reference key="NSDocView" ref="329152418"/> + <reference key="NSBGColor" ref="806483849"/> + <int key="NScvFlags">4</int> + </object> + <reference ref="822439151"/> + </object> + <string key="NSFrame">{{20, 52}, {440, 147}}</string> + <reference key="NSSuperview" ref="1006"/> + <reference key="NSNextKeyView" ref="144860280"/> + <int key="NSsFlags">50</int> + <reference key="NSVScroller" ref="316831958"/> + <reference key="NSHScroller" ref="792927203"/> + <reference key="NSContentView" ref="144860280"/> + <reference key="NSHeaderClipView" ref="88791154"/> + <reference key="NSCornerView" ref="822439151"/> + <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes> + </object> </object> <string key="NSFrameSize">{480, 253}</string> <reference key="NSSuperview"/> @@ -234,6 +369,20 @@ <object class="NSCustomObject" id="12470901"> <string key="NSClassName">GTMUILocalizerAndLayoutTweaker</string> </object> + <object class="NSTreeController" id="1024614982"> + <object class="NSMutableArray" key="NSDeclaredKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>folderName</string> + <string>newFolder</string> + <string>selectionIndexPaths</string> + </object> + <bool key="NSEditable">YES</bool> + <object class="_NSManagedProxy" key="_NSManagedProxy"/> + <bool key="NSAvoidsEmptySelection">YES</bool> + <bool key="NSPreservesSelection">YES</bool> + <bool key="NSSelectsInsertedObjects">YES</bool> + <string key="NSTreeContentChildrenKey">children</string> + </object> </object> <object class="IBObjectContainer" key="IBDocument.Objects"> <object class="NSMutableArray" key="connectionRecords"> @@ -319,30 +468,6 @@ <int key="connectionID">41</int> </object> <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">folderBrowser_</string> - <reference key="source" ref="1001"/> - <reference key="destination" ref="723395462"/> - </object> - <int key="connectionID">59</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">delegate</string> - <reference key="source" ref="723395462"/> - <reference key="destination" ref="1001"/> - </object> - <int key="connectionID">60</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">target</string> - <reference key="source" ref="723395462"/> - <reference key="destination" ref="1001"/> - </object> - <int key="connectionID">61</int> - </object> - <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> <string key="label">value: displayName</string> <reference key="source" ref="921757931"/> @@ -378,13 +503,118 @@ </object> <int key="connectionID">66</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">folderTreeController_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="1024614982"/> + </object> + <int key="connectionID">75</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">contentArray: folderTreeArray</string> + <reference key="source" ref="1024614982"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="1024614982"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">contentArray: folderTreeArray</string> + <string key="NSBinding">contentArray</string> + <string key="NSKeyPath">folderTreeArray</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">76</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">fontBold: arrangedObjects.newFolder</string> + <reference key="source" ref="612858300"/> + <reference key="destination" ref="1024614982"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="612858300"/> + <reference key="NSDestination" ref="1024614982"/> + <string key="NSLabel">fontBold: arrangedObjects.newFolder</string> + <string key="NSBinding">fontBold</string> + <string key="NSKeyPath">arrangedObjects.newFolder</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">80</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">editable: arrangedObjects.newFolder</string> + <reference key="source" ref="612858300"/> + <reference key="destination" ref="1024614982"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="612858300"/> + <reference key="NSDestination" ref="1024614982"/> + <string key="NSLabel">editable: arrangedObjects.newFolder</string> + <string key="NSBinding">editable</string> + <string key="NSKeyPath">arrangedObjects.newFolder</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">81</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: arrangedObjects.folderName</string> + <reference key="source" ref="612858300"/> + <reference key="destination" ref="1024614982"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="612858300"/> + <reference key="NSDestination" ref="1024614982"/> + <string key="NSLabel">value: arrangedObjects.folderName</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">arrangedObjects.folderName</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">82</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">content: arrangedObjects</string> + <reference key="source" ref="904735886"/> + <reference key="destination" ref="1024614982"/> + <object class="NSNibBindingConnector" key="connector" id="817442453"> + <reference key="NSSource" ref="904735886"/> + <reference key="NSDestination" ref="1024614982"/> + <string key="NSLabel">content: arrangedObjects</string> + <string key="NSBinding">content</string> + <string key="NSKeyPath">arrangedObjects</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">84</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">selectionIndexPaths: tableSelectionPaths</string> + <reference key="source" ref="904735886"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="904735886"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">selectionIndexPaths: tableSelectionPaths</string> + <string key="NSBinding">selectionIndexPaths</string> + <string key="NSKeyPath">tableSelectionPaths</string> + <reference key="NSPreviousConnector" ref="817442453"/> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">85</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="1002"> + <object class="NSArray" key="object" id="544969523"> <bool key="EncodedWithXMLCoder">YES</bool> </object> <reference key="children" ref="1000"/> @@ -393,19 +623,19 @@ <object class="IBObjectRecord"> <int key="objectID">-2</int> <reference key="object" ref="1001"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="544969523"/> <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> </object> <object class="IBObjectRecord"> <int key="objectID">-1</int> <reference key="object" ref="1003"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="544969523"/> <string key="objectName">First Responder</string> </object> <object class="IBObjectRecord"> <int key="objectID">-3</int> <reference key="object" ref="1004"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="544969523"/> <string key="objectName">Application</string> </object> <object class="IBObjectRecord"> @@ -415,31 +645,25 @@ <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="1006"/> </object> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="544969523"/> </object> <object class="IBObjectRecord"> <int key="objectID">2</int> <reference key="object" ref="1006"/> <object class="NSMutableArray" key="children"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="723395462"/> <reference ref="138844528"/> <reference ref="563188797"/> <reference ref="649769717"/> + <reference ref="607350872"/> <reference ref="921757931"/> </object> <reference key="parent" ref="1005"/> </object> <object class="IBObjectRecord"> - <int key="objectID">26</int> - <reference key="object" ref="723395462"/> - <reference key="parent" ref="1006"/> - <string key="objectName">Folder Tree Browser</string> - </object> - <object class="IBObjectRecord"> <int key="objectID">34</int> <reference key="object" ref="764065517"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="544969523"/> </object> <object class="IBObjectRecord"> <int key="objectID">36</int> @@ -482,7 +706,7 @@ <object class="IBObjectRecord"> <int key="objectID">37</int> <reference key="object" ref="12470901"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="544969523"/> </object> <object class="IBObjectRecord"> <int key="objectID">40</int> @@ -531,6 +755,62 @@ <reference key="parent" ref="631907363"/> </object> <object class="IBObjectRecord"> + <int key="objectID">67</int> + <reference key="object" ref="607350872"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="329152418"/> + <reference ref="904735886"/> + <reference ref="792927203"/> + <reference ref="316831958"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">68</int> + <reference key="object" ref="329152418"/> + <reference key="parent" ref="607350872"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">69</int> + <reference key="object" ref="904735886"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="612858300"/> + </object> + <reference key="parent" ref="607350872"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">70</int> + <reference key="object" ref="792927203"/> + <reference key="parent" ref="607350872"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">71</int> + <reference key="object" ref="316831958"/> + <reference key="parent" ref="607350872"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">72</int> + <reference key="object" ref="612858300"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="511905862"/> + </object> + <reference key="parent" ref="904735886"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">73</int> + <reference key="object" ref="511905862"/> + <reference key="parent" ref="612858300"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">74</int> + <reference key="object" ref="1024614982"/> + <reference key="parent" ref="544969523"/> + <string key="objectName">Folder Tree Controller</string> + </object> + <object class="IBObjectRecord"> <int key="objectID">13</int> <reference key="object" ref="921757931"/> <object class="NSMutableArray" key="children"> @@ -569,14 +849,21 @@ <string>14.IBPluginDependency</string> <string>2.IBPluginDependency</string> <string>2.IBUserGuides</string> - <string>26.IBPluginDependency</string> <string>3.IBPluginDependency</string> <string>34.IBPluginDependency</string> <string>37.IBPluginDependency</string> <string>4.IBPluginDependency</string> <string>5.IBPluginDependency</string> <string>6.IBPluginDependency</string> + <string>67.IBPluginDependency</string> + <string>68.IBPluginDependency</string> + <string>69.IBPluginDependency</string> <string>7.IBPluginDependency</string> + <string>70.IBPluginDependency</string> + <string>71.IBPluginDependency</string> + <string>72.IBPluginDependency</string> + <string>73.IBPluginDependency</string> + <string>74.IBPluginDependency</string> <string>8.IBPluginDependency</string> <string>9.IBPluginDependency</string> </object> @@ -585,10 +872,10 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{141, 575}, {480, 253}}</string> + <string>{{445, 603}, {480, 253}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="0" id="6"/> - <string>{{141, 575}, {480, 253}}</string> + <string>{{445, 603}, {480, 253}}</string> <reference ref="6"/> <string>{196, 240}</string> <string>{{357, 418}, {480, 270}}</string> @@ -613,6 +900,13 @@ <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> + <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"> @@ -635,7 +929,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">66</int> + <int key="maxID">85</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -670,13 +964,15 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>folderBrowser_</string> + <string>folderTreeController_</string> + <string>folderTreeView_</string> <string>newFolderButton_</string> <string>okButton_</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>NSBrowser</string> + <string>NSTreeController</string> + <string>NSOutlineView</string> <string>NSButton</string> <string>NSButton</string> </object> @@ -761,18 +1057,6 @@ <reference key="sourceIdentifier" ref="262327023"/> </object> <object class="IBPartialClassDescription"> - <string key="className">NSBrowser</string> - <string key="superclassName">NSControl</string> - <object class="NSMutableDictionary" key="outlets"> - <string key="NS.key.0">target</string> - <string key="NS.object.0">id</string> - </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBUserSource</string> - <string key="minorKey"/> - </object> - </object> - <object class="IBPartialClassDescription"> <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> diff --git a/chrome/app/nibs/BookmarkEditor.xib b/chrome/app/nibs/BookmarkEditor.xib index 312cafd..71e4ab9 100644 --- a/chrome/app/nibs/BookmarkEditor.xib +++ b/chrome/app/nibs/BookmarkEditor.xib @@ -1,19 +1,28 @@ <?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.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">9L30</string> - <string key="IBDocument.InterfaceBuilderVersion">670</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="36"/> + <integer value="70"/> </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"> + <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"> @@ -40,30 +49,6 @@ <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSBrowser" id="723395462"> - <reference key="NSNextResponder" ref="1006"/> - <int key="NSvFlags">274</int> - <string key="NSFrame">{{20, 60}, {440, 143}}</string> - <reference key="NSSuperview" ref="1006"/> - <bool key="NSEnabled">YES</bool> - <object class="NSBrowserCell" key="NSCellPrototype"> - <int key="NSCellFlags">67239488</int> - <int key="NSCellFlags2">2048</int> - <string key="NSContents"> </string> - <object class="NSFont" key="NSSupport"> - <string key="NSName">LucidaGrande</string> - <double key="NSSize">1.200000e+01</double> - <int key="NSfFlags">16</int> - </object> - </object> - <string key="NSPathSeparator">/</string> - <int key="NSMinColumnWidth">100</int> - <int key="NSNumberOfVisibleColumns">3</int> - <int key="NSColumnResizingType">1</int> - <double key="NSPreferedColumnWidth">1.000000e+02</double> - <bool key="NSAllowsTypeSelect">YES</bool> - <int key="NSBrFlags">1544765440</int> - </object> <object class="NSCustomView" id="138844528"> <reference key="NSNextResponder" ref="1006"/> <int key="NSvFlags">289</int> @@ -139,7 +124,7 @@ <int key="NSColorSpace">6</int> <string key="NSCatalogName">System</string> <string key="NSColorName">controlColor</string> - <object class="NSColor" key="NSColor"> + <object class="NSColor" key="NSColor" id="643861378"> <int key="NSColorSpace">3</int> <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes> </object> @@ -203,7 +188,7 @@ <int key="NSColorSpace">6</int> <string key="NSCatalogName">System</string> <string key="NSColorName">textBackgroundColor</string> - <object class="NSColor" key="NSColor"> + <object class="NSColor" key="NSColor" id="354852741"> <int key="NSColorSpace">3</int> <bytes key="NSWhite">MQA</bytes> </object> @@ -245,7 +230,7 @@ <int key="NSCellFlags">67239424</int> <int key="NSCellFlags2">0</int> <string key="NSContents"/> - <object class="NSFont" key="NSSupport"> + <object class="NSFont" key="NSSupport" id="26"> <string key="NSName">LucidaGrande</string> <double key="NSSize">1.100000e+01</double> <int key="NSfFlags">3100</int> @@ -293,6 +278,125 @@ <reference key="NSSuperview" ref="1006"/> <string key="NSClassName">GTMWidthBasedTweaker</string> </object> + <object class="NSScrollView" id="193645101"> + <reference key="NSNextResponder" ref="1006"/> + <int key="NSvFlags">274</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSClipView" id="964674476"> + <reference key="NSNextResponder" ref="193645101"/> + <int key="NSvFlags">2304</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSOutlineView" id="448393933"> + <reference key="NSNextResponder" ref="964674476"/> + <int key="NSvFlags">274</int> + <string key="NSFrameSize">{423, 122}</string> + <reference key="NSSuperview" ref="964674476"/> + <bool key="NSEnabled">YES</bool> + <object class="_NSCornerView" key="NSCornerView"> + <nil key="NSNextResponder"/> + <int key="NSvFlags">256</int> + <string key="NSFrame">{{424, 0}, {16, 17}}</string> + </object> + <object class="NSMutableArray" key="NSTableColumns"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSTableColumn" id="500451419"> + <double key="NSWidth">4.040000e+02</double> + <double key="NSMinWidth">1.600000e+01</double> + <double key="NSMaxWidth">1.000000e+03</double> + <object class="NSTableHeaderCell" key="NSHeaderCell"> + <int key="NSCellFlags">75628032</int> + <int key="NSCellFlags2">0</int> + <string key="NSContents"/> + <reference key="NSSupport" ref="26"/> + <object class="NSColor" key="NSBackgroundColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes> + </object> + <object class="NSColor" key="NSTextColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">headerTextColor</string> + <reference key="NSColor" ref="528526553"/> + </object> + </object> + <object class="NSTextFieldCell" key="NSDataCell" id="584091932"> + <int key="NSCellFlags">337772096</int> + <int key="NSCellFlags2">2048</int> + <string key="NSContents">Text Cell</string> + <reference key="NSSupport" ref="899171858"/> + <reference key="NSControlView" ref="448393933"/> + <object class="NSColor" key="NSBackgroundColor" id="297386013"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlBackgroundColor</string> + <reference key="NSColor" ref="643861378"/> + </object> + <reference key="NSTextColor" ref="728676191"/> + </object> + <int key="NSResizingMask">3</int> + <bool key="NSIsResizeable">YES</bool> + <bool key="NSIsEditable">YES</bool> + <reference key="NSTableView" ref="448393933"/> + </object> + </object> + <double key="NSIntercellSpacingWidth">3.000000e+00</double> + <double key="NSIntercellSpacingHeight">2.000000e+00</double> + <reference key="NSBackgroundColor" ref="354852741"/> + <object class="NSColor" key="NSGridColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">gridColor</string> + <object class="NSColor" key="NSColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC41AA</bytes> + </object> + </object> + <double key="NSRowHeight">1.700000e+01</double> + <int key="NSTvFlags">37748736</int> + <int key="NSColumnAutoresizingStyle">4</int> + <int key="NSDraggingSourceMaskForLocal">15</int> + <int key="NSDraggingSourceMaskForNonLocal">0</int> + <bool key="NSAllowsTypeSelect">YES</bool> + </object> + </object> + <string key="NSFrame">{{1, 1}, {423, 122}}</string> + <reference key="NSSuperview" ref="193645101"/> + <reference key="NSNextKeyView" ref="448393933"/> + <reference key="NSDocView" ref="448393933"/> + <reference key="NSBGColor" ref="297386013"/> + <int key="NScvFlags">4</int> + </object> + <object class="NSScroller" id="951336489"> + <reference key="NSNextResponder" ref="193645101"/> + <int key="NSvFlags">256</int> + <string key="NSFrame">{{424, 1}, {15, 122}}</string> + <reference key="NSSuperview" ref="193645101"/> + <reference key="NSTarget" ref="193645101"/> + <string key="NSAction">_doScroller:</string> + <double key="NSPercent">9.918699e-01</double> + </object> + <object class="NSScroller" id="813654667"> + <reference key="NSNextResponder" ref="193645101"/> + <int key="NSvFlags">256</int> + <string key="NSFrame">{{1, 123}, {423, 15}}</string> + <reference key="NSSuperview" ref="193645101"/> + <int key="NSsFlags">1</int> + <reference key="NSTarget" ref="193645101"/> + <string key="NSAction">_doScroller:</string> + <double key="NSPercent">9.976415e-01</double> + </object> + </object> + <string key="NSFrame">{{20, 51}, {440, 139}}</string> + <reference key="NSSuperview" ref="1006"/> + <reference key="NSNextKeyView" ref="964674476"/> + <int key="NSsFlags">50</int> + <reference key="NSVScroller" ref="951336489"/> + <reference key="NSHScroller" ref="813654667"/> + <reference key="NSContentView" ref="964674476"/> + <bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes> + </object> </object> <string key="NSFrameSize">{480, 270}</string> <reference key="NSSuperview"/> @@ -307,6 +411,16 @@ <object class="NSCustomObject" id="12470901"> <string key="NSClassName">GTMUILocalizerAndLayoutTweaker</string> </object> + <object class="NSTreeController" id="784029904"> + <object class="NSMutableArray" key="NSDeclaredKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>folderName</string> + <string>newFolder</string> + </object> + <object class="_NSManagedProxy" key="_NSManagedProxy"/> + <bool key="NSAvoidsEmptySelection">YES</bool> + <string key="NSTreeContentChildrenKey">children</string> + </object> </object> <object class="IBObjectContainer" key="IBDocument.Objects"> <object class="NSMutableArray" key="connectionRecords"> @@ -337,14 +451,6 @@ </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">25</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> <string key="label">window</string> <reference key="source" ref="1001"/> <reference key="destination" ref="1005"/> @@ -408,30 +514,6 @@ <int key="connectionID">43</int> </object> <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">folderBrowser_</string> - <reference key="source" ref="1001"/> - <reference key="destination" ref="723395462"/> - </object> - <int key="connectionID">59</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">delegate</string> - <reference key="source" ref="723395462"/> - <reference key="destination" ref="1001"/> - </object> - <int key="connectionID">60</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBOutletConnection" key="connection"> - <string key="label">target</string> - <reference key="source" ref="723395462"/> - <reference key="destination" ref="1001"/> - </object> - <int key="connectionID">61</int> - </object> - <object class="IBConnectionRecord"> <object class="IBBindingConnection" key="connection"> <string key="label">value: displayURL</string> <reference key="source" ref="812603726"/> @@ -487,13 +569,126 @@ </object> <int key="connectionID">66</int> </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">contentArray: folderTreeArray</string> + <reference key="source" ref="784029904"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="784029904"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">contentArray: folderTreeArray</string> + <string key="NSBinding">contentArray</string> + <string key="NSKeyPath">folderTreeArray</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">78</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">value: arrangedObjects.folderName</string> + <reference key="source" ref="500451419"/> + <reference key="destination" ref="784029904"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="500451419"/> + <reference key="NSDestination" ref="784029904"/> + <string key="NSLabel">value: arrangedObjects.folderName</string> + <string key="NSBinding">value</string> + <string key="NSKeyPath">arrangedObjects.folderName</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">80</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">folderTreeController_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="784029904"/> + </object> + <int key="connectionID">90</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">folderTreeView_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="448393933"/> + </object> + <int key="connectionID">91</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">fontBold: arrangedObjects.newFolder</string> + <reference key="source" ref="500451419"/> + <reference key="destination" ref="784029904"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="500451419"/> + <reference key="NSDestination" ref="784029904"/> + <string key="NSLabel">fontBold: arrangedObjects.newFolder</string> + <string key="NSBinding">fontBold</string> + <string key="NSKeyPath">arrangedObjects.newFolder</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">98</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">editable: arrangedObjects.newFolder</string> + <reference key="source" ref="500451419"/> + <reference key="destination" ref="784029904"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="500451419"/> + <reference key="NSDestination" ref="784029904"/> + <string key="NSLabel">editable: arrangedObjects.newFolder</string> + <string key="NSBinding">editable</string> + <string key="NSKeyPath">arrangedObjects.newFolder</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">101</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">content: arrangedObjects</string> + <reference key="source" ref="448393933"/> + <reference key="destination" ref="784029904"/> + <object class="NSNibBindingConnector" key="connector" id="560837184"> + <reference key="NSSource" ref="448393933"/> + <reference key="NSDestination" ref="784029904"/> + <string key="NSLabel">content: arrangedObjects</string> + <string key="NSBinding">content</string> + <string key="NSKeyPath">arrangedObjects</string> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">102</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBBindingConnection" key="connection"> + <string key="label">selectionIndexPaths: tableSelectionPaths</string> + <reference key="source" ref="448393933"/> + <reference key="destination" ref="1001"/> + <object class="NSNibBindingConnector" key="connector"> + <reference key="NSSource" ref="448393933"/> + <reference key="NSDestination" ref="1001"/> + <string key="NSLabel">selectionIndexPaths: tableSelectionPaths</string> + <string key="NSBinding">selectionIndexPaths</string> + <string key="NSKeyPath">tableSelectionPaths</string> + <reference key="NSPreviousConnector" ref="560837184"/> + <int key="NSNibBindingConnectorVersion">2</int> + </object> + </object> + <int key="connectionID">111</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="1002"> + <object class="NSArray" key="object" id="952403548"> <bool key="EncodedWithXMLCoder">YES</bool> </object> <reference key="children" ref="1000"/> @@ -502,19 +697,19 @@ <object class="IBObjectRecord"> <int key="objectID">-2</int> <reference key="object" ref="1001"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="952403548"/> <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> </object> <object class="IBObjectRecord"> <int key="objectID">-1</int> <reference key="object" ref="1003"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="952403548"/> <string key="objectName">First Responder</string> </object> <object class="IBObjectRecord"> <int key="objectID">-3</int> <reference key="object" ref="1004"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="952403548"/> <string key="objectName">Application</string> </object> <object class="IBObjectRecord"> @@ -524,31 +719,25 @@ <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="1006"/> </object> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="952403548"/> </object> <object class="IBObjectRecord"> <int key="objectID">2</int> <reference key="object" ref="1006"/> <object class="NSMutableArray" key="children"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="723395462"/> - <reference ref="138844528"/> <reference ref="563188797"/> <reference ref="898764481"/> + <reference ref="193645101"/> + <reference ref="138844528"/> <reference ref="649769717"/> </object> <reference key="parent" ref="1005"/> </object> <object class="IBObjectRecord"> - <int key="objectID">26</int> - <reference key="object" ref="723395462"/> - <reference key="parent" ref="1006"/> - <string key="objectName">Folder Tree Browser</string> - </object> - <object class="IBObjectRecord"> <int key="objectID">34</int> <reference key="object" ref="764065517"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="952403548"/> </object> <object class="IBObjectRecord"> <int key="objectID">36</int> @@ -591,7 +780,7 @@ <object class="IBObjectRecord"> <int key="objectID">37</int> <reference key="object" ref="12470901"/> - <reference key="parent" ref="1002"/> + <reference key="parent" ref="952403548"/> </object> <object class="IBObjectRecord"> <int key="objectID">40</int> @@ -692,6 +881,56 @@ <reference key="object" ref="732374144"/> <reference key="parent" ref="631907363"/> </object> + <object class="IBObjectRecord"> + <int key="objectID">67</int> + <reference key="object" ref="193645101"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="951336489"/> + <reference ref="813654667"/> + <reference ref="448393933"/> + </object> + <reference key="parent" ref="1006"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">68</int> + <reference key="object" ref="951336489"/> + <reference key="parent" ref="193645101"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">69</int> + <reference key="object" ref="813654667"/> + <reference key="parent" ref="193645101"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">70</int> + <reference key="object" ref="448393933"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="500451419"/> + </object> + <reference key="parent" ref="193645101"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">72</int> + <reference key="object" ref="500451419"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="584091932"/> + </object> + <reference key="parent" ref="448393933"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">75</int> + <reference key="object" ref="584091932"/> + <reference key="parent" ref="500451419"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">76</int> + <reference key="object" ref="784029904"/> + <reference key="parent" ref="952403548"/> + <string key="objectName">Folder Tree Controller</string> + </object> </object> </object> <object class="NSMutableDictionary" key="flattenedProperties"> @@ -721,14 +960,20 @@ <string>16.IBPluginDependency</string> <string>2.IBPluginDependency</string> <string>2.IBUserGuides</string> - <string>26.IBPluginDependency</string> <string>3.IBPluginDependency</string> <string>34.IBPluginDependency</string> <string>37.IBPluginDependency</string> <string>4.IBPluginDependency</string> <string>5.IBPluginDependency</string> <string>6.IBPluginDependency</string> + <string>67.IBPluginDependency</string> + <string>68.IBPluginDependency</string> + <string>69.IBPluginDependency</string> <string>7.IBPluginDependency</string> + <string>70.IBPluginDependency</string> + <string>72.IBPluginDependency</string> + <string>75.IBPluginDependency</string> + <string>76.IBPluginDependency</string> <string>8.IBPluginDependency</string> <string>9.IBPluginDependency</string> </object> @@ -737,15 +982,15 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{141, 558}, {480, 270}}</string> + <string>{{510, 586}, {480, 270}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <integer value="0" id="6"/> - <string>{{141, 558}, {480, 270}}</string> + <string>{{510, 586}, {480, 270}}</string> <reference ref="6"/> <string>{196, 240}</string> <string>{{357, 418}, {480, 270}}</string> <reference ref="6"/> - <integer value="1"/> + <reference ref="5"/> <string>{331, 270}</string> <string>{331, 270}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -769,6 +1014,12 @@ <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> + <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"> @@ -791,13 +1042,13 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">66</int> + <int key="maxID">111</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBPartialClassDescription"> - <string key="className">BookmarkEditorController</string> + <string key="className">BookmarkEditorBaseController</string> <string key="superclassName">NSWindowController</string> <object class="NSMutableDictionary" key="actions"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -818,23 +1069,29 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>folderBrowser_</string> - <string>nameField_</string> + <string>folderTreeController_</string> + <string>folderTreeView_</string> <string>newFolderButton_</string> <string>okButton_</string> - <string>urlField_</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>NSBrowser</string> - <string>NSTextField</string> + <string>NSTreeController</string> + <string>NSOutlineView</string> <string>NSButton</string> <string>NSButton</string> - <string>NSTextField</string> </object> </object> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/bookmark_editor_base_controller.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">BookmarkEditorController</string> + <string key="superclassName">BookmarkEditorBaseController</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> <string key="minorKey">browser/cocoa/bookmark_editor_controller.h</string> </object> </object> @@ -913,18 +1170,6 @@ <reference key="sourceIdentifier" ref="262327023"/> </object> <object class="IBPartialClassDescription"> - <string key="className">NSBrowser</string> - <string key="superclassName">NSControl</string> - <object class="NSMutableDictionary" key="outlets"> - <string key="NS.key.0">target</string> - <string key="NS.object.0">id</string> - </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBUserSource</string> - <string key="minorKey"/> - </object> - </object> - <object class="IBPartialClassDescription"> <string key="className">NSObject</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> diff --git a/chrome/browser/cocoa/bookmark_all_tabs_controller.h b/chrome/browser/cocoa/bookmark_all_tabs_controller.h index e861c50..8d2d2b9 100644 --- a/chrome/browser/cocoa/bookmark_all_tabs_controller.h +++ b/chrome/browser/cocoa/bookmark_all_tabs_controller.h @@ -15,8 +15,9 @@ typedef std::pair<std::wstring, GURL> ActiveTabNameURLPair; typedef std::vector<ActiveTabNameURLPair> ActiveTabsNameURLPairVector; -// A controller for the bookmark editor, opened with Edit... from the -// context menu of a bookmark button. +// A controller for the Bookmark All Tabs sheet which is presented upon +// selecting the Bookmark All Tabs... menu item shown by the contextual +// menu in the bookmarks bar. @interface BookmarkAllTabsController : BookmarkEditorBaseController { @private ActiveTabsNameURLPairVector activeTabPairsVector_; diff --git a/chrome/browser/cocoa/bookmark_all_tabs_controller.mm b/chrome/browser/cocoa/bookmark_all_tabs_controller.mm index 93b4026..8c2e236 100644 --- a/chrome/browser/cocoa/bookmark_all_tabs_controller.mm +++ b/chrome/browser/cocoa/bookmark_all_tabs_controller.mm @@ -30,9 +30,8 @@ } - (void)awakeFromNib { - [self - setInitialName: - l10n_util::GetNSStringWithFixup(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME)]; + [self setInitialName: + l10n_util::GetNSStringWithFixup(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME)]; [super awakeFromNib]; } @@ -52,10 +51,10 @@ } } -// The the name for the folder into which the tabs will be recorded as -// bookmarks is assumed to be non-empty. The folder is then created -// and a bookmark for each open tab added therein. -- (IBAction)ok:(id)sender { +// Called by -[BookmarkEditorBaseController ok:]. Creates the container +// folder for the tabs and then the bookmarks in that new folder. +// Returns a BOOL as an NSNumber indicating that the commit may proceed. +- (NSNumber*)didCommit { NSString* name = [[self displayName] stringByTrimmingCharactersInSet: [NSCharacterSet newlineCharacterSet]]; std::wstring newTitle = base::SysNSStringToWide(name); @@ -67,7 +66,7 @@ BookmarkModel* model = [self bookmarkModel]; const BookmarkNode* newFolder = model->AddGroup(newParentNode, newIndex, newFolderString); - [self NotifyHandlerCreatedNode:newFolder]; + [self notifyHandlerCreatedNode:newFolder]; // Get a list of all open tabs, create nodes for them, and add // to the new folder node. [self UpdateActiveTabPairs]; @@ -77,9 +76,9 @@ it != activeTabPairsVector_.end(); ++it, ++i) { const BookmarkNode* node = model->AddURL(newFolder, i, it->first, it->second); - [self NotifyHandlerCreatedNode:node]; + [self notifyHandlerCreatedNode:node]; } - [super ok:sender]; + return [NSNumber numberWithBool:YES]; } - (ActiveTabsNameURLPairVector*)activeTabPairsVector { diff --git a/chrome/browser/cocoa/bookmark_all_tabs_controller_unittest.mm b/chrome/browser/cocoa/bookmark_all_tabs_controller_unittest.mm index 1d0a724..118a554 100644 --- a/chrome/browser/cocoa/bookmark_all_tabs_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_all_tabs_controller_unittest.mm @@ -59,11 +59,11 @@ class BookmarkAllTabsControllerTest : public CocoaTest { virtual void SetUp() { CocoaTest::SetUp(); controller_ = CreateController(); - EXPECT_TRUE([controller_ window]); + [controller_ runAsModalSheet]; } virtual void TearDown() { - [controller_ close]; + controller_ = NULL; CocoaTest::TearDown(); } }; @@ -71,6 +71,7 @@ class BookmarkAllTabsControllerTest : public CocoaTest { TEST_F(BookmarkAllTabsControllerTest, BookmarkAllTabs) { // OK button should always be enabled. EXPECT_TRUE([controller_ okButtonEnabled]); + [controller_ selectTestNodeInBrowser:group_a_]; [controller_ setDisplayName:@"ALL MY TABS"]; [controller_ ok:nil]; EXPECT_EQ(4, group_a_->GetChildCount()); diff --git a/chrome/browser/cocoa/bookmark_editor_base_controller.h b/chrome/browser/cocoa/bookmark_editor_base_controller.h index cb0725d..265289f 100644 --- a/chrome/browser/cocoa/bookmark_editor_base_controller.h +++ b/chrome/browser/cocoa/bookmark_editor_base_controller.h @@ -12,23 +12,23 @@ #include "base/scoped_nsobject.h" #include "chrome/browser/bookmarks/bookmark_editor.h" -@class BookmarkTreeBrowserCell; class BookmarkModel; +@class BookmarkTreeBrowserCell; // A base controller class for bookmark creation and editing dialogs which // present the current bookmark folder structure in a tree view. Do not // instantiate this controller directly -- use one of its derived classes. -// NOTE: If your derived classes is intended to be dispatched via the +// NOTE: If a derived class is intended to be dispatched via the // BookmarkEditor::Show static function found in the accompanying -// implementation will need to update that function. -@interface BookmarkEditorBaseController : - NSWindowController<NSMatrixDelegate, NSTextFieldDelegate> { +// implementation, that function will need to be update. +@interface BookmarkEditorBaseController : NSWindowController { @private - IBOutlet NSBrowser* folderBrowser_; IBOutlet NSButton* newFolderButton_; IBOutlet NSButton* okButton_; // Used for unit testing only. + IBOutlet NSTreeController* folderTreeController_; + IBOutlet NSOutlineView* folderTreeView_; - NSWindow* parentWindow_; + NSWindow* parentWindow_; // weak Profile* profile_; // weak const BookmarkNode* parentNode_; // weak; owned by the model BookmarkEditor::Configuration configuration_; @@ -36,11 +36,19 @@ class BookmarkModel; NSString* initialName_; NSString* displayName_; // Bound to a text field in the dialog. BOOL okEnabled_; // Bound to the OK button. + // An array of BookmarkFolderInfo where each item describes a folder in the + // BookmarkNode structure. + scoped_nsobject<NSArray> folderTreeArray_; + // Bound to the table view giving a path to the current selections, of which + // there should only ever be one. + scoped_nsobject<NSArray> tableSelectionPaths_; } @property (copy) NSString* initialName; @property (copy) NSString* displayName; @property (assign) BOOL okEnabled; +@property (retain, readonly) NSArray* folderTreeArray; +@property (copy) NSArray* tableSelectionPaths; // Designated initializer. Derived classes should call through to this init. - (id)initWithParentWindow:(NSWindow*)parentWindow @@ -57,11 +65,22 @@ class BookmarkModel; // an untitled name, and put it into editing mode. - (IBAction)newFolder:(id)sender; -// Actions for the buttons at the bottom of the window. +// The cancel action will dismiss the dialog. Derived classes which +// override cancel:, must call this after accessing any dialog-related +// data. - (IBAction)cancel:(id)sender; -// The OK action will record the edited bookmark. The default dismisses -// the dialog and should be called by the derived class if overridden. +// The OK action will dismiss the dialog. This action is bound +// to the OK button of a dialog which presents a tree view of a profile's +// folder hierarchy and allows the creation of new folders within that tree. +// When the OK button is pressed, this function will: 1) call the derived +// class's -[willCommit] function, 2) create any new folders created by +// the user while the dialog is presented, 3) call the derived class's +// -[didCommit] function, and then 4) dismiss the dialog. At least one +// of -[willCommit] and -[didCommit] must be provided by the derived class +// and should return a NSNumber containing a BOOL or nil ('nil' means YES) +// indicating if the operation should be allowed to continue. +// Note: A derived class should not override the ok: action. - (IBAction)ok:(id)sender; // Methods for use by derived classes only. @@ -69,8 +88,7 @@ class BookmarkModel; // Determine and returns the rightmost selected/highlighted element (node) // in the bookmark tree view if the tree view is showing, otherwise returns // the original |parentNode_|. If the tree view is showing but nothing is -// selected then return the root node. This assumes that leaf nodes (pure -// bookmarks) are not being presented. +// selected then the root node is returned. - (const BookmarkNode*)selectedNode; // Select/highlight the given node within the browser tree view. If the @@ -78,7 +96,7 @@ class BookmarkModel; - (void)selectNodeInBrowser:(const BookmarkNode*)node; // Notify the handler, if any, of a node creation. -- (void)NotifyHandlerCreatedNode:(const BookmarkNode*)node; +- (void)notifyHandlerCreatedNode:(const BookmarkNode*)node; // Accessors - (BookmarkModel*)bookmarkModel; @@ -86,12 +104,64 @@ class BookmarkModel; @end +// Describes the profile's bookmark folder structure: the folder name, the +// original BookmarkNode pointer (if the folder already exists), a BOOL +// indicating if the folder is new (meaning: created during this session +// but not yet committed to the bookmark structure), and an NSArray of +// child folder BookmarkFolderInfo's following this same structure. +@interface BookmarkFolderInfo : NSObject { + @private + NSString* folderName_; + const BookmarkNode* folderNode_; // weak + NSMutableArray* children_; + BOOL newFolder_; +} + +@property (copy, readwrite) NSString* folderName; +@property (assign, readwrite) const BookmarkNode* folderNode; +@property (retain, readwrite) NSMutableArray* children; +@property (assign, readwrite) BOOL newFolder; + +// Convenience creator for adding a new folder to the editor's bookmark +// structure. This folder will be added to the bookmark model when the +// user accepts the dialog. |folderName| must be provided. ++ (id)bookmarkFolderInfoWithFolderName:(NSString*)folderName; + +// Designated initializer. |folderName| must be provided. For folders which +// already exist in the bookmark model, |folderNode| and |children| (if any +// children are already attached to this folder) must be provided and +// |newFolder| should be NO. For folders which the user has added during +// this session and which have not been committed yet, |newFolder| should be +// YES and |folderNode| and |children| should be NULL/nil. +- (id)initWithFolderName:(NSString*)folderName + folderNode:(const BookmarkNode*)folderNode + children:(NSMutableArray*)children + newFolder:(BOOL)newFolder; + +// Convenience creator used during construction of the editor's bookmark +// structure. |folderName| and |folderNode| must be provided. |children| +// is optional. Private: exposed here for unit testing purposes. ++ (id)bookmarkFolderInfoWithFolderName:(NSString*)folderName + folderNode:(const BookmarkNode*)folderNode + children:(NSMutableArray*)children; + +@end + @interface BookmarkEditorBaseController(TestingAPI) + @property (readonly) BOOL okButtonEnabled; + +// Create any newly added folders. New folders are nodes in folderTreeArray +// which are marked as being new (i.e. their kFolderTreeNewFolderKey +// dictionary item is YES). This is called by -[ok:]. +- (void)createNewFolders; + +// Select the given bookmark node within the tree view. - (void)selectTestNodeInBrowser:(const BookmarkNode*)node; -+ (const BookmarkNode*)folderChildForParent:(const BookmarkNode*)parent - withFolderIndex:(NSInteger)index; -+ (int)indexOfFolderChild:(const BookmarkNode*)child; + +// Return the dictionary for the folder selected in the tree. +- (BookmarkFolderInfo*)selectedFolder; + @end #endif /* CHROME_BROWSER_COCOA_BOOKMARK_EDITOR_BASE_CONTROLLER_H_ */ diff --git a/chrome/browser/cocoa/bookmark_editor_base_controller.mm b/chrome/browser/cocoa/bookmark_editor_base_controller.mm index d97874a..59b8913 100644 --- a/chrome/browser/cocoa/bookmark_editor_base_controller.mm +++ b/chrome/browser/cocoa/bookmark_editor_base_controller.mm @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <stack> + #import "chrome/browser/cocoa/bookmark_editor_base_controller.h" #include "app/l10n_util.h" +#include "app/l10n_util_mac.h" #include "base/logging.h" #include "base/mac_util.h" #include "base/sys_string_conversions.h" @@ -16,25 +19,27 @@ @interface BookmarkEditorBaseController (Private) -// Given a cell in the folder browser, make that cell editable so that the -// bookmark folder name can be modified by the user. -- (void)editFolderNameInCell:(BookmarkTreeBrowserCell*)cell; +@property (retain, readwrite) NSArray* folderTreeArray; + +// Return the folder tree object for the given path. +- (BookmarkFolderInfo*)folderForIndexPath:(NSIndexPath*)path; -// The action called by the bookmark folder name cell being edited by -// the user when editing has been completed (such as by pressing <return>). -- (void)cellEditingCompleted:(id)sender; +// Given a folder node, collect an array containing BookmarkFolderInfos +// describing its subchildren which are also folders. +- (NSMutableArray*)addChildFoldersFromNode:(const BookmarkNode*)node; -// Update the folder name from the current edit in the given cell -// and return the focus to the folder tree browser. -- (void)saveFolderNameForCell:(BookmarkTreeBrowserCell*)cell; +// Scan the folder tree stemming from the given tree folder and create +// any newly added folders. +- (void)createNewFoldersForFolder:(BookmarkFolderInfo*)treeFolder; -// A custom action handler called by the bookmark folder browser when the -// user has double-clicked on a folder name. -- (void)browserDoubleClicked:(id)sender; +// Scan the folder tree looking for the given bookmark node and return +// the selection path thereto. +- (NSIndexPath*)selectionPathForNode:(const BookmarkNode*)node; @end -// static; implemented for each platform. +// static; implemented for each platform. Update this function for new +// classes derived from BookmarkEditorBaseController. void BookmarkEditor::Show(gfx::NativeWindow parent_hwnd, Profile* profile, const BookmarkNode* parent, @@ -61,40 +66,6 @@ void BookmarkEditor::Show(gfx::NativeWindow parent_hwnd, [controller runAsModalSheet]; } -#pragma mark Bookmark TreeNode Helpers - -namespace { - -// Find the index'th folder child of a parent, ignoring bookmarks (leafs). -const BookmarkNode* GetFolderChildForParent(const BookmarkNode* parent_node, - NSInteger folder_index) { - const BookmarkNode* child_node = nil; - int i = 0; - int child_count = parent_node->GetChildCount(); - do { - child_node = parent_node->GetChild(i); - if (child_node->type() != BookmarkNode::URL) - --folder_index; - ++i; - } while (folder_index >= 0 && i < child_count); - return child_node; -} - -// Determine the index of a child within its parent ignoring -// bookmarks (leafs). -int IndexOfFolderChild(const BookmarkNode* child_node) { - const BookmarkNode* node_parent = child_node->GetParent(); - int child_index = node_parent->IndexOfChild(child_node); - for (int i = child_index - 1; i >= 0; --i) { - const BookmarkNode* sibling = node_parent->GetChild(i); - if (sibling->type() == BookmarkNode::URL) - --child_index; - } - return child_index; -} - -} // namespace - @implementation BookmarkEditorBaseController @synthesize initialName = initialName_; @@ -131,21 +102,24 @@ int IndexOfFolderChild(const BookmarkNode* child_node) { [self setDisplayName:[self initialName]]; if (configuration_ != BookmarkEditor::SHOW_TREE) { - // Remember the NSBrowser's height; we will shrink our frame by that - // much. + // Remember the tree view's height; we will shrink our frame by that much. NSRect frame = [[self window] frame]; - CGFloat browserHeight = [folderBrowser_ frame].size.height; + CGFloat browserHeight = [folderTreeView_ frame].size.height; frame.size.height -= browserHeight; frame.origin.y += browserHeight; - // Remove the NSBrowser and "new folder" button. - [folderBrowser_ removeFromSuperview]; + // Remove the folder tree and "new folder" button. + [folderTreeView_ removeFromSuperview]; [newFolderButton_ removeFromSuperview]; // Finally, commit the size change. [[self window] setFrame:frame display:YES]; } - [folderBrowser_ setCellClass:[BookmarkTreeBrowserCell class]]; - [folderBrowser_ setDoubleAction:@selector(browserDoubleClicked:)]; + // Build up a tree of the current folder configuration. + BookmarkModel* model = profile_->GetBookmarkModel(); + const BookmarkNode* rootNode = model->root_node(); + NSMutableArray* baseArray = [self addChildFoldersFromNode:rootNode]; + DCHECK(baseArray); + [self setFolderTreeArray:baseArray]; } - (void)windowDidLoad { @@ -154,13 +128,6 @@ int IndexOfFolderChild(const BookmarkNode* child_node) { } } -- (void)windowWillClose:(NSNotification *)notification { - // If a folder name cell is being edited then force it to end editing - // so that any changes are recorded. - [[self window] makeFirstResponder:nil]; - [self autorelease]; -} - /* TODO(jrg): // Implementing this informal protocol allows us to open the sheet // somewhere other than at the top of the window. NOTE: this means @@ -181,50 +148,93 @@ int IndexOfFolderChild(const BookmarkNode* child_node) { contextInfo:nil]; } -- (void)selectNodeInBrowser:(const BookmarkNode*)node { - DCHECK(configuration_ == BookmarkEditor::SHOW_TREE); - std::deque<NSInteger> rowsToSelect; - const BookmarkNode* nodeParent = nil; - if (node) { - nodeParent = node->GetParent(); - // There should always be a parent node. - DCHECK(nodeParent); - while (nodeParent) { - int nodeRow = IndexOfFolderChild(node); - rowsToSelect.push_front(nodeRow); - node = nodeParent; - nodeParent = nodeParent->GetParent(); - } - } else { - BookmarkModel* model = profile_->GetBookmarkModel(); - nodeParent = model->GetBookmarkBarNode(); - rowsToSelect.push_front(0); +- (BOOL)okEnabled { + return YES; +} + +- (IBAction)ok:(id)sender { + // At least one of these two functions should be provided by derived classes. + BOOL hasWillCommit = [self respondsToSelector:@selector(willCommit)]; + BOOL hasDidCommit = [self respondsToSelector:@selector(didCommit)]; + DCHECK(hasWillCommit || hasDidCommit); + BOOL shouldContinue = YES; + if (hasWillCommit) { + NSNumber* hasWillContinue = [self performSelector:@selector(willCommit)]; + if (hasWillContinue && [hasWillContinue isKindOfClass:[NSNumber class]]) + shouldContinue = [hasWillContinue boolValue]; } - for (std::deque<NSInteger>::size_type column = 0; - column < rowsToSelect.size(); - ++column) { - [folderBrowser_ selectRow:rowsToSelect[column] inColumn:column]; + if (shouldContinue) + [self createNewFolders]; + if (hasDidCommit) { + NSNumber* hasDidContinue = [self performSelector:@selector(didCommit)]; + if (hasDidContinue && [hasDidContinue isKindOfClass:[NSNumber class]]) + shouldContinue = [hasDidContinue boolValue]; } + if (shouldContinue) + [NSApp endSheet:[self window]]; +} - // Force the OK button state to be re-evaluated. - [self willChangeValueForKey:@"okEnabled"]; - [self didChangeValueForKey:@"okEnabled"]; +- (IBAction)cancel:(id)sender { + [NSApp endSheet:[self window]]; +} + +- (void)didEndSheet:(NSWindow*)sheet + returnCode:(int)returnCode + contextInfo:(void*)contextInfo { + [sheet close]; +} + +- (void)windowWillClose:(NSNotification*)notification { + [self autorelease]; +} + +#pragma mark Folder Tree Management + +- (BookmarkModel*)bookmarkModel { + return profile_->GetBookmarkModel(); +} + +- (const BookmarkNode*)parentNode { + return parentNode_; +} + +- (BookmarkFolderInfo*)folderForIndexPath:(NSIndexPath*)indexPath { + NSUInteger pathCount = [indexPath length]; + BookmarkFolderInfo* item = nil; + NSArray* treeNode = [self folderTreeArray]; + for (NSUInteger i = 0; i < pathCount; ++i) { + item = [treeNode objectAtIndex:[indexPath indexAtPosition:i]]; + treeNode = [item children]; + } + return item; +} + +- (NSIndexPath*)selectedIndexPath { + NSIndexPath* selectedIndexPath = nil; + NSArray* selections = [self tableSelectionPaths]; + if ([selections count]) { + DCHECK([selections count] == 1); // Should be exactly one selection. + selectedIndexPath = [selections objectAtIndex:0]; + } + return selectedIndexPath; +} + +- (BookmarkFolderInfo*)selectedFolder { + BookmarkFolderInfo* item = nil; + NSIndexPath* selectedIndexPath = [self selectedIndexPath]; + if (selectedIndexPath) { + item = [self folderForIndexPath:selectedIndexPath]; + } + return item; } - (const BookmarkNode*)selectedNode { - BookmarkModel* model = profile_->GetBookmarkModel(); const BookmarkNode* selectedNode = NULL; // Determine a new parent node only if the browser is showing. if (configuration_ == BookmarkEditor::SHOW_TREE) { - selectedNode = model->root_node(); - NSInteger column = 0; - NSInteger selectedRow = [folderBrowser_ selectedRowInColumn:column]; - while (selectedRow >= 0) { - selectedNode = GetFolderChildForParent(selectedNode, - selectedRow); - ++column; - selectedRow = [folderBrowser_ selectedRowInColumn:column]; - } + BookmarkFolderInfo* folderInfo = [self selectedFolder]; + if (folderInfo) + selectedNode = [folderInfo folderNode]; } else { // If the tree is not showing then we use the original parent. selectedNode = parentNode_; @@ -232,94 +242,156 @@ int IndexOfFolderChild(const BookmarkNode* child_node) { return selectedNode; } -- (void)NotifyHandlerCreatedNode:(const BookmarkNode*)node { +- (void)notifyHandlerCreatedNode:(const BookmarkNode*)node { if (handler_.get()) handler_->NodeCreated(node); } -#pragma mark New Folder Handler & Folder Cell Editing - -- (void)editFolderNameInCell:(BookmarkTreeBrowserCell*)cell { - DCHECK([cell isKindOfClass:[BookmarkTreeBrowserCell class]]); - [cell setEditable:YES]; - [cell setTarget:self]; - [cell setAction:@selector(cellEditingCompleted:)]; - [cell setSendsActionOnEndEditing:YES]; - NSMatrix* matrix = [cell matrix]; - // Set the delegate so that we get called when editing completes. - [matrix setDelegate:self]; - [matrix selectText:self]; -} - -- (void)cellEditingCompleted:(id)sender { - DCHECK([sender isKindOfClass:[NSMatrix class]]); - BookmarkTreeBrowserCell* cell = [sender selectedCell]; - DCHECK([cell isKindOfClass:[BookmarkTreeBrowserCell class]]); - [self saveFolderNameForCell:cell]; -} - -- (void)saveFolderNameForCell:(BookmarkTreeBrowserCell*)cell { - DCHECK([cell isKindOfClass:[BookmarkTreeBrowserCell class]]); - // It's possible that the cell can get reused so clean things up - // to prevent inadvertant notifications. - [cell setTarget:nil]; - [cell setAction:nil]; - [cell setEditable:NO]; - [cell setSendsActionOnEndEditing:NO]; - // Force a responder change here to force the editing of the cell's text - // to complete otherwise the call to -[cell title] could return stale text. - // The focus does not automatically get reset to the browser when the - // cell gives up focus. - [[folderBrowser_ window] makeFirstResponder:folderBrowser_]; - const BookmarkNode* bookmarkNode = [cell bookmarkNode]; - BookmarkModel* model = profile_->GetBookmarkModel(); - NSString* newTitle = [cell title]; - model->SetTitle(bookmarkNode, base::SysNSStringToWide(newTitle)); +- (NSArray*)folderTreeArray { + return folderTreeArray_.get(); } -- (void)browserDoubleClicked:(id)sender { - BookmarkTreeBrowserCell* cell = [folderBrowser_ selectedCell]; - DCHECK([cell isKindOfClass:[BookmarkTreeBrowserCell class]]); - [self editFolderNameInCell:cell]; +- (void)setFolderTreeArray:(NSArray*)folderTreeArray { + folderTreeArray_.reset([folderTreeArray retain]); } -- (IBAction)newFolder:(id)sender { - BookmarkModel* model = profile_->GetBookmarkModel(); - const BookmarkNode* newParentNode = [self selectedNode]; - int newIndex = newParentNode->GetChildCount(); - std::wstring newFolderString = - l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME); - const BookmarkNode* newFolder = model->AddGroup(newParentNode, newIndex, - newFolderString); - [self selectNodeInBrowser:newFolder]; - BookmarkTreeBrowserCell* cell = [folderBrowser_ selectedCell]; - [self editFolderNameInCell:cell]; +- (NSArray*)tableSelectionPaths { + return tableSelectionPaths_.get(); } -- (BOOL)okEnabled { - return YES; +- (void)setTableSelectionPath:(NSIndexPath*)tableSelectionPath { + [self setTableSelectionPaths:[NSArray arrayWithObject:tableSelectionPath]]; } -- (IBAction)ok:(id)sender { - [NSApp endSheet:[self window]]; +- (void)setTableSelectionPaths:(NSArray*)tableSelectionPaths { + tableSelectionPaths_.reset([tableSelectionPaths retain]); } -- (IBAction)cancel:(id)sender { - [NSApp endSheet:[self window]]; +- (void)selectNodeInBrowser:(const BookmarkNode*)node { + DCHECK(configuration_ == BookmarkEditor::SHOW_TREE); + NSIndexPath* selectionPath = [self selectionPathForNode:node]; + [self willChangeValueForKey:@"okEnabled"]; + [self setTableSelectionPath:selectionPath]; + [self didChangeValueForKey:@"okEnabled"]; } -- (void)didEndSheet:(NSWindow*)sheet - returnCode:(int)returnCode - contextInfo:(void*)contextInfo { - [sheet close]; +- (NSIndexPath*)selectionPathForNode:(const BookmarkNode*)desiredNode { + // Back up the parent chaing for desiredNode, building up a stack + // of ancestor nodes. Then crawl down the folderTreeArray looking + // for each ancestor in order while building up the selectionPath. + std::stack<const BookmarkNode*> nodeStack; + BookmarkModel* model = profile_->GetBookmarkModel(); + const BookmarkNode* rootNode = model->root_node(); + const BookmarkNode* node = desiredNode; + while (node != rootNode) { + nodeStack.push(node); + node = node->GetParent(); + } + NSUInteger stackSize = nodeStack.size(); + + NSIndexPath* path = nil; + NSArray* folders = [self folderTreeArray]; + while (!nodeStack.empty()) { + node = nodeStack.top(); + nodeStack.pop(); + // Find node in the current folders array. + NSUInteger i = 0; + for (BookmarkFolderInfo *folderInfo in folders) { + const BookmarkNode* testNode = [folderInfo folderNode]; + if (testNode == node) { + path = path ? [path indexPathByAddingIndex:i] : + [NSIndexPath indexPathWithIndex:i]; + folders = [folderInfo children]; + break; + } + ++i; + } + } + DCHECK([path length] == stackSize); + return path; } -- (BookmarkModel*)bookmarkModel { - return profile_->GetBookmarkModel(); +- (NSMutableArray*)addChildFoldersFromNode:(const BookmarkNode*)node { + NSMutableArray* childFolders = nil; + int childCount = node->GetChildCount(); + for (int i = 0; i < childCount; ++i) { + const BookmarkNode* childNode = node->GetChild(i); + if (childNode->type() != BookmarkNode::URL) { + NSString* childName = base::SysWideToNSString(childNode->GetTitle()); + NSMutableArray* children = [self addChildFoldersFromNode:childNode]; + BookmarkFolderInfo* folderInfo = + [BookmarkFolderInfo bookmarkFolderInfoWithFolderName:childName + folderNode:childNode + children:children]; + if (!childFolders) + childFolders = [NSMutableArray arrayWithObject:folderInfo]; + else + [childFolders addObject:folderInfo]; + } + } + return childFolders; } -- (const BookmarkNode*)parentNode { - return parentNode_; +#pragma mark New Folder Handler + +- (void)createNewFoldersForFolder:(BookmarkFolderInfo*)folderInfo { + NSArray* subfolders = [folderInfo children]; + const BookmarkNode* parentNode = [folderInfo folderNode]; + DCHECK(parentNode); + NSUInteger i = 0; + for (BookmarkFolderInfo *subFolderInfo in subfolders) { + if ([subFolderInfo newFolder]) { + BookmarkModel* model = [self bookmarkModel]; + const BookmarkNode* newFolder = + model->AddGroup(parentNode, i, + base::SysNSStringToWide([subFolderInfo folderName])); + [self notifyHandlerCreatedNode:newFolder]; + // Update our dictionary with the actual folder node just created. + [subFolderInfo setFolderNode:newFolder]; + [subFolderInfo setNewFolder:NO]; + } + [self createNewFoldersForFolder:subFolderInfo]; + ++i; + } +} + +- (IBAction)newFolder:(id)sender { + // Create a new folder off of the selected folder node. + BookmarkFolderInfo* parentInfo = [self selectedFolder]; + if (parentInfo) { + NSIndexPath* selection = [self selectedIndexPath]; + NSString* newFolderName = + l10n_util::GetNSStringWithFixup(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME); + BookmarkFolderInfo* folderInfo = + [BookmarkFolderInfo bookmarkFolderInfoWithFolderName:newFolderName]; + [self willChangeValueForKey:@"folderTreeArray"]; + NSMutableArray* children = [parentInfo children]; + if (children) { + [children addObject:folderInfo]; + } else { + children = [NSMutableArray arrayWithObject:folderInfo]; + [parentInfo setChildren:children]; + } + [self didChangeValueForKey:@"folderTreeArray"]; + + // Expose the parent folder children. + [folderTreeView_ expandItem:parentInfo]; + + // Select the new folder node and put the folder name into edit mode. + selection = [selection indexPathByAddingIndex:[children count] - 1]; + [self setTableSelectionPath:selection]; + NSInteger row = [folderTreeView_ selectedRow]; + DCHECK(row >= 0); + [folderTreeView_ editColumn:0 row:row withEvent:nil select:YES]; + } +} + +- (void)createNewFolders { + // Scan the tree looking for nodes marked 'newFolder' and create those nodes. + NSArray* folderTreeArray = [self folderTreeArray]; + for (BookmarkFolderInfo *folderInfo in folderTreeArray) { + [self createNewFoldersForFolder:folderInfo]; + } } #pragma mark For Unit Test Use Only @@ -332,67 +404,64 @@ int IndexOfFolderChild(const BookmarkNode* child_node) { [self selectNodeInBrowser:node]; } -+ (const BookmarkNode*)folderChildForParent:(const BookmarkNode*)parent - withFolderIndex:(NSInteger)index { - return GetFolderChildForParent(parent, index); -} +@end // BookmarkEditorBaseController -+ (int)indexOfFolderChild:(const BookmarkNode*)child { - return IndexOfFolderChild(child); +@implementation BookmarkFolderInfo + +@synthesize folderName = folderName_; +@synthesize folderNode = folderNode_; +@synthesize children = children_; +@synthesize newFolder = newFolder_; + ++ (id)bookmarkFolderInfoWithFolderName:(NSString*)folderName + folderNode:(const BookmarkNode*)folderNode + children:(NSMutableArray*)children { + return [[[BookmarkFolderInfo alloc] initWithFolderName:folderName + folderNode:folderNode + children:children + newFolder:NO] + autorelease]; } ++ (id)bookmarkFolderInfoWithFolderName:(NSString*)folderName { + return [[[BookmarkFolderInfo alloc] initWithFolderName:folderName + folderNode:NULL + children:nil + newFolder:YES] + autorelease]; +} -#pragma mark NSBrowser delegate methods - -// Given a column number, determine the parent bookmark folder node for the -// bookmarks being shown in that column. This is done by scanning forward -// from column zero and following the selected row for each column up -// to the parent of the desired column. -- (const BookmarkNode*)parentNodeForColumn:(NSInteger)column { - DCHECK(column >= 0); - BookmarkModel* model = profile_->GetBookmarkModel(); - const BookmarkNode* node = model->root_node(); - for (NSInteger i = 0; i < column; ++i) { - NSInteger selectedRowInColumn = [folderBrowser_ selectedRowInColumn:i]; - node = GetFolderChildForParent(node, selectedRowInColumn); - } - return node; -} - -// This implementation returns the number of folders contained in the parent -// folder node for this column. -// TOTO(mrossetti): Decide if bookmark (i.e. non-folder) nodes should be -// shown, perhaps in gray. -- (NSInteger)browser:(NSBrowser*)sender numberOfRowsInColumn:(NSInteger)col { - NSInteger rowCount = 0; - const BookmarkNode* parentNode = [self parentNodeForColumn:col]; - if (parentNode) { - int childCount = parentNode->GetChildCount(); - for (int i = 0; i < childCount; ++i) { - const BookmarkNode* childNode = parentNode->GetChild(i); - if (childNode->type() != BookmarkNode::URL) - ++rowCount; +- (id)initWithFolderName:(NSString*)folderName + folderNode:(const BookmarkNode*)folderNode + children:(NSMutableArray*)children + newFolder:(BOOL)newFolder { + if ((self = [super init])) { + // A folderName is always required, and if newFolder is NO then there + // should be a folderNode. Children is optional. + DCHECK(folderName && (newFolder || folderNode)); + if (folderName && (newFolder || folderNode)) { + folderName_ = [folderName copy]; + folderNode_ = folderNode; + children_ = [children retain]; + newFolder_ = newFolder; + } else { + NOTREACHED(); // Invalid init. + [self release]; + self = nil; } } - return rowCount; -} - -- (void)browser:(NSBrowser*)sender - willDisplayCell:(NSBrowserCell*)cell - atRow:(NSInteger)row - column:(NSInteger)column { - DCHECK(row >= 0); // Trust AppKit, but verify. - DCHECK(column >= 0); - DCHECK([cell isKindOfClass:[BookmarkTreeBrowserCell class]]); - const BookmarkNode* parentNode = [self parentNodeForColumn:column]; - const BookmarkNode* childNode = GetFolderChildForParent(parentNode, row); - DCHECK(childNode); - BookmarkTreeBrowserCell* browserCell = - static_cast<BookmarkTreeBrowserCell*>(cell); - [browserCell setTitle:base::SysWideToNSString(childNode->GetTitle())]; - [browserCell setBookmarkNode:childNode]; - [browserCell setMatrix:[folderBrowser_ matrixInColumn:column]]; + return self; } -@end // BookmarkEditorBaseController +- (id)init { + NOTREACHED(); // Should never be called. + return [self initWithFolderName:nil folderNode:nil children:nil newFolder:NO]; +} + +- (void)dealloc { + [folderName_ release]; + [children_ release]; + [super dealloc]; +} +@end diff --git a/chrome/browser/cocoa/bookmark_editor_base_controller_unittest.mm b/chrome/browser/cocoa/bookmark_editor_base_controller_unittest.mm index 2bb1fa1..698276e 100644 --- a/chrome/browser/cocoa/bookmark_editor_base_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_editor_base_controller_unittest.mm @@ -4,18 +4,20 @@ #import <Cocoa/Cocoa.h> +#include "app/l10n_util_mac.h" #include "base/scoped_nsobject.h" #include "base/sys_string_conversions.h" #import "chrome/browser/cocoa/bookmark_editor_controller.h" #include "chrome/browser/cocoa/browser_test_helper.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" +#include "grit/generated_resources.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" class BookmarkEditorBaseControllerTest : public CocoaTest { public: - BrowserTestHelper helper_; - BookmarkEditorBaseController* controller_; + BrowserTestHelper browser_helper_; + BookmarkEditorBaseController* controller_; // weak const BookmarkNode* group_a_; const BookmarkNode* group_b_; const BookmarkNode* group_b_0_; @@ -33,7 +35,7 @@ class BookmarkEditorBaseControllerTest : public CocoaTest { // b-30 // b-31 // b-4 - BookmarkModel& model(*(helper_.profile()->GetBookmarkModel())); + BookmarkModel& model(*(browser_helper_.profile()->GetBookmarkModel())); const BookmarkNode* root = model.GetBookmarkBarNode(); group_a_ = model.AddGroup(root, 0, L"a"); model.AddURL(group_a_, 0, L"a-0", GURL("http://a-0.com")); @@ -63,7 +65,7 @@ class BookmarkEditorBaseControllerTest : public CocoaTest { return [[BookmarkEditorBaseController alloc] initWithParentWindow:test_window() nibName:@"BookmarkAllTabs" - profile:helper_.profile() + profile:browser_helper_.profile() parent:group_b_0_ configuration:BookmarkEditor::SHOW_TREE handler:nil]; @@ -73,16 +75,17 @@ class BookmarkEditorBaseControllerTest : public CocoaTest { CocoaTest::SetUp(); controller_ = CreateController(); EXPECT_TRUE([controller_ window]); + [controller_ runAsModalSheet]; } virtual void TearDown() { - [controller_ close]; + controller_ = NULL; CocoaTest::TearDown(); } }; TEST_F(BookmarkEditorBaseControllerTest, VerifyBookmarkTestModel) { - BookmarkModel& model(*(helper_.profile()->GetBookmarkModel())); + BookmarkModel& model(*(browser_helper_.profile()->GetBookmarkModel())); const BookmarkNode& root(*model.GetBookmarkBarNode()); EXPECT_EQ(4, root.GetChildCount()); // a @@ -127,22 +130,52 @@ TEST_F(BookmarkEditorBaseControllerTest, VerifyBookmarkTestModel) { // d child = root.GetChild(3); EXPECT_EQ(0, child->GetChildCount()); + [controller_ cancel:nil]; } -TEST_F(BookmarkEditorBaseControllerTest, FolderChildForParent) { - const BookmarkNode* child = - [BookmarkEditorBaseController folderChildForParent:group_b_ - withFolderIndex:1]; - EXPECT_EQ(child, group_b_3_); +TEST_F(BookmarkEditorBaseControllerTest, NodeSelection) { + EXPECT_TRUE([controller_ folderTreeArray]); + [controller_ selectTestNodeInBrowser:group_b_3_]; + const BookmarkNode* node = [controller_ selectedNode]; + EXPECT_EQ(node, group_b_3_); + [controller_ cancel:nil]; } -TEST_F(BookmarkEditorBaseControllerTest, IndexOfFolderChild) { - int index = [BookmarkEditorBaseController indexOfFolderChild:group_b_3_]; - EXPECT_EQ(index, 1); +TEST_F(BookmarkEditorBaseControllerTest, CreateFolder) { + EXPECT_EQ(2, group_b_3_->GetChildCount()); + [controller_ selectTestNodeInBrowser:group_b_3_]; + NSString* expectedName = + l10n_util::GetNSStringWithFixup(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME); + [controller_ setDisplayName:expectedName]; + [controller_ newFolder:nil]; + NSArray* selectionPaths = [controller_ tableSelectionPaths]; + EXPECT_EQ(1U, [selectionPaths count]); + NSIndexPath* selectionPath = [selectionPaths objectAtIndex:0]; + EXPECT_EQ(4U, [selectionPath length]); + BookmarkFolderInfo* newFolderInfo = [controller_ selectedFolder]; + EXPECT_TRUE(newFolderInfo); + NSString* newFolderName = [newFolderInfo folderName]; + EXPECT_TRUE([newFolderName isEqualToString:expectedName]); + [controller_ createNewFolders]; + // Verify that the tab folder was added to the new folder. + EXPECT_EQ(3, group_b_3_->GetChildCount()); + [controller_ cancel:nil]; } -TEST_F(BookmarkEditorBaseControllerTest, NodeSelection) { - [controller_ selectNodeInBrowser:group_b_3_]; - const BookmarkNode* node = [controller_ selectedNode]; - EXPECT_EQ(node, group_b_3_); + +class BookmarkFolderInfoTest : public CocoaTest { }; + +TEST_F(BookmarkFolderInfoTest, Construction) { + NSMutableArray* children = [NSMutableArray arrayWithObject:@"child"]; + // We just need a pointer, and any pointer will do. + const BookmarkNode* fakeNode = + reinterpret_cast<const BookmarkNode*>(&children); + BookmarkFolderInfo* info = + [BookmarkFolderInfo bookmarkFolderInfoWithFolderName:@"name" + folderNode:fakeNode + children:children]; + EXPECT_TRUE(info); + EXPECT_EQ([info folderName], @"name"); + EXPECT_EQ([info children], children); + EXPECT_EQ([info folderNode], fakeNode); } diff --git a/chrome/browser/cocoa/bookmark_editor_controller.h b/chrome/browser/cocoa/bookmark_editor_controller.h index ff779b8..1fcf5f7 100644 --- a/chrome/browser/cocoa/bookmark_editor_controller.h +++ b/chrome/browser/cocoa/bookmark_editor_controller.h @@ -7,8 +7,9 @@ #import "chrome/browser/cocoa/bookmark_editor_base_controller.h" -// A controller for the bookmark editor, opened with Edit... from the -// context menu of a bookmark button. +// A controller for the bookmark editor, opened by 1) Edit... from the +// context menu of a bookmark button, and 2) Bookmark this Page...'s Edit +// button. @interface BookmarkEditorController : BookmarkEditorBaseController { @private const BookmarkNode* node_; // weak; owned by the model diff --git a/chrome/browser/cocoa/bookmark_editor_controller.mm b/chrome/browser/cocoa/bookmark_editor_controller.mm index 8164d4b..f471f1f 100644 --- a/chrome/browser/cocoa/bookmark_editor_controller.mm +++ b/chrome/browser/cocoa/bookmark_editor_controller.mm @@ -87,8 +87,9 @@ // should not be enabled). If the bookmark previously existed then it is // removed from its old folder. The bookmark is then added to its new // folder. If the folder has not changed then the bookmark stays in its -// original position (index) otherwise it is added to the end of the new folder. -- (IBAction)ok:(id)sender { +// original position (index) otherwise it is added to the end of the new +// folder. Called by -[BookmarkEditorBaseController ok:]. +- (NSNumber*)didCommit { NSString* name = [[self displayName] stringByTrimmingCharactersInSet: [NSCharacterSet newlineCharacterSet]]; std::wstring newTitle = base::SysNSStringToWide(name); @@ -97,9 +98,9 @@ int newIndex = newParentNode->GetChildCount(); GURL newURL = [self GURLFromUrlField]; if (!newURL.is_valid()) { - // Shouldn't be reached -- OK button disabled if not valid! + // Shouldn't be reached -- OK button should be disabled if not valid! NOTREACHED(); - return; + return [NSNumber numberWithBool:NO]; } // Determine where the new/replacement bookmark is to go. @@ -116,8 +117,8 @@ const BookmarkNode* node = model->AddURL(newParentNode, newIndex, newTitle, newURL); // Honor handler semantics: callback on node creation. - [self NotifyHandlerCreatedNode:node]; - [super ok:sender]; + [self notifyHandlerCreatedNode:node]; + return [NSNumber numberWithBool:YES]; } @end // BookmarkEditorController diff --git a/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm b/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm index db340b1..f505585 100644 --- a/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_editor_controller_unittest.mm @@ -4,7 +4,6 @@ #import <Cocoa/Cocoa.h> -#include "base/scoped_nsobject.h" #include "base/sys_string_conversions.h" #import "chrome/browser/cocoa/bookmark_editor_controller.h" #include "chrome/browser/cocoa/browser_test_helper.h" @@ -14,86 +13,40 @@ class BookmarkEditorControllerTest : public CocoaTest { public: - BrowserTestHelper helper_; + BrowserTestHelper browser_helper_; const BookmarkNode* default_node_; const BookmarkNode* default_parent_; const char* default_name_; std::wstring default_title_; - BookmarkEditorController* default_controller_; + BookmarkEditorController* controller_; virtual void SetUp() { CocoaTest::SetUp(); - BookmarkModel* model = helper_.profile()->GetBookmarkModel(); + BookmarkModel* model = browser_helper_.profile()->GetBookmarkModel(); default_parent_ = model->GetBookmarkBarNode(); default_name_ = "http://www.zim-bop-a-dee.com/"; default_title_ = L"ooh title"; const BookmarkNode* default_node = model->AddURL(default_parent_, 0, default_title_, GURL(default_name_)); - default_controller_ = [[BookmarkEditorController alloc] - initWithParentWindow:test_window() - profile:helper_.profile() - parent:default_parent_ - node:default_node - configuration:BookmarkEditor::NO_TREE - handler:nil]; - [default_controller_ window]; // Forces a nib load + controller_ = [[BookmarkEditorController alloc] + initWithParentWindow:test_window() + profile:browser_helper_.profile() + parent:default_parent_ + node:default_node + configuration:BookmarkEditor::NO_TREE + handler:nil]; + [controller_ runAsModalSheet]; } virtual void TearDown() { - [default_controller_ close]; + controller_ = NULL; CocoaTest::TearDown(); } }; -TEST_F(BookmarkEditorControllerTest, NoNodeNoTree) { - BookmarkModel* model = helper_.profile()->GetBookmarkModel(); - const BookmarkNode* parent = model->GetBookmarkBarNode(); - const BookmarkNode* node = NULL; - - BookmarkEditorController* controller = - [[BookmarkEditorController alloc] - initWithParentWindow:test_window() - profile:helper_.profile() - parent:parent - node:node - configuration:BookmarkEditor::NO_TREE - handler:nil]; - - EXPECT_NE((NSWindow*)nil, [controller window]); // Forces a nib load - EXPECT_EQ(@"", [controller displayName]); - EXPECT_EQ(@"", [controller displayURL]); - EXPECT_FALSE([controller okButtonEnabled]); - [controller close]; -} - -TEST_F(BookmarkEditorControllerTest, YesNodeShowTree) { - BookmarkModel* model = helper_.profile()->GetBookmarkModel(); - const BookmarkNode* parent = model->GetBookmarkBarNode(); - const char* url_name = "http://www.zim-bop-a-dee.com/"; - const BookmarkNode* node = model->AddURL(parent, 0, default_title_, - GURL(url_name)); - - BookmarkEditorController* controller = - [[BookmarkEditorController alloc] - initWithParentWindow:test_window() - profile:helper_.profile() - parent:parent - node:node - configuration:BookmarkEditor::SHOW_TREE - handler:nil]; - - EXPECT_NE((NSWindow*)nil, [controller window]); // Forces a nib load - EXPECT_TRUE([base::SysWideToNSString(default_title_) - isEqual:[controller displayName]]); - EXPECT_TRUE([[NSString stringWithCString:url_name - encoding:NSUTF8StringEncoding] - isEqual:[controller displayURL]]); - [controller close]; -} - TEST_F(BookmarkEditorControllerTest, NoEdit) { - [default_controller_ ok:nil]; + [controller_ cancel:nil]; ASSERT_EQ(default_parent_->GetChildCount(), 1); const BookmarkNode* child = default_parent_->GetChild(0); EXPECT_EQ(child->GetTitle(), default_title_); @@ -101,8 +54,8 @@ TEST_F(BookmarkEditorControllerTest, NoEdit) { } TEST_F(BookmarkEditorControllerTest, EditTitle) { - [default_controller_ setDisplayName:@"whamma jamma bamma"]; - [default_controller_ ok:nil]; + [controller_ setDisplayName:@"whamma jamma bamma"]; + [controller_ ok:nil]; ASSERT_EQ(default_parent_->GetChildCount(), 1); const BookmarkNode* child = default_parent_->GetChild(0); EXPECT_EQ(child->GetTitle(), L"whamma jamma bamma"); @@ -110,10 +63,10 @@ TEST_F(BookmarkEditorControllerTest, EditTitle) { } TEST_F(BookmarkEditorControllerTest, EditURL) { - EXPECT_TRUE([default_controller_ okButtonEnabled]); - [default_controller_ setDisplayURL:@"http://yellow-sneakers.com/"]; - EXPECT_TRUE([default_controller_ okButtonEnabled]); - [default_controller_ ok:nil]; + EXPECT_TRUE([controller_ okButtonEnabled]); + [controller_ setDisplayURL:@"http://yellow-sneakers.com/"]; + EXPECT_TRUE([controller_ okButtonEnabled]); + [controller_ ok:nil]; ASSERT_EQ(default_parent_->GetChildCount(), 1); const BookmarkNode* child = default_parent_->GetChild(0); EXPECT_EQ(child->GetTitle(), default_title_); @@ -121,8 +74,8 @@ TEST_F(BookmarkEditorControllerTest, EditURL) { } TEST_F(BookmarkEditorControllerTest, EditAndFixPrefix) { - [default_controller_ setDisplayURL:@"x"]; - [default_controller_ ok:nil]; + [controller_ setDisplayURL:@"x"]; + [controller_ ok:nil]; ASSERT_EQ(default_parent_->GetChildCount(), 1); const BookmarkNode* child = default_parent_->GetChild(0); EXPECT_TRUE(child->GetURL().is_valid()); @@ -131,27 +84,102 @@ TEST_F(BookmarkEditorControllerTest, EditAndFixPrefix) { TEST_F(BookmarkEditorControllerTest, EditAndConfirmOKButton) { // Confirm OK button enabled/disabled as appropriate: // First test the URL. - EXPECT_TRUE([default_controller_ okButtonEnabled]); - [default_controller_ setDisplayURL:@""]; - EXPECT_FALSE([default_controller_ okButtonEnabled]); - [default_controller_ setDisplayURL:@"http://www.cnn.com"]; - EXPECT_TRUE([default_controller_ okButtonEnabled]); + EXPECT_TRUE([controller_ okButtonEnabled]); + [controller_ setDisplayURL:@""]; + EXPECT_FALSE([controller_ okButtonEnabled]); + [controller_ setDisplayURL:@"http://www.cnn.com"]; + EXPECT_TRUE([controller_ okButtonEnabled]); // Then test the name. - [default_controller_ setDisplayName:@""]; - EXPECT_TRUE([default_controller_ okButtonEnabled]); - [default_controller_ setDisplayName:@" "]; - EXPECT_TRUE([default_controller_ okButtonEnabled]); + [controller_ setDisplayName:@""]; + EXPECT_TRUE([controller_ okButtonEnabled]); + [controller_ setDisplayName:@" "]; + EXPECT_TRUE([controller_ okButtonEnabled]); // Then little mix of both. - [default_controller_ setDisplayName:@"name"]; - EXPECT_TRUE([default_controller_ okButtonEnabled]); - [default_controller_ setDisplayURL:@""]; - EXPECT_FALSE([default_controller_ okButtonEnabled]); + [controller_ setDisplayName:@"name"]; + EXPECT_TRUE([controller_ okButtonEnabled]); + [controller_ setDisplayURL:@""]; + EXPECT_FALSE([controller_ okButtonEnabled]); + [controller_ cancel:nil]; +} + +class BookmarkEditorControllerNoNodeTest : public CocoaTest { + public: + BrowserTestHelper browser_helper_; + BookmarkEditorController* controller_; + + virtual void SetUp() { + CocoaTest::SetUp(); + BookmarkModel* model = browser_helper_.profile()->GetBookmarkModel(); + const BookmarkNode* parent = model->GetBookmarkBarNode(); + controller_ = [[BookmarkEditorController alloc] + initWithParentWindow:test_window() + profile:browser_helper_.profile() + parent:parent + node:NULL + configuration:BookmarkEditor::NO_TREE + handler:nil]; + + [controller_ runAsModalSheet]; + } + + virtual void TearDown() { + controller_ = NULL; + CocoaTest::TearDown(); + } +}; + +TEST_F(BookmarkEditorControllerNoNodeTest, NoNodeNoTree) { + EXPECT_EQ(@"", [controller_ displayName]); + EXPECT_EQ(@"", [controller_ displayURL]); + EXPECT_FALSE([controller_ okButtonEnabled]); + [controller_ cancel:nil]; +} + +class BookmarkEditorControllerYesNodeTest : public CocoaTest { + public: + BrowserTestHelper browser_helper_; + std::wstring default_title_; + const char* url_name_; + BookmarkEditorController* controller_; + + virtual void SetUp() { + CocoaTest::SetUp(); + BookmarkModel* model = browser_helper_.profile()->GetBookmarkModel(); + const BookmarkNode* parent = model->GetBookmarkBarNode(); + default_title_ = L"wooh title"; + url_name_ = "http://www.zoom-baby-doo-da.com/"; + const BookmarkNode* node = model->AddURL(parent, 0, default_title_, + GURL(url_name_)); + controller_ = [[BookmarkEditorController alloc] + initWithParentWindow:test_window() + profile:browser_helper_.profile() + parent:parent + node:node + configuration:BookmarkEditor::NO_TREE + handler:nil]; + + [controller_ runAsModalSheet]; + } + + virtual void TearDown() { + controller_ = NULL; + CocoaTest::TearDown(); + } +}; + +TEST_F(BookmarkEditorControllerYesNodeTest, YesNodeShowTree) { + EXPECT_TRUE([base::SysWideToNSString(default_title_) + isEqual:[controller_ displayName]]); + EXPECT_TRUE([[NSString stringWithCString:url_name_ + encoding:NSUTF8StringEncoding] + isEqual:[controller_ displayURL]]); + [controller_ cancel:nil]; } class BookmarkEditorControllerTreeTest : public CocoaTest { public: - BrowserTestHelper helper_; - BookmarkEditorController* default_controller_; + BrowserTestHelper browser_helper_; + BookmarkEditorController* controller_; const BookmarkNode* group_a_; const BookmarkNode* group_b_; const BookmarkNode* group_bb_; @@ -169,7 +197,7 @@ class BookmarkEditorControllerTreeTest : public CocoaTest { // bb-4 // b-1 // b-2 - BookmarkModel& model(*(helper_.profile()->GetBookmarkModel())); + BookmarkModel& model(*(browser_helper_.profile()->GetBookmarkModel())); const BookmarkNode* root = model.GetBookmarkBarNode(); group_a_ = model.AddGroup(root, 0, L"a"); model.AddURL(group_a_, 0, L"a-0", GURL("http://a-0.com")); @@ -200,7 +228,7 @@ class BookmarkEditorControllerTreeTest : public CocoaTest { virtual BookmarkEditorController* CreateController() { return [[BookmarkEditorController alloc] initWithParentWindow:test_window() - profile:helper_.profile() + profile:browser_helper_.profile() parent:group_bb_ node:bookmark_bb_3_ configuration:BookmarkEditor::SHOW_TREE @@ -208,19 +236,18 @@ class BookmarkEditorControllerTreeTest : public CocoaTest { } virtual void SetUp() { - CocoaTest::SetUp(); - default_controller_ = CreateController(); - EXPECT_TRUE([default_controller_ window]); + controller_ = CreateController(); + [controller_ runAsModalSheet]; } virtual void TearDown() { - [default_controller_ close]; + controller_ = NULL; CocoaTest::TearDown(); } }; TEST_F(BookmarkEditorControllerTreeTest, VerifyBookmarkTestModel) { - BookmarkModel& model(*(helper_.profile()->GetBookmarkModel())); + BookmarkModel& model(*(browser_helper_.profile()->GetBookmarkModel())); model.root_node(); const BookmarkNode& root(*model.GetBookmarkBarNode()); EXPECT_EQ(4, root.GetChildCount()); @@ -267,12 +294,13 @@ TEST_F(BookmarkEditorControllerTreeTest, VerifyBookmarkTestModel) { child = root.GetChild(3); EXPECT_EQ(0, child->GetChildCount()); + [controller_ cancel:nil]; } TEST_F(BookmarkEditorControllerTreeTest, RenameBookmarkInPlace) { const BookmarkNode* oldParent = bookmark_bb_3_->GetParent(); - [default_controller_ setDisplayName:@"NEW NAME"]; - [default_controller_ ok:nil]; + [controller_ setDisplayName:@"NEW NAME"]; + [controller_ ok:nil]; const BookmarkNode* newParent = bookmark_bb_3_->GetParent(); ASSERT_EQ(newParent, oldParent); int childIndex = newParent->IndexOfChild(bookmark_bb_3_); @@ -281,8 +309,8 @@ TEST_F(BookmarkEditorControllerTreeTest, RenameBookmarkInPlace) { TEST_F(BookmarkEditorControllerTreeTest, ChangeBookmarkURLInPlace) { const BookmarkNode* oldParent = bookmark_bb_3_->GetParent(); - [default_controller_ setDisplayURL:@"http://NEWURL.com"]; - [default_controller_ ok:nil]; + [controller_ setDisplayURL:@"http://NEWURL.com"]; + [controller_ ok:nil]; const BookmarkNode* newParent = bookmark_bb_3_->GetParent(); ASSERT_EQ(newParent, oldParent); int childIndex = newParent->IndexOfChild(bookmark_bb_3_); @@ -290,8 +318,8 @@ TEST_F(BookmarkEditorControllerTreeTest, ChangeBookmarkURLInPlace) { } TEST_F(BookmarkEditorControllerTreeTest, ChangeBookmarkGroup) { - [default_controller_ selectTestNodeInBrowser:group_c_]; - [default_controller_ ok:nil]; + [controller_ selectTestNodeInBrowser:group_c_]; + [controller_ ok:nil]; const BookmarkNode* parent = bookmark_bb_3_->GetParent(); ASSERT_EQ(parent, group_c_); int childIndex = parent->IndexOfChild(bookmark_bb_3_); @@ -299,9 +327,9 @@ TEST_F(BookmarkEditorControllerTreeTest, ChangeBookmarkGroup) { } TEST_F(BookmarkEditorControllerTreeTest, ChangeNameAndBookmarkGroup) { - [default_controller_ setDisplayName:@"NEW NAME"]; - [default_controller_ selectTestNodeInBrowser:group_c_]; - [default_controller_ ok:nil]; + [controller_ setDisplayName:@"NEW NAME"]; + [controller_ selectTestNodeInBrowser:group_c_]; + [controller_ ok:nil]; const BookmarkNode* parent = bookmark_bb_3_->GetParent(); ASSERT_EQ(parent, group_c_); int childIndex = parent->IndexOfChild(bookmark_bb_3_); @@ -310,11 +338,10 @@ TEST_F(BookmarkEditorControllerTreeTest, ChangeNameAndBookmarkGroup) { } TEST_F(BookmarkEditorControllerTreeTest, AddFolderWithGroupSelected) { - [default_controller_ newFolder:nil]; - [default_controller_ cancel:nil]; - EXPECT_EQ(6, group_bb_->GetChildCount()); - const BookmarkNode* folderChild = group_bb_->GetChild(5); - EXPECT_EQ(folderChild->GetTitle(), L"New folder"); + // Folders are NOT added unless the OK button is pressed. + [controller_ newFolder:nil]; + [controller_ cancel:nil]; + EXPECT_EQ(5, group_bb_->GetChildCount()); } class BookmarkEditorControllerTreeNoNodeTest : @@ -323,7 +350,7 @@ class BookmarkEditorControllerTreeNoNodeTest : virtual BookmarkEditorController* CreateController() { return [[BookmarkEditorController alloc] initWithParentWindow:test_window() - profile:helper_.profile() + profile:browser_helper_.profile() parent:group_bb_ node:nil configuration:BookmarkEditor::SHOW_TREE @@ -333,35 +360,11 @@ class BookmarkEditorControllerTreeNoNodeTest : }; TEST_F(BookmarkEditorControllerTreeNoNodeTest, NewBookmarkNoNode) { - [default_controller_ setDisplayName:@"NEW BOOKMARK"]; - [default_controller_ setDisplayURL:@"http://NEWURL.com"]; - [default_controller_ ok:nil]; + [controller_ setDisplayName:@"NEW BOOKMARK"]; + [controller_ setDisplayURL:@"http://NEWURL.com"]; + [controller_ ok:nil]; const BookmarkNode* new_node = group_bb_->GetChild(5); ASSERT_EQ(0, new_node->GetChildCount()); EXPECT_EQ(new_node->GetTitle(), L"NEW BOOKMARK"); EXPECT_EQ(new_node->GetURL(), GURL("http://NEWURL.com")); } - -class BookmarkEditorControllerTreeNoParentTest : - public BookmarkEditorControllerTreeTest { - public: - virtual BookmarkEditorController* CreateController() { - return [[BookmarkEditorController alloc] - initWithParentWindow:test_window() - profile:helper_.profile() - parent:nil - node:nil - configuration:BookmarkEditor::SHOW_TREE - handler:nil]; - } -}; - -TEST_F(BookmarkEditorControllerTreeNoParentTest, AddFolderWithNoGroupSelected) { - [default_controller_ newFolder:nil]; - [default_controller_ cancel:nil]; - BookmarkModel* model = helper_.profile()->GetBookmarkModel(); - const BookmarkNode* bookmarkBar = model->GetBookmarkBarNode(); - EXPECT_EQ(5, bookmarkBar->GetChildCount()); - const BookmarkNode* folderChild = bookmarkBar->GetChild(4); - EXPECT_EQ(folderChild->GetTitle(), L"New folder"); -} |