diff options
-rw-r--r-- | chrome/app/nibs/en.lproj/FindBar.xib | 507 | ||||
-rw-r--r-- | chrome/app/nibs/en.lproj/MainMenu.xib | 55 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser_window_factory.mm | 8 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller.mm | 35 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.h | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.h | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 34 | ||||
-rw-r--r-- | chrome/browser/cocoa/find_bar_bridge.h | 80 | ||||
-rw-r--r-- | chrome/browser/cocoa/find_bar_bridge.mm | 69 | ||||
-rw-r--r-- | chrome/browser/cocoa/find_bar_cocoa_controller.h | 57 | ||||
-rw-r--r-- | chrome/browser/cocoa/find_bar_cocoa_controller.mm | 163 | ||||
-rw-r--r-- | chrome/browser/cocoa/find_bar_view.h | 16 | ||||
-rw-r--r-- | chrome/browser/cocoa/find_bar_view.mm | 36 | ||||
-rw-r--r-- | chrome/chrome.gyp | 7 |
17 files changed, 1047 insertions, 42 deletions
diff --git a/chrome/app/nibs/en.lproj/FindBar.xib b/chrome/app/nibs/en.lproj/FindBar.xib new file mode 100644 index 0000000..51cab7f --- /dev/null +++ b/chrome/app/nibs/en.lproj/FindBar.xib @@ -0,0 +1,507 @@ +<?xml version="1.0" encoding="UTF-8"?> +<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> + <data> + <int key="IBDocument.SystemTarget">1050</int> + <string key="IBDocument.SystemVersion">9G55</string> + <string key="IBDocument.InterfaceBuilderVersion">677</string> + <string key="IBDocument.AppKitVersion">949.43</string> + <string key="IBDocument.HIToolboxVersion">353.00</string> + <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> + <bool key="EncodedWithXMLCoder">YES</bool> + <integer value="2"/> + </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"> + <string key="NSClassName">FindBarCocoaController</string> + </object> + <object class="NSCustomObject" id="1003"> + <string key="NSClassName">FirstResponder</string> + </object> + <object class="NSCustomObject" id="1004"> + <string key="NSClassName">NSApplication</string> + </object> + <object class="NSCustomView" id="612665518"> + <reference key="NSNextResponder"/> + <int key="NSvFlags">265</int> + <object class="NSMutableArray" key="NSSubviews"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSTextField" id="445667"> + <reference key="NSNextResponder" ref="612665518"/> + <int key="NSvFlags">290</int> + <string key="NSFrame">{{175, 3}, {71, 22}}</string> + <reference key="NSSuperview" ref="612665518"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="236923920"> + <int key="NSCellFlags">-1542324672</int> + <int key="NSCellFlags2">71304192</int> + <string key="NSContents"/> + <object class="NSFont" key="NSSupport" id="197084721"> + <string key="NSName">LucidaGrande</string> + <double key="NSSize">1.300000e+01</double> + <int key="NSfFlags">1044</int> + </object> + <reference key="NSControlView" ref="445667"/> + <object class="NSColor" key="NSBackgroundColor" id="649287797"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">textBackgroundColor</string> + <object class="NSColor" key="NSColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MQA</bytes> + </object> + </object> + <object class="NSColor" key="NSTextColor"> + <int key="NSColorSpace">1</int> + <bytes key="NSRGB">MC42MTk1NjUyNSAwLjYxOTU2NTI1IDAuNjE5NTY1MjUAA</bytes> + </object> + </object> + </object> + <object class="NSTextField" id="510660793"> + <reference key="NSNextResponder" ref="612665518"/> + <int key="NSvFlags">290</int> + <string key="NSFrame">{{20, 6}, {228, 22}}</string> + <reference key="NSSuperview" ref="612665518"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="926027568"> + <int key="NSCellFlags">-1804468671</int> + <int key="NSCellFlags2">272630784</int> + <string key="NSContents"/> + <reference key="NSSupport" ref="197084721"/> + <reference key="NSControlView" ref="510660793"/> + <bool key="NSDrawsBackground">YES</bool> + <reference key="NSBackgroundColor" ref="649287797"/> + <object class="NSColor" key="NSTextColor"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">textColor</string> + <object class="NSColor" key="NSColor" id="817558590"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MAA</bytes> + </object> + </object> + </object> + </object> + <object class="NSButton" id="455192438"> + <reference key="NSNextResponder" ref="612665518"/> + <int key="NSvFlags">289</int> + <string key="NSFrame">{{256, 6}, {22, 22}}</string> + <reference key="NSSuperview" ref="612665518"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="1064223545"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents"/> + <reference key="NSSupport" ref="197084721"/> + <reference key="NSControlView" ref="455192438"/> + <int key="NSButtonFlags">-2033958657</int> + <int key="NSButtonFlags2">134</int> + <object class="NSCustomResource" key="NSNormalImage"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSGoLeftTemplate</string> + </object> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">400</int> + <int key="NSPeriodicInterval">75</int> + </object> + </object> + <object class="NSButton" id="968135285"> + <reference key="NSNextResponder" ref="612665518"/> + <int key="NSvFlags">289</int> + <string key="NSFrame">{{277, 6}, {22, 22}}</string> + <reference key="NSSuperview" ref="612665518"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="9143312"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents"/> + <reference key="NSSupport" ref="197084721"/> + <reference key="NSControlView" ref="968135285"/> + <int key="NSButtonFlags">-2033958657</int> + <int key="NSButtonFlags2">134</int> + <object class="NSCustomResource" key="NSNormalImage"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSGoRightTemplate</string> + </object> + <string key="NSAlternateContents"/> + <string key="NSKeyEquivalent"/> + <int key="NSPeriodicDelay">400</int> + <int key="NSPeriodicInterval">75</int> + </object> + </object> + <object class="NSButton" id="742622660"> + <reference key="NSNextResponder" ref="612665518"/> + <int key="NSvFlags">289</int> + <string key="NSFrame">{{308, 6}, {22, 22}}</string> + <reference key="NSSuperview" ref="612665518"/> + <bool key="NSEnabled">YES</bool> + <object class="NSButtonCell" key="NSCell" id="768031501"> + <int key="NSCellFlags">67239424</int> + <int key="NSCellFlags2">134217728</int> + <string key="NSContents"/> + <reference key="NSSupport" ref="197084721"/> + <reference key="NSControlView" ref="742622660"/> + <int key="NSButtonFlags">-2033958657</int> + <int key="NSButtonFlags2">134</int> + <object class="NSCustomResource" key="NSNormalImage"> + <string key="NSClassName">NSImage</string> + <string key="NSResourceName">NSStopProgressTemplate</string> + </object> + <string key="NSAlternateContents"/> + <string type="base64-UTF8" key="NSKeyEquivalent">Gw</string> + <int key="NSPeriodicDelay">400</int> + <int key="NSPeriodicInterval">75</int> + </object> + </object> + </object> + <string key="NSFrameSize">{350, 34}</string> + <reference key="NSSuperview"/> + <string key="NSClassName">FindBarView</string> + </object> + </object> + <object class="IBObjectContainer" key="IBDocument.Objects"> + <object class="NSMutableArray" key="connectionRecords"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">view</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="612665518"/> + </object> + <int key="connectionID">13</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">findText_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="510660793"/> + </object> + <int key="connectionID">14</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">close:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="742622660"/> + </object> + <int key="connectionID">15</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">previousResult:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="455192438"/> + </object> + <int key="connectionID">16</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">nextResult:</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="968135285"/> + </object> + <int key="connectionID">17</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">delegate</string> + <reference key="source" ref="510660793"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">18</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">resultsLabel_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="445667"/> + </object> + <int key="connectionID">19</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">nextButton_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="968135285"/> + </object> + <int key="connectionID">20</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">previousButton_</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="455192438"/> + </object> + <int key="connectionID">21</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"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <reference key="children" ref="1000"/> + <nil key="parent"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-2</int> + <reference key="object" ref="1001"/> + <reference key="parent" ref="1002"/> + <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"/> + <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"/> + <string key="objectName">Application</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">2</int> + <reference key="object" ref="612665518"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="968135285"/> + <reference ref="455192438"/> + <reference ref="510660793"/> + <reference ref="742622660"/> + <reference ref="445667"/> + </object> + <reference key="parent" ref="1002"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">3</int> + <reference key="object" ref="968135285"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="9143312"/> + </object> + <reference key="parent" ref="612665518"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">4</int> + <reference key="object" ref="455192438"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="1064223545"/> + </object> + <reference key="parent" ref="612665518"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">5</int> + <reference key="object" ref="510660793"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="926027568"/> + </object> + <reference key="parent" ref="612665518"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">6</int> + <reference key="object" ref="445667"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="236923920"/> + </object> + <reference key="parent" ref="612665518"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">7</int> + <reference key="object" ref="742622660"/> + <object class="NSMutableArray" key="children"> + <bool key="EncodedWithXMLCoder">YES</bool> + <reference ref="768031501"/> + </object> + <reference key="parent" ref="612665518"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">8</int> + <reference key="object" ref="768031501"/> + <reference key="parent" ref="742622660"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">9</int> + <reference key="object" ref="236923920"/> + <reference key="parent" ref="445667"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">10</int> + <reference key="object" ref="926027568"/> + <reference key="parent" ref="510660793"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">11</int> + <reference key="object" ref="1064223545"/> + <reference key="parent" ref="455192438"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">12</int> + <reference key="object" ref="9143312"/> + <reference key="parent" ref="968135285"/> + </object> + </object> + </object> + <object class="NSMutableDictionary" key="flattenedProperties"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>-1.IBPluginDependency</string> + <string>-2.IBPluginDependency</string> + <string>-3.IBPluginDependency</string> + <string>10.IBPluginDependency</string> + <string>11.IBPluginDependency</string> + <string>12.IBPluginDependency</string> + <string>2.IBEditorWindowLastContentRect</string> + <string>2.IBPluginDependency</string> + <string>2.IBViewIntegration.shadowBlurRadius</string> + <string>2.IBViewIntegration.shadowColor</string> + <string>2.IBViewIntegration.shadowOffsetHeight</string> + <string>2.IBViewIntegration.shadowOffsetWidth</string> + <string>3.IBPluginDependency</string> + <string>4.IBPluginDependency</string> + <string>5.IBPluginDependency</string> + <string>6.IBPluginDependency</string> + <string>6.IBViewIntegration.shadowBlurRadius</string> + <string>6.IBViewIntegration.shadowColor</string> + <string>6.IBViewIntegration.shadowOffsetHeight</string> + <string>6.IBViewIntegration.shadowOffsetWidth</string> + <string>7.IBPluginDependency</string> + <string>8.IBPluginDependency</string> + <string>9.IBPluginDependency</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <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>{{481, 702}, {350, 34}}</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <real value="0.000000e+00" id="304884188"/> + <reference ref="817558590"/> + <reference ref="304884188"/> + <reference ref="304884188"/> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <real value="0.000000e+00"/> + <reference ref="817558590"/> + <real value="0.000000e+00"/> + <real value="0.000000e+00"/> + <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"> + <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> + <nil key="activeLocalization"/> + <object class="NSMutableDictionary" key="localizations"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> + </object> + <nil key="sourceID"/> + <int key="maxID">24</int> + </object> + <object class="IBClassDescriber" key="IBDocument.Classes"> + <object class="NSMutableArray" key="referencedPartialClassDescriptions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">FindBarCocoaController</string> + <string key="superclassName">NSViewController</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>close:</string> + <string>nextResult:</string> + <string>previousResult:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSMutableArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>findText_</string> + <string>nextButton_</string> + <string>previousButton_</string> + <string>resultsLabel_</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSTextField</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/find_bar_cocoa_controller.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">FindBarView</string> + <string key="superclassName">NSView</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/find_bar_view.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/tab_strip_model_observer_bridge.h</string> + </object> + </object> + </object> + </object> + <int key="IBDocument.localizationMode">0</int> + <string key="IBDocument.LastKnownRelativeProjectPath">../../../chrome.xcodeproj</string> + <int key="IBDocument.defaultPropertyAccessControl">3</int> + </data> +</archive> diff --git a/chrome/app/nibs/en.lproj/MainMenu.xib b/chrome/app/nibs/en.lproj/MainMenu.xib index 1cb6c61..c33dd7a 100644 --- a/chrome/app/nibs/en.lproj/MainMenu.xib +++ b/chrome/app/nibs/en.lproj/MainMenu.xib @@ -8,7 +8,7 @@ <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="533"/> + <integer value="220"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -501,7 +501,7 @@ <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="353210768"/> <reference key="NSMixedImage" ref="549394948"/> - <int key="NSTag">1</int> + <int key="NSTag">37000</int> </object> <object class="NSMenuItem" id="326711663"> <reference key="NSMenu" ref="963351320"/> @@ -511,7 +511,7 @@ <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="353210768"/> <reference key="NSMixedImage" ref="549394948"/> - <int key="NSTag">2</int> + <int key="NSTag">37001</int> </object> <object class="NSMenuItem" id="270902937"> <reference key="NSMenu" ref="963351320"/> @@ -521,7 +521,7 @@ <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="353210768"/> <reference key="NSMixedImage" ref="549394948"/> - <int key="NSTag">3</int> + <int key="NSTag">37002</int> </object> <object class="NSMenuItem" id="159080638"> <reference key="NSMenu" ref="963351320"/> @@ -867,7 +867,8 @@ <object class="NSMenuItem" id="399860348"> <reference key="NSMenu" ref="891828782"/> <string type="base64-UTF8" key="NSTitle">Qm9va21hcmsgQ3VycmVudCBQYWdl4oCmA</string> - <string key="NSKeyEquiv"/> + <string key="NSKeyEquiv">d</string> + <int key="NSKeyEquivModMask">1048576</int> <int key="NSMnemonicLoc">2147483647</int> <reference key="NSOnImage" ref="353210768"/> <reference key="NSMixedImage" ref="549394948"/> @@ -1174,14 +1175,6 @@ </object> <object class="IBConnectionRecord"> <object class="IBActionConnection" key="connection"> - <string key="label">performFindPanelAction:</string> - <reference key="source" ref="1014"/> - <reference key="destination" ref="447796847"/> - </object> - <int key="connectionID">241</int> - </object> - <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> <string key="label">centerSelectionInVisibleArea:</string> <reference key="source" ref="1014"/> <reference key="destination" ref="88285865"/> @@ -1372,6 +1365,30 @@ </object> <int key="connectionID">534</int> </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">commandDispatch:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="447796847"/> + </object> + <int key="connectionID">535</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">commandDispatch:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="326711663"/> + </object> + <int key="connectionID">536</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBActionConnection" key="connection"> + <string key="label">commandDispatch:</string> + <reference key="source" ref="1014"/> + <reference key="destination" ref="270902937"/> + </object> + <int key="connectionID">537</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -2458,7 +2475,7 @@ <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{264, 632}, {243, 263}}</string> + <string>{{264, 573}, {243, 263}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{197, 734}, {243, 243}}</string> @@ -2492,7 +2509,7 @@ <reference ref="9"/> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> - <string>{{492, 463}, {241, 103}}</string> + <string>{{507, 553}, {241, 103}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> <string>{{608, 612}, {241, 103}}</string> @@ -2514,7 +2531,7 @@ <string>{74, 862}</string> <string>{{11, 977}, {478, 20}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{306, 752}, {273, 143}}</string> + <string>{{308, 693}, {273, 143}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{475, 832}, {234, 43}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -2558,7 +2575,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{425, 861}, {230, 33}}</string> + <string>{{425, 803}, {254, 33}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <reference ref="9"/> @@ -2569,7 +2586,7 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{358, 801}, {188, 93}}</string> + <string>{{358, 743}, {188, 93}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> @@ -2631,7 +2648,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">534</int> + <int key="maxID">537</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 99f1d3f..0a2ebad 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -284,11 +284,9 @@ void Browser::CreateBrowserWindow() { window_->GetLocationBar()->ShowFirstRunBubble(); } -#if defined(OS_WIN) || defined(OS_LINUX) FindBar* find_bar = BrowserWindow::CreateFindBar(this); find_bar_controller_.reset(new FindBarController(find_bar)); find_bar->SetFindBarController(find_bar_controller_.get()); -#endif } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/browser_window_factory.mm b/chrome/browser/browser_window_factory.mm index 33d0070..bead83b 100644 --- a/chrome/browser/browser_window_factory.mm +++ b/chrome/browser/browser_window_factory.mm @@ -3,8 +3,11 @@ // found in the LICENSE file. #include "base/logging.h" +#include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" +#include "chrome/browser/cocoa/browser_window_cocoa.h" #include "chrome/browser/cocoa/browser_window_controller.h" +#include "chrome/browser/cocoa/find_bar_bridge.h" // Create the controller for the Browser, which handles loading the browser // window from the nib. The controller takes ownership of |browser|. @@ -20,7 +23,6 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { } // static -FindBar* BrowserWindow::CreateFindBar(Browser* browser_window) { - NOTIMPLEMENTED(); - return NULL; +FindBar* BrowserWindow::CreateFindBar(Browser* browser) { + return new FindBarBridge(static_cast<BrowserWindowCocoa*>(browser->window())); } diff --git a/chrome/browser/cocoa/bookmark_bar_controller.h b/chrome/browser/cocoa/bookmark_bar_controller.h index eec8a60..fde6482 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.h +++ b/chrome/browser/cocoa/bookmark_bar_controller.h @@ -35,6 +35,9 @@ class Profile; - (id)initWithProfile:(Profile*)profile contentArea:(NSView*)content; +// Resizes the bookmark bar based on the state of the content area. +- (void)resizeBookmarkBar; + // Returns whether or not the bookmark bar is visible. - (BOOL)isBookmarkBarVisible; diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm index 55ff71d..95195c8 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller.mm @@ -39,20 +39,27 @@ // view's visibility to match the pref. This doesn't move the content view at // all, you need to call |-showBookmarkBar:| to do that. - (void)positionBar { - NSRect contentFrame = [contentArea_ frame]; - NSRect barFrame = [bookmarkView_ frame]; - // Hide or show bar based on initial visibility and set the resize flags. [bookmarkView_ setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; [bookmarkView_ setHidden:[self isBookmarkBarVisible] ? NO : YES]; - // Position the bar at the top of the content area, within the window's - // content view (as opposed to the tab strip, which is a sibling). We'll - // slide the content area down when we need to show this strip. - contentFrame.size.height -= barFrame.size.height; - barFrame.origin.y = NSMaxY(contentFrame); - barFrame.origin.x = 0; - barFrame.size.width = contentFrame.size.width; + // Set the bar's height to zero and position it at the top of the + // content area, within the window's content view (as opposed to the + // tab strip, which is a sibling). We'll enlarge it and slide the + // content area down when we need to show this strip. + NSRect contentFrame = [contentArea_ frame]; + NSRect barFrame = NSMakeRect(0, NSMaxY(contentFrame), + contentFrame.size.width, 0); + [bookmarkView_ setFrame:barFrame]; +} + +// Called when the contentArea's frame changes. Enlarge the view to +// stay with the top of the contentArea. +- (void)resizeBookmarkBar { + NSRect barFrame = [bookmarkView_ frame]; + const int maxY = NSMaxY(barFrame); + barFrame.origin.y = NSMaxY([contentArea_ frame]); + barFrame.size.height = maxY - barFrame.origin.y; [bookmarkView_ setFrame:barFrame]; } @@ -85,16 +92,14 @@ return; } - int offset = [bookmarkView_ frame].size.height; + static const int kBookmarkBarHeight = 30; NSRect frame = [contentArea_ frame]; if (apply) - frame.size.height -= offset; + frame.size.height -= kBookmarkBarHeight; else - frame.size.height += offset; + frame.size.height += kBookmarkBarHeight; - // TODO(jrg): animate [[contentArea_ animator] setFrame:frame]; - [bookmarkView_ setNeedsDisplay:YES]; [contentArea_ setNeedsDisplay:YES]; } diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 67a7cc6..355884f 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -10,6 +10,7 @@ class Browser; @class BrowserWindowController; +@class FindBarCocoaController; @class NSWindow; @class NSMenu; @@ -51,7 +52,6 @@ class BrowserWindowCocoa : public BrowserWindow { virtual bool IsBookmarkBarVisible() const; virtual gfx::Rect GetRootWindowResizerRect() const; virtual void ToggleBookmarkBar(); - virtual void ShowFindBar(); virtual void ShowAboutChromeDialog(); virtual void ShowBookmarkManager(); virtual void ShowBookmarkBubble(const GURL& url, bool already_bookmarked); @@ -66,6 +66,9 @@ class BrowserWindowCocoa : public BrowserWindow { virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, void* parent_window); + // Adds the given FindBar cocoa controller to this browser window. + void AddFindBar(FindBarCocoaController* find_bar_cocoa_controller); + protected: virtual void DestroyBrowser(); diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index b0023ac..1ad2e9b 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -147,8 +147,9 @@ void BrowserWindowCocoa::ToggleBookmarkBar() { [controller_ toggleBookmarkBar]; } -void BrowserWindowCocoa::ShowFindBar() { - NOTIMPLEMENTED(); +void BrowserWindowCocoa::AddFindBar( + FindBarCocoaController* find_bar_cocoa_controller) { + return [controller_ addFindBar:find_bar_cocoa_controller]; } void BrowserWindowCocoa::ShowAboutChromeDialog() { diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index 8bc7222..337570a 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -20,6 +20,7 @@ class Browser; class BrowserWindow; class BrowserWindowCocoa; +@class FindBarCocoaController; class LocationBar; class StatusBubble; class TabContents; @@ -47,6 +48,7 @@ class TabStripModelObserverBridge; scoped_nsobject<ToolbarController> toolbarController_; scoped_nsobject<BookmarkBarController> bookmarkController_; scoped_nsobject<TabStripController> tabStripController_; + scoped_nsobject<FindBarCocoaController> findBarCocoaController_; scoped_ptr<StatusBubble> statusBubble_; } @@ -94,6 +96,11 @@ class TabStripModelObserverBridge; - (void)toggleBookmarkBar; +// Retains the given FindBarCocoaController and adds its view to this +// browser window. Must only be called once per +// BrowserWindowController. +- (void)addFindBar:(FindBarCocoaController*)findBarCocoaController; + @end #endif // CHROME_BROWSER_COCOA_BROWSER_WINDOW_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index cad9089..03fb697 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -11,6 +11,8 @@ #import "chrome/browser/cocoa/bookmark_bar_controller.h" #import "chrome/browser/cocoa/browser_window_cocoa.h" #import "chrome/browser/cocoa/browser_window_controller.h" +#import "chrome/browser/cocoa/find_bar_cocoa_controller.h" +#include "chrome/browser/cocoa/find_bar_bridge.h" #import "chrome/browser/cocoa/status_bubble_mac.h" #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" #import "chrome/browser/cocoa/tab_strip_view.h" @@ -36,6 +38,10 @@ const int kWindowGradientHeight = 24; // heuristic. - (void)fixWindowGradient; +// Called by the Notification Center whenever the tabContentArea's +// frame changes. Re-positions the bookmark bar and the find bar. +- (void)tabContentAreaFrameChanged:(id)sender; + // We need to adjust where sheets come out of the window, as by default they // erupt from the omnibox, which is rather weird. - (NSRect)window:(NSWindow *)window @@ -63,6 +69,14 @@ willPositionSheet:(NSWindow *)sheet // Retain it per the comment in the header. window_.reset([[self window] retain]); + // Register ourselves for frame changed notifications from the + // tabContentArea. + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(tabContentAreaFrameChanged:) + name:nil + object:[self tabContentArea]]; + // Get the most appropriate size for the window. The window shim will handle // flipping the coordinates for us so we can use it to save some code. gfx::Rect windowRect = browser_->GetSavedWindowBounds(); @@ -326,6 +340,16 @@ willPositionSheet:(NSWindow *)sheet [bookmarkController_ toggleBookmarkBar]; } +- (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { + // Shouldn't call addFindBar twice. + DCHECK(!findBarCocoaController_.get()); + + // Create a controller for the findbar. + findBarCocoaController_.reset([findBarCocoaController retain]); + [[[self window] contentView] addSubview:[findBarCocoaController_ view]]; + [findBarCocoaController_ positionFindBarView:[self tabContentArea]]; +} + - (NSInteger)numberOfTabs { return browser_->tabstrip_model()->count(); } @@ -416,6 +440,16 @@ willPositionSheet:(NSWindow *)sheet } } +- (void)tabContentAreaFrameChanged:(id)sender { + // TODO(rohitrao): This is triggered by window resizes also. Make + // sure we aren't doing anything wasteful in those cases. + [bookmarkController_ resizeBookmarkBar]; + + if (findBarCocoaController_.get()) { + [findBarCocoaController_ positionFindBarView:[self tabContentArea]]; + } +} + - (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)defaultSheetRect { diff --git a/chrome/browser/cocoa/find_bar_bridge.h b/chrome/browser/cocoa/find_bar_bridge.h new file mode 100644 index 0000000..b01b849 --- /dev/null +++ b/chrome/browser/cocoa/find_bar_bridge.h @@ -0,0 +1,80 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_COCOA_FIND_BAR_BRIDGE_H_ +#define CHROME_BROWSER_COCOA_FIND_BAR_BRIDGE_H_ + +#import <Cocoa/Cocoa.h> + +#import "base/logging.h" +#import "base/scoped_nsobject.h" +#import "chrome/browser/find_bar.h" + +class BrowserWindowCocoa; +class FindBarController; +@class FindBarCocoaController; + +// Implementation of FindBar for the Mac. This class simply passes +// each message along to |cocoa_controller_|. +// +// The initialization here is a bit complicated. FindBarBridge is +// created by a static method in BrowserWindow. The FindBarBridge +// constructor creates a FindBarCocoaController, which in turn loads a +// FindBarView from a nib file. All of this is happening outside of +// the main view hierarchy, so FindBarCocoaController calls +// BrowserWindowCocoa::AddFindBar() in order to add its FindBarView to +// the cocoa views hierarchy. +// +// Memory ownership is relatively straightfoward. The FindBarBridge +// object is owned by the Browser. FindBarCocoaController is retained +// by bother FindBarBridge and BrowserWindowController, since both use it. + +class FindBarBridge : public FindBar { + public: + // Constructs a new bridge object and adds its cocoa controller to |window|. + FindBarBridge(BrowserWindowCocoa* window); + virtual ~FindBarBridge(); + + virtual void SetFindBarController(FindBarController* find_bar_controller) { + find_bar_controller_ = find_bar_controller; + } + + virtual FindBarController* GetFindBarController() const { + DCHECK(find_bar_controller_); + return find_bar_controller_; + } + + virtual FindBarTesting* GetFindBarTesting() { + NOTIMPLEMENTED(); + return NULL; + } + + // Methods from FindBar. + virtual void Show(); + virtual void Hide(bool animate); + virtual void SetFocusAndSelection(); + virtual void ClearResults(const FindNotificationDetails& results); + virtual void StopAnimation(); + virtual void SetFindText(const string16& find_text); + virtual void UpdateUIForFindResult(const FindNotificationDetails& result, + const string16& find_text); + virtual gfx::Rect GetDialogPosition(gfx::Rect avoid_overlapping_rect); + virtual void SetDialogPosition(const gfx::Rect& new_pos, bool no_redraw); + virtual bool IsFindBarVisible(); + virtual void RestoreSavedFocus(); + virtual void MoveWindowIfNecessary(const gfx::Rect& selection_rect, + bool no_redraw); + + private: + // Pointer to the cocoa controller which manages the cocoa view. Is + // never null. + scoped_nsobject<FindBarCocoaController> cocoa_controller_; + + // Pointer back to the owning controller. + FindBarController* find_bar_controller_; // weak, owns us + + DISALLOW_COPY_AND_ASSIGN(FindBarBridge); +}; + +#endif // CHROME_BROWSER_COCOA_FIND_BAR_BRIDGE_H_ diff --git a/chrome/browser/cocoa/find_bar_bridge.mm b/chrome/browser/cocoa/find_bar_bridge.mm new file mode 100644 index 0000000..415273b --- /dev/null +++ b/chrome/browser/cocoa/find_bar_bridge.mm @@ -0,0 +1,69 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "chrome/browser/cocoa/find_bar_bridge.h" +#import "chrome/browser/cocoa/find_bar_cocoa_controller.h" + +FindBarBridge::FindBarBridge(BrowserWindowCocoa* window) { + cocoa_controller_.reset( + [[FindBarCocoaController alloc] initWithBrowserWindow:window]); + [cocoa_controller_ setFindBarBridge:this]; +} + +FindBarBridge::~FindBarBridge() { +} + +void FindBarBridge::Show() { + [cocoa_controller_ showFindBar]; +} + +void FindBarBridge::Hide(bool animate) { + [cocoa_controller_ hideFindBar]; +} + +void FindBarBridge::SetFocusAndSelection() { + [cocoa_controller_ setFocusAndSelection]; +} + +void FindBarBridge::ClearResults(const FindNotificationDetails& results) { + [cocoa_controller_ clearResults:results]; +} + +void FindBarBridge::SetFindText(const string16& find_text) { + [cocoa_controller_ setFindText:find_text]; +} + +void FindBarBridge::UpdateUIForFindResult(const FindNotificationDetails& result, + const string16& find_text) { + [cocoa_controller_ updateUIForFindResult:result withText:find_text]; +} + +bool FindBarBridge::IsFindBarVisible() { + return [cocoa_controller_ isFindBarVisible] ? true : false; +} + +void FindBarBridge::MoveWindowIfNecessary(const gfx::Rect& selection_rect, + bool no_redraw) { + NOTIMPLEMENTED(); +} + +void FindBarBridge::StopAnimation() { + NOTIMPLEMENTED(); +} + +gfx::Rect FindBarBridge::GetDialogPosition(gfx::Rect avoid_overlapping_rect) { + NOTIMPLEMENTED(); + return gfx::Rect(); +} + +void FindBarBridge::SetDialogPosition(const gfx::Rect& new_pos, + bool no_redraw) { + // TODO(rohitrao): Do something useful here. For now, just show the findbar. + NOTIMPLEMENTED(); + Show(); +} + +void FindBarBridge::RestoreSavedFocus() { + NOTIMPLEMENTED(); +} diff --git a/chrome/browser/cocoa/find_bar_cocoa_controller.h b/chrome/browser/cocoa/find_bar_cocoa_controller.h new file mode 100644 index 0000000..eb3e5a8 --- /dev/null +++ b/chrome/browser/cocoa/find_bar_cocoa_controller.h @@ -0,0 +1,57 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <Cocoa/Cocoa.h> + +#import "chrome/browser/cocoa/find_bar_cocoa_controller.h" + +#include "base/string16.h" + +class BrowserWindowCocoa; +class FindBarBridge; +class FindNotificationDetails; + +// A controller for the find bar in the browser window. Manages +// updating the state of the find bar and provides a target for the +// next/previous/close buttons. Certain operations require a pointer +// to the cross-platform FindBarController, so be sure to call +// setFindBarBridge: after creating this controller. + +@interface FindBarCocoaController : NSViewController { + @private + IBOutlet NSTextField* findText_; + IBOutlet NSTextField* resultsLabel_; + IBOutlet NSButton* nextButton_; + IBOutlet NSButton* previousButton_; + + // Needed to call methods on FindBarController. + FindBarBridge* findBarBridge_; // weak +}; + +// Initializes a new FindBarCocoaController and add itself to |window|. +- (id)initWithBrowserWindow:(BrowserWindowCocoa*)window; + +- (void)setFindBarBridge:(FindBarBridge*)findBar; + +- (IBAction)close:(id)sender; + +- (IBAction)nextResult:(id)sender; + +- (IBAction)previousResult:(id)sender; + +// Positions the find bar based on the location of |contentArea|. +- (void)positionFindBarView:(NSView*)contentArea; + +// Methods called from FindBarBridge. +- (void)showFindBar; +- (void)hideFindBar; +- (void)setFocusAndSelection; +- (void)setFindText:(const string16&)findText; + +- (void)clearResults:(const FindNotificationDetails&)results; +- (void)updateUIForFindResult:(const FindNotificationDetails&)results + withText:(const string16&)findText; +- (BOOL)isFindBarVisible; + +@end diff --git a/chrome/browser/cocoa/find_bar_cocoa_controller.mm b/chrome/browser/cocoa/find_bar_cocoa_controller.mm new file mode 100644 index 0000000..dbd66fb --- /dev/null +++ b/chrome/browser/cocoa/find_bar_cocoa_controller.mm @@ -0,0 +1,163 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <Cocoa/Cocoa.h> + +#include "base/mac_util.h" +#include "base/sys_string_conversions.h" +#include "grit/generated_resources.h" +#include "chrome/browser/find_bar_controller.h" +#include "chrome/browser/cocoa/browser_window_cocoa.h" +#import "chrome/browser/cocoa/find_bar_cocoa_controller.h" +#import "chrome/browser/cocoa/find_bar_bridge.h" +#import "chrome/browser/cocoa/tab_strip_controller.h" +#include "chrome/browser/tab_contents/web_contents.h" +#include "chrome/common/l10n_util.h" + +@implementation FindBarCocoaController + +- (id)initWithBrowserWindow:(BrowserWindowCocoa*)window { + if ((self = [super initWithNibName:@"FindBar" + bundle:mac_util::MainAppBundle()])) { + window->AddFindBar(self); + } + return self; +} + +- (void)setFindBarBridge:(FindBarBridge*)findBarBridge { + DCHECK(!findBarBridge_); // should only be called once. + findBarBridge_ = findBarBridge; +} + +- (void)awakeFromNib { + [[self view] setHidden:YES]; +} + +- (IBAction)close:(id)sender { + if (findBarBridge_) + findBarBridge_->GetFindBarController()->EndFindSession(); +} + +- (IBAction)previousResult:(id)sender { + if (findBarBridge_) + findBarBridge_->GetFindBarController()->web_contents()->StartFinding( + base::SysNSStringToUTF16([findText_ stringValue]), + false); +} + +- (IBAction)nextResult:(id)sender { + if (findBarBridge_) + findBarBridge_->GetFindBarController()->web_contents()->StartFinding( + base::SysNSStringToUTF16([findText_ stringValue]), + true); +} + +// Positions the find bar view in the correct location based on the +// current state of the window. Currently only the visibility of the +// bookmark bar can affect the find bar's position. +- (void)positionFindBarView:(NSView*)contentArea { + static const int kRightEdgeOffset = 25; + NSView* findBarView = [self view]; + int findBarHeight = NSHeight([findBarView frame]); + int findBarWidth = NSWidth([findBarView frame]); + + // Start by computing the upper right corner of the tab content + // area, then move left by a constant offset and up one pixel. This + // gives us the upper right corner of our bounding box. We move up + // one pixel to overlap with the toolbar area, which allows us to + // cover up the toolbar's border. + NSRect windowRect = [contentArea frame]; + int max_x = NSMaxX(windowRect) - kRightEdgeOffset; + int max_y = NSMaxY(windowRect) + 1; + + NSRect findRect = NSMakeRect(max_x - findBarWidth, max_y - findBarHeight, + findBarWidth, findBarHeight); + [findBarView setFrame:findRect]; +} + +// NSControl delegate method. +- (void)controlTextDidChange:(NSNotification *)aNotification { + if (!findBarBridge_) + return; + + WebContents* web_contents = + findBarBridge_->GetFindBarController()->web_contents(); + if (!web_contents) + return; + + string16 findText = base::SysNSStringToUTF16([findText_ stringValue]); + if (findText.length() > 0) { + web_contents->StartFinding(findText, true); + } else { + // The textbox is empty so we reset. + web_contents->StopFinding(true); // true = clear selection on page. + [self updateUIForFindResult:web_contents->find_result() + withText:string16()]; + } +} + +// Methods from FindBar +- (void)showFindBar { + [[self view] setHidden:NO]; +} + +- (void)hideFindBar { + [[self view] setHidden:YES]; +} + +- (void)setFocusAndSelection { + [[findText_ window] makeFirstResponder:findText_]; +} + +- (void)setFindText:(const string16&)findText { + [findText_ setStringValue:base::SysUTF16ToNSString(findText)]; +} + +- (void)clearResults:(const FindNotificationDetails&)results { + [findText_ setStringValue:@""]; +} + +- (void)updateUIForFindResult:(const FindNotificationDetails&)result + withText:(const string16&)findText { + // If we don't have any results and something was passed in, then + // that means someone pressed Cmd-G while the Find box was + // closed. In that case we need to repopulate the Find box with what + // was passed in. + if ([[findText_ stringValue] length] == 0 && !findText.empty()) { + [findText_ setStringValue:base::SysUTF16ToNSString(findText)]; + [findText_ selectText:self]; + } + + // Make sure Find Next and Find Previous are enabled if we found any matches. + BOOL buttonsEnabled = result.number_of_matches() > 0 ? YES : NO; + [previousButton_ setEnabled:buttonsEnabled]; + [nextButton_ setEnabled:buttonsEnabled]; + + // Update the results label. + // TODO(rohitrao): The part of the webkit glue that computes match + // ordinals is wrapped in OS_WIN. Figure out why and remove it, + // otherwise match counts won't work on Mac and Linux. + NSString* searchString = [findText_ stringValue]; + if ([searchString length] > 0) { + // TODO(rohitrao): Implement similar logic as in FindBarWin, to + // avoid flickering when searching. For now, only update the + // results label if both our numbers are non-negative. + if (result.active_match_ordinal() >= 0 && result.number_of_matches() >= 0) { + [resultsLabel_ setStringValue:base::SysWideToNSString( + l10n_util::GetStringF(IDS_FIND_IN_PAGE_COUNT, + IntToWString(result.active_match_ordinal()), + IntToWString(result.number_of_matches())))]; + } + } else { + // If there was no text entered, we don't show anything in the result count + // area. + [resultsLabel_ setStringValue:@""]; + } +} + +- (BOOL)isFindBarVisible { + return [[self view] isHidden] ? NO : YES; +} + +@end diff --git a/chrome/browser/cocoa/find_bar_view.h b/chrome/browser/cocoa/find_bar_view.h new file mode 100644 index 0000000..919f517 --- /dev/null +++ b/chrome/browser/cocoa/find_bar_view.h @@ -0,0 +1,16 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_COCOA_FIND_BAR_VIEW_H_ +#define CHROME_BROWSER_COCOA_FIND_BAR_VIEW_H_ + +#import <Cocoa/Cocoa.h> + +// A view that handles painting the border for the FindBar. + +@interface FindBarView : NSView { +} +@end + +#endif // CHROME_BROWSER_COCOA_FIND_BAR_VIEW_H_ diff --git a/chrome/browser/cocoa/find_bar_view.mm b/chrome/browser/cocoa/find_bar_view.mm new file mode 100644 index 0000000..3cbee2d --- /dev/null +++ b/chrome/browser/cocoa/find_bar_view.mm @@ -0,0 +1,36 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/cocoa/find_bar_view.h" + +@implementation FindBarView + +- (void)drawRect:(NSRect)rect { + // TODO(rohitrao): Make this prettier. + rect = [self bounds]; + NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect)); + NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect)); + // Inset the bottom points by 1 so we draw the border entirely + // inside the frame. + NSPoint bottomLeft = NSMakePoint(NSMinX(rect) + 15, NSMinY(rect) + 1); + NSPoint bottomRight = NSMakePoint(NSMaxX(rect) - 15, NSMinY(rect) + 1); + + NSBezierPath *path = [NSBezierPath bezierPath]; + [path moveToPoint:topLeft]; + [path curveToPoint:bottomLeft + controlPoint1:NSMakePoint(topLeft.x + 15, topLeft.y) + controlPoint2:NSMakePoint(bottomLeft.x - 15, bottomLeft.y)]; + [path lineToPoint:bottomRight]; + [path curveToPoint:topRight + controlPoint1:NSMakePoint(bottomRight.x + 15, bottomRight.y) + controlPoint2:NSMakePoint(topRight.x - 15, topRight.y)]; + + [[NSColor colorWithCalibratedWhite:0.90 alpha:1.0] set]; + [path fill]; + + [[NSColor colorWithCalibratedWhite:0.0 alpha:0.3] set]; + [path stroke]; +} + +@end diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index e883bfb..746f99d 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -534,6 +534,12 @@ 'browser/cocoa/cocoa_test_helper.h', 'browser/cocoa/command_observer_bridge.h', 'browser/cocoa/command_observer_bridge.mm', + 'browser/cocoa/find_bar_bridge.h', + 'browser/cocoa/find_bar_bridge.mm', + 'browser/cocoa/find_bar_cocoa_controller.h', + 'browser/cocoa/find_bar_cocoa_controller.mm', + 'browser/cocoa/find_bar_view.h', + 'browser/cocoa/find_bar_view.mm', 'browser/cocoa/grow_box_view.h', 'browser/cocoa/grow_box_view.m', 'browser/cocoa/location_bar_view_mac.h', @@ -1580,6 +1586,7 @@ ], 'mac_bundle_resources': [ 'app/nibs/en.lproj/BrowserWindow.xib', + 'app/nibs/en.lproj/FindBar.xib', 'app/nibs/en.lproj/MainMenu.xib', 'app/nibs/en.lproj/SaveAccessoryView.xib', 'app/nibs/en.lproj/TabContents.xib', |