summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 22:31:24 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 22:31:24 +0000
commitcf5889eddcb85c35e539835f137c710763f37b08 (patch)
tree763367cab82744afe511222c52657ae1863158d2
parent25af92056d8145d044674e3544010e9500b78ea3 (diff)
downloadchromium_src-cf5889eddcb85c35e539835f137c710763f37b08.zip
chromium_src-cf5889eddcb85c35e539835f137c710763f37b08.tar.gz
chromium_src-cf5889eddcb85c35e539835f137c710763f37b08.tar.bz2
[Mac] Enables drag N' drop for the buttons within the Browser Actions container. Also fixes an issue where the grippy was being shown when no Browser Actions were installed.
Known issue: You can drag the buttons outside of the container, even though they will recover by snapping back into place. This will be fixed in a further revision. TEST=try dragging browser action buttons in order to reorder them. BUG=26990 Review URL: http://codereview.chromium.org/1418003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42845 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/nibs/Toolbar.xib764
-rw-r--r--chrome/browser/cocoa/extensions/browser_action_button.h20
-rw-r--r--chrome/browser/cocoa/extensions/browser_action_button.mm115
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_controller.mm104
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm24
5 files changed, 960 insertions, 67 deletions
diff --git a/chrome/app/nibs/Toolbar.xib b/chrome/app/nibs/Toolbar.xib
index 1170d54..2525a8c 100644
--- a/chrome/app/nibs/Toolbar.xib
+++ b/chrome/app/nibs/Toolbar.xib
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <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>
+ <string key="IBDocument.SystemVersion">10C540</string>
+ <string key="IBDocument.InterfaceBuilderVersion">761</string>
+ <string key="IBDocument.AppKitVersion">1038.25</string>
+ <string key="IBDocument.HIToolboxVersion">458.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="NS.object.0">761</string>
+ </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="1"/>
@@ -16,7 +20,7 @@
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<object class="NSMutableArray" key="dict.values">
@@ -41,7 +45,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomView" id="421615633">
<reference key="NSNextResponder" ref="928520650"/>
- <int key="NSvFlags">265</int>
+ <int key="NSvFlags">-2147483383</int>
<string key="NSFrame">{{540, 0}, {0.777771, 36}}</string>
<reference key="NSSuperview" ref="928520650"/>
<string key="NSClassName">BrowserActionsContainerView</string>
@@ -59,7 +63,7 @@
<string key="NSContents">chromium.org</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
- <double key="NSSize">1.300000e+01</double>
+ <double key="NSSize">13</double>
<int key="NSfFlags">16</int>
</object>
<reference key="NSControlView" ref="535508469"/>
@@ -97,7 +101,7 @@
<string key="NSContents"/>
<object class="NSFont" key="NSSupport" id="64724822">
<string key="NSName">LucidaGrande</string>
- <double key="NSSize">1.300000e+01</double>
+ <double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="368496192"/>
@@ -125,8 +129,8 @@
<int key="NSCellFlags2">134250496</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="64724822"/>
- <int key="NSTag">-1</int>
<reference key="NSControlView" ref="559273956"/>
+ <int key="NSTag">-1</int>
<int key="NSButtonFlags">-2030812929</int>
<int key="NSButtonFlags2">6</int>
<object class="NSCustomResource" key="NSNormalImage">
@@ -180,8 +184,8 @@
<int key="NSCellFlags2">134250496</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="64724822"/>
- <int key="NSTag">1</int>
<reference key="NSControlView" ref="781044416"/>
+ <int key="NSTag">1</int>
<int key="NSButtonFlags">-2031861505</int>
<int key="NSButtonFlags2">6</int>
<object class="NSCustomResource" key="NSNormalImage">
@@ -206,8 +210,8 @@
<int key="NSCellFlags2">134250496</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="64724822"/>
- <int key="NSTag">-2</int>
<reference key="NSControlView" ref="634265909"/>
+ <int key="NSTag">-2</int>
<int key="NSButtonFlags">-2030812929</int>
<int key="NSButtonFlags2">6</int>
<object class="NSCustomResource" key="NSNormalImage">
@@ -232,8 +236,8 @@
<int key="NSCellFlags2">134250496</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="64724822"/>
- <int key="NSTag">1</int>
<reference key="NSControlView" ref="480525277"/>
+ <int key="NSTag">1</int>
<int key="NSButtonFlags">-2031861505</int>
<int key="NSButtonFlags2">6</int>
<object class="NSCustomResource" key="NSNormalImage">
@@ -469,28 +473,26 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
- <object class="NSArray" key="object" id="177301140">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
- <reference key="parent" ref="177301140"/>
- <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
- <reference key="parent" ref="177301140"/>
+ <reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
- <reference key="parent" ref="177301140"/>
+ <reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
@@ -509,7 +511,7 @@
<reference ref="571076484"/>
<reference ref="421615633"/>
</object>
- <reference key="parent" ref="177301140"/>
+ <reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">2</int>
@@ -640,12 +642,12 @@
<object class="IBObjectRecord">
<int key="objectID">122</int>
<reference key="object" ref="1044322163"/>
- <reference key="parent" ref="177301140"/>
+ <reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">130</int>
<reference key="object" ref="306232897"/>
- <reference key="parent" ref="177301140"/>
+ <reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">144</int>
@@ -657,7 +659,7 @@
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
@@ -750,9 +752,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
@@ -812,9 +812,7 @@
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
@@ -822,9 +820,7 @@
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
+ <reference key="dict.sortedKeys" ref="0"/>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
@@ -900,7 +896,7 @@
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>commandDispatch:</string>
<string>commandDispatchUsingKeyModifiers:</string>
@@ -921,7 +917,7 @@
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>otherObjectToLocalize_</string>
<string>owner_</string>
@@ -1010,7 +1006,7 @@
<string key="superclassName">NSViewController</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
+ <object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>backButton_</string>
<string>browserActionsContainerView_</string>
@@ -1061,9 +1057,705 @@
</object>
</object>
</object>
+ <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSActionCell</string>
+ <string key="superclassName">NSCell</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSApplication</string>
+ <string key="superclassName">NSResponder</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="680097003">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSApplication.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSApplication</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="214330444">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSApplicationScripting.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSApplication</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="568897720">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSColorPanel.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSApplication</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSHelpManager.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSApplication</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSPageLayout.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSButton</string>
+ <string key="superclassName">NSControl</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSButton.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSButtonCell</string>
+ <string key="superclassName">NSActionCell</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSCell</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSControl</string>
+ <string key="superclassName">NSView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="636973055">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSControl.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSController</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSFormatter</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSMenu</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="662735041">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSMenu.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AddressBook.framework/Headers/ABActions.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSAccessibility.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSAlert.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSAnimation.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <reference key="sourceIdentifier" ref="680097003"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <reference key="sourceIdentifier" ref="214330444"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSBrowser.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <reference key="sourceIdentifier" ref="568897720"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSComboBox.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSComboBoxCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <reference key="sourceIdentifier" ref="636973055"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSDatePickerCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSDictionaryController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSDragging.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSDrawer.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSFontPanel.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSImage.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSKeyValueBinding.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <reference key="sourceIdentifier" ref="662735041"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSNibLoading.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSOutlineView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSPasteboard.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSRuleEditor.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSSavePanel.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSSound.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSSpeechRecognizer.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSSpeechSynthesizer.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSSplitView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSTabView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSTableView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSText.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSTextStorage.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSTextView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSTokenField.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSTokenFieldCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSToolbar.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSToolbarItem.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier" id="1021231619">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSWindow.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSConnection.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSError.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSMetadata.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSNetServices.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSObject.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSPort.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSSpellServer.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSStream.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSThread.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSURL.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Foundation.framework/Headers/NSXMLParser.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">Print.framework/Headers/PDEPluginInterface.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">SecurityInterface.framework/Headers/SFAuthorizationView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">SecurityInterface.framework/Headers/SFCertificatePanel.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">SecurityInterface.framework/Headers/SFChooseIdentityPanel.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSResponder</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSInterfaceStyle.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSResponder</string>
+ <string key="superclassName">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSTextField</string>
+ <string key="superclassName">NSControl</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSTextField.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSTextFieldCell</string>
+ <string key="superclassName">NSActionCell</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSUserDefaultsController</string>
+ <string key="superclassName">NSController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSUserDefaultsController.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSClipView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSMenuItem.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSRulerView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSView</string>
+ <string key="superclassName">NSResponder</string>
+ <reference key="sourceIdentifier" ref="1021231619"/>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSViewController</string>
+ <string key="superclassName">NSResponder</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <string key="NS.key.0">view</string>
+ <string key="NS.object.0">NSView</string>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">AppKit.framework/Headers/NSViewController.h</string>
+ </object>
+ </object>
+ </object>
</object>
<int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+ <integer value="1050" key="NS.object.0"/>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
+ <integer value="1050" key="NS.object.0"/>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
+ <integer value="3000" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>back_Template</string>
+ <string>forward_Template</string>
+ <string>go_Template</string>
+ <string>home_Template</string>
+ <string>menu_chrome_Template</string>
+ <string>menu_page_Template</string>
+ <string>reload_Template</string>
+ <string>star_Template</string>
+ <string>starred</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>{19, 19}</string>
+ <string>{19, 19}</string>
+ <string>{19, 19}</string>
+ <string>{19, 19}</string>
+ <string>{30, 19}</string>
+ <string>{30, 19}</string>
+ <string>{19, 19}</string>
+ <string>{19, 19}</string>
+ <string>{30, 29}</string>
+ </object>
+ </object>
</data>
</archive>
diff --git a/chrome/browser/cocoa/extensions/browser_action_button.h b/chrome/browser/cocoa/extensions/browser_action_button.h
index caf03a1..bc2128d 100644
--- a/chrome/browser/cocoa/extensions/browser_action_button.h
+++ b/chrome/browser/cocoa/extensions/browser_action_button.h
@@ -20,6 +20,11 @@ class Profile;
// be updated.
extern const NSString* kBrowserActionButtonUpdatedNotification;
+// Fired on each drag event while the user is moving the button.
+extern const NSString* kBrowserActionButtonDraggingNotification;
+// Fired when the user drops the button.
+extern const NSString* kBrowserActionButtonDragEndNotification;
+
extern const CGFloat kBrowserActionWidth;
@interface BrowserActionButton : NSButton {
@@ -34,33 +39,44 @@ extern const CGFloat kBrowserActionWidth;
// The icon specific to the active tab.
scoped_nsobject<NSImage> tabSpecificIcon_;
+ // Used to move the button and query whether a button is currently animating.
+ scoped_nsobject<NSAnimation> moveAnimation_;
+
// The extension for this button. Weak.
Extension* extension_;
// The ID of the active tab.
int tabId_;
+
+ // Whether the button is currently being dragged.
+ BOOL isBeingDragged_;
}
- (id)initWithExtension:(Extension*)extension
profile:(Profile*)profile
tabId:(int)tabId;
+- (void)setFrame:(NSRect)frameRect animate:(BOOL)animate;
+
- (void)setDefaultIcon:(NSImage*)image;
- (void)setTabSpecificIcon:(NSImage*)image;
- (void)updateState;
+- (BOOL)isAnimating;
+
// Returns a pointer to an autoreleased NSImage with the badge, shadow and
// cell image drawn into it.
- (NSImage*)compositedImage;
-@property(readwrite, nonatomic) int tabId;
+@property(readonly, nonatomic) BOOL isBeingDragged;
@property(readonly, nonatomic) Extension* extension;
+@property(readwrite, nonatomic) int tabId;
@end
-@interface BrowserActionCell : ToolbarButtonCell {
+@interface BrowserActionCell : GradientButtonCell {
@private
// The current tab ID used when drawing the cell.
int tabId_;
diff --git a/chrome/browser/cocoa/extensions/browser_action_button.mm b/chrome/browser/cocoa/extensions/browser_action_button.mm
index d1f1681..fe456c6 100644
--- a/chrome/browser/cocoa/extensions/browser_action_button.mm
+++ b/chrome/browser/cocoa/extensions/browser_action_button.mm
@@ -4,6 +4,9 @@
#import "chrome/browser/cocoa/extensions/browser_action_button.h"
+#include <algorithm>
+#include <cmath>
+
#include "base/sys_string_conversions.h"
#include "chrome/browser/cocoa/extensions/extension_action_context_menu.h"
#include "chrome/browser/extensions/image_loading_tracker.h"
@@ -16,10 +19,16 @@
#include "gfx/rect.h"
#include "gfx/size.h"
#include "skia/ext/skia_utils_mac.h"
+#import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
extern const NSString* kBrowserActionButtonUpdatedNotification =
@"BrowserActionButtonUpdatedNotification";
+extern const NSString* kBrowserActionButtonDraggingNotification =
+ @"BrowserActionButtonDraggingNotification";
+extern const NSString* kBrowserActionButtonDragEndNotification =
+ @"BrowserActionButtonDragEndNotification";
+
static const CGFloat kBrowserActionBadgeOriginYOffset = 5;
// Since the container is the maximum height of the toolbar, we have to move the
@@ -32,6 +41,7 @@ static const CGFloat kBrowserActionHeight = 27;
extern const CGFloat kBrowserActionWidth = 29;
namespace {
+const CGFloat kAnimationDuration = 0.2;
const CGFloat kShadowOffset = 2.0;
} // anonymous namespace
@@ -93,8 +103,16 @@ class ExtensionImageTrackerBridge : public NotificationObserver,
- (void)drawBadgeWithinFrame:(NSRect)frame;
@end
+@interface BrowserActionButton(Private)
+- (void)endDrag;
+@end
+
@implementation BrowserActionButton
+@synthesize isBeingDragged = isBeingDragged_;
+@synthesize extension = extension_;
+@synthesize tabId = tabId_;
+
+ (Class)cellClass {
return [BrowserActionCell class];
}
@@ -128,12 +146,90 @@ class ExtensionImageTrackerBridge : public NotificationObserver,
extension_ = extension;
imageLoadingBridge_.reset(new ExtensionImageTrackerBridge(self, extension));
+ moveAnimation_.reset([[NSViewAnimation alloc] init]);
+ [moveAnimation_ gtm_setDuration:kAnimationDuration
+ eventMask:NSLeftMouseDownMask];
+ [moveAnimation_ setAnimationBlockingMode:NSAnimationNonblocking];
+
[self updateState];
}
return self;
}
+- (BOOL)acceptsFirstResponder {
+ return YES;
+}
+
+- (void)mouseDown:(NSEvent*)theEvent {
+ [[self cell] setHighlighted:YES];
+}
+
+- (void)mouseDragged:(NSEvent*)theEvent {
+ if (!isBeingDragged_) {
+ // The start of a drag. Position the button above all others.
+ [[self superview] addSubview:self positioned:NSWindowAbove relativeTo:nil];
+ }
+ isBeingDragged_ = YES;
+ NSPoint location = [self convertPoint:[theEvent locationInWindow]
+ fromView:nil];
+ NSRect buttonFrame = [self frame];
+ // TODO(andybons): Constrain the buttons to be within the container.
+ // Clamp the button to be within its superview along the X-axis.
+ buttonFrame.origin.x += [theEvent deltaX];
+ [self setFrame:buttonFrame];
+ [self setNeedsDisplay:YES];
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName:kBrowserActionButtonDraggingNotification
+ object:self];
+}
+
+- (void)mouseUp:(NSEvent*)theEvent {
+ // There are non-drag cases where a mouseUp: may happen
+ // (e.g. mouse-down, cmd-tab to another application, move mouse,
+ // mouse-up).
+ NSPoint location = [self convertPoint:[theEvent locationInWindow]
+ fromView:nil];
+ if (NSPointInRect(location, [self bounds]) && !isBeingDragged_) {
+ // Only perform the click if we didn't drag the button.
+ [self performClick:self];
+ } else {
+ // Make sure an ESC to end a drag doesn't trigger 2 endDrags.
+ if (isBeingDragged_) {
+ [self endDrag];
+ } else {
+ [super mouseUp:theEvent];
+ }
+ }
+}
+
+- (void)endDrag {
+ isBeingDragged_ = NO;
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName:kBrowserActionButtonDragEndNotification
+ object:self];
+ [[self cell] setHighlighted:NO];
+}
+
+- (void)setFrame:(NSRect)frameRect animate:(BOOL)animate {
+ if (!animate) {
+ [self setFrame:frameRect];
+ } else {
+ if ([moveAnimation_ isAnimating])
+ [moveAnimation_ stopAnimation];
+
+ NSDictionary* animationDictionary =
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ self, NSViewAnimationTargetKey,
+ [NSValue valueWithRect:[self frame]], NSViewAnimationStartFrameKey,
+ [NSValue valueWithRect:frameRect], NSViewAnimationEndFrameKey,
+ nil];
+ [moveAnimation_ setViewAnimations:
+ [NSArray arrayWithObject:animationDictionary]];
+ [moveAnimation_ startAnimation];
+ }
+}
+
- (void)setDefaultIcon:(NSImage*)image {
defaultIcon_.reset([image retain]);
}
@@ -170,12 +266,16 @@ class ExtensionImageTrackerBridge : public NotificationObserver,
object:self];
}
+- (BOOL)isAnimating {
+ return [moveAnimation_ isAnimating];
+}
+
- (NSImage*)compositedImage {
NSRect bounds = NSMakeRect(0, 0, kBrowserActionWidth, kBrowserActionHeight);
NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:NSWidth(bounds)
- pixelsHigh:NSWidth(bounds)
+ pixelsHigh:NSHeight(bounds)
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
@@ -197,8 +297,8 @@ class ExtensionImageTrackerBridge : public NotificationObserver,
// TODO(andybons): Figure out why |flipped| can be yes in certain cases.
// http://crbug.com/38943
[actionImage setFlipped:NO];
- CGFloat xPos = floor((NSWidth(bounds) - [actionImage size].width) / 2);
- CGFloat yPos = floor((NSHeight(bounds) - [actionImage size].height) / 2);
+ CGFloat xPos = std::floor((NSWidth(bounds) - [actionImage size].width) / 2);
+ CGFloat yPos = std::floor((NSHeight(bounds) - [actionImage size].height) / 2);
[actionImage drawAtPoint:NSMakePoint(xPos, yPos)
fromRect:NSZeroRect
operation:NSCompositeSourceOver
@@ -215,13 +315,13 @@ class ExtensionImageTrackerBridge : public NotificationObserver,
return compositeImage;
}
-@synthesize tabId = tabId_;
-@synthesize extension = extension_;
-
@end
@implementation BrowserActionCell
+@synthesize tabId = tabId_;
+@synthesize extensionAction = extensionAction_;
+
- (void)setIconShadow {
// Create the shadow below and to the right of the drawn image.
scoped_nsobject<NSShadow> imgShadow([[NSShadow alloc] init]);
@@ -248,7 +348,4 @@ class ExtensionImageTrackerBridge : public NotificationObserver,
[NSGraphicsContext restoreGraphicsState];
}
-@synthesize tabId = tabId_;
-@synthesize extensionAction = extensionAction_;
-
@end
diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/cocoa/extensions/browser_actions_controller.mm
index d0d5c93..49bb871 100644
--- a/chrome/browser/cocoa/extensions/browser_actions_controller.mm
+++ b/chrome/browser/cocoa/extensions/browser_actions_controller.mm
@@ -4,6 +4,7 @@
#import "browser_actions_controller.h"
+#include <cmath>
#include <string>
#include "app/resource_bundle.h"
@@ -47,29 +48,36 @@ const CGFloat kGrippyXOffset = 8.0;
// Used during initialization to create the BrowserActionButton objects from the
// stored toolbar model.
- (void)createButtons;
+
// Creates and then adds the given extension's action button to the container
// at the given index within the container. It does not affect the toolbar model
// object since it is called when the toolbar model changes.
- (void)createActionButtonForExtension:(Extension*)extension
withIndex:(NSUInteger)index;
+
// Removes an action button for the given extension from the container. This
// method also does not affect the underlying toolbar model since it is called
// when the toolbar model changes.
- (void)removeActionButtonForExtension:(Extension*)extension;
+
// Useful in the case of a Browser Action being added/removed from the middle of
// the container, this method repositions each button according to the current
// toolbar model.
-- (void)repositionActionButtons;
+- (void)repositionActionButtonsAndAnimate:(BOOL)animate;
+
// During container resizing, buttons become more transparent as they are pushed
// off the screen. This method updates each button's opacity determined by the
// position of the button.
- (void)updateButtonOpacity;
+
// Returns the existing button with the given extension backing it; nil if it
// cannot be found or the extension's ID is invalid.
- (BrowserActionButton*)buttonForExtension:(Extension*)extension;
+
// Returns the preferred width of the container given the number of visible
// buttons |buttonCount|.
- (CGFloat)containerWidthWithButtonCount:(NSUInteger)buttonCount;
+
// Returns the number of buttons that can fit in the container according to its
// current size.
- (NSUInteger)containerButtonCapacity;
@@ -78,21 +86,40 @@ const CGFloat kGrippyXOffset = 8.0;
// Updates each button's opacity, the cursor rects and chevron position.
- (void)containerFrameChanged:(NSNotification*)notification;
+
// Hides the chevron and unhides every hidden button so that dragging the
// container out smoothly shows the Browser Action buttons.
- (void)containerDragStart:(NSNotification*)notification;
+
// Sends a notification for the toolbar to reposition surrounding UI elements.
- (void)containerDragging:(NSNotification*)notification;
+
// Determines which buttons need to be hidden based on the new size, hides them
// and updates the chevron overflow menu. Also fires a notification to let the
// toolbar know that the drag has finished.
- (void)containerDragFinished:(NSNotification*)notification;
+
// Updates the image associated with the button should it be within the chevron
// menu.
- (void)actionButtonUpdated:(NSNotification*)notification;
+// Adjusts the position of the surrounding action buttons depending on where the
+// button is within the container.
+- (void)actionButtonDragging:(NSNotification*)notification;
+
+// Updates the underlying toolbar model and "snaps" the button into its proper
+// place within the button grid.
+- (void)actionButtonDragFinished:(NSNotification*)notification;
+
+// Moves the given button both visually and within the toolbar model to the
+// specified index.
+- (void)moveButton:(BrowserActionButton*)button
+ toIndex:(NSUInteger)index
+ animate:(BOOL)animate;
+
// Handles when the given BrowserActionButton object is clicked.
- (void)browserActionClicked:(BrowserActionButton*)button;
+
// Returns whether the given extension should be displayed. Only displays
// incognito-enabled extensions in incognito mode. Otherwise returns YES.
- (BOOL)shouldDisplayBrowserAction:(Extension*)extension;
@@ -105,17 +132,22 @@ const CGFloat kGrippyXOffset = 8.0;
// Shows the overflow chevron button depending on whether there are any hidden
// extensions within the frame given.
- (void)showChevronIfNecessaryInFrame:(NSRect)frame animate:(BOOL)animate;
+
// Moves the chevron to its correct position within |frame|.
- (void)updateChevronPositionInFrame:(NSRect)frame;
+
// Shows or hides the chevron, animating as specified by |animate|.
- (void)setChevronHidden:(BOOL)hidden
inFrame:(NSRect)frame
animate:(BOOL)animate;
+
// Handles when a menu item within the chevron overflow menu is selected.
- (void)chevronItemSelected:(id)menuItem;
+
// Clears and then populates the overflow menu based on the contents of
// |hiddenButtons_|.
- (void)updateOverflowMenu;
+
// Returns the ID of the currently selected tab or -1 if none exists.
- (int)currentTabId;
@end
@@ -424,7 +456,18 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
[self updateOverflowMenu];
}
- [self repositionActionButtons];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(actionButtonDragging:)
+ name:kBrowserActionButtonDraggingNotification
+ object:newButton];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(actionButtonDragFinished:)
+ name:kBrowserActionButtonDragEndNotification
+ object:newButton];
+
+ [self repositionActionButtonsAndAnimate:NO];
[containerView_ setMaxWidth:
[self containerWidthWithButtonCount:[self buttonCount]]];
[containerView_ setNeedsDisplay:YES];
@@ -455,28 +498,24 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
// No more buttons? Hide the container.
[containerView_ setHidden:YES];
} else {
- [self repositionActionButtons];
+ [self repositionActionButtonsAndAnimate:NO];
}
[containerView_ setMaxWidth:
[self containerWidthWithButtonCount:[self buttonCount]]];
[containerView_ setNeedsDisplay:YES];
}
-- (void)repositionActionButtons {
+- (void)repositionActionButtonsAndAnimate:(BOOL)animate {
NSUInteger i = 0;
for (ExtensionList::iterator iter = toolbarModel_->begin();
iter != toolbarModel_->end(); ++iter) {
if (![self shouldDisplayBrowserAction:*iter])
continue;
-
- CGFloat xOffset = kGrippyXOffset +
- (i * (kBrowserActionWidth + kBrowserActionButtonPadding));
BrowserActionButton* button = [self buttonForExtension:(*iter)];
if (!button)
continue;
- NSRect buttonFrame = [button frame];
- buttonFrame.origin.x = xOffset;
- [button setFrame:buttonFrame];
+ if (![button isBeingDragged])
+ [self moveButton:button toIndex:i animate:animate];
++i;
}
}
@@ -587,6 +626,49 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
[item setImage:[button compositedImage]];
}
+- (void)actionButtonDragging:(NSNotification*)notification {
+ if (![self chevronIsHidden])
+ [self setChevronHidden:YES inFrame:[containerView_ frame] animate:YES];
+
+ // Determine what index the dragged button should lie in, alter the model and
+ // reposition the buttons.
+ CGFloat dragThreshold = std::floor(kBrowserActionWidth / 2);
+ BrowserActionButton* draggedButton = [notification object];
+ NSRect draggedButtonFrame = [draggedButton frame];
+
+ NSUInteger index = 0;
+ for (ExtensionList::iterator iter = toolbarModel_->begin();
+ iter != toolbarModel_->end(); ++iter) {
+ BrowserActionButton* button = [self buttonForExtension:(*iter)];
+ CGFloat intersectionWidth =
+ NSWidth(NSIntersectionRect(draggedButtonFrame, [button frame]));
+
+ if (intersectionWidth > dragThreshold && button != draggedButton &&
+ ![button isAnimating]) {
+ toolbarModel_->MoveBrowserAction([draggedButton extension], index);
+ [self repositionActionButtonsAndAnimate:YES];
+ return;
+ }
+ ++index;
+ }
+}
+
+- (void)actionButtonDragFinished:(NSNotification*)notification {
+ [self showChevronIfNecessaryInFrame:[containerView_ frame] animate:YES];
+ DCHECK(![[notification object] isBeingDragged]);
+ [self repositionActionButtonsAndAnimate:YES];
+}
+
+- (void)moveButton:(BrowserActionButton*)button
+ toIndex:(NSUInteger)index
+ animate:(BOOL)animate {
+ CGFloat xOffset = kGrippyXOffset +
+ (index * (kBrowserActionWidth + kBrowserActionButtonPadding));
+ NSRect buttonFrame = [button frame];
+ buttonFrame.origin.x = xOffset;
+ [button setFrame:buttonFrame animate:animate];
+}
+
- (void)browserActionClicked:(BrowserActionButton*)button {
int tabId = [self currentTabId];
if (tabId < 0) {
@@ -669,7 +751,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver,
nil];
}
[chevronAnimation_ setViewAnimations:
- [NSArray arrayWithObjects:animationDictionary, nil]];
+ [NSArray arrayWithObject:animationDictionary]];
[chevronAnimation_ startAnimation];
}
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index dbb949c..68819f1 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -639,9 +639,10 @@ class PrefObserverBridge : public NotificationObserver {
name:NSWindowDidBecomeKeyNotification
object:[[self view] window]];
}
-
- CGFloat dX = NSWidth([browserActionsContainerView_ frame]) * -1;
- [self adjustLocationAndGoPositionsBy:dX animate:NO];
+ CGFloat containerWidth = [browserActionsContainerView_ isHidden] ? 0.0 :
+ NSWidth([browserActionsContainerView_ frame]);
+ if (containerWidth > 0.0)
+ [self adjustLocationAndGoPositionsBy:(containerWidth * -1) animate:NO];
BOOL rightBorderShown = !([pageButton_ isHidden] && [wrenchButton_ isHidden]);
[browserActionsContainerView_ setRightBorderShown:rightBorderShown];
}
@@ -674,13 +675,18 @@ class PrefObserverBridge : public NotificationObserver {
}
- (void)pinGoButtonToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate {
- NSRect goFrame = [goButton_ frame];
- NSRect containerFrame = animate ?
- [browserActionsContainerView_ animationEndFrame] :
- [browserActionsContainerView_ frame];
+ CGFloat goXPos = [goButton_ frame].origin.x + NSWidth([goButton_ frame]);
+ CGFloat leftPadding;
- CGFloat leftPadding = containerFrame.origin.x -
- (goFrame.origin.x + NSWidth(goFrame));
+ if ([browserActionsContainerView_ isHidden]) {
+ leftPadding = NSWidth([[goButton_ window] frame]) - goXPos;
+ } else {
+ NSRect containerFrame = animate ?
+ [browserActionsContainerView_ animationEndFrame] :
+ [browserActionsContainerView_ frame];
+
+ leftPadding = containerFrame.origin.x - goXPos;
+ }
if (leftPadding != kBrowserActionsContainerLeftPadding) {
CGFloat dX = leftPadding - kBrowserActionsContainerLeftPadding;
[self adjustLocationAndGoPositionsBy:dX animate:animate];