diff options
-rw-r--r-- | chrome/app/generated_resources.grd | 5 | ||||
-rw-r--r-- | chrome/app/nibs/AvatarMenuItem.xib | 452 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/base_bubble_controller.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/base_bubble_controller.mm | 9 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h | 18 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.mm | 121 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm | 90 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/page_info_bubble_controller.mm | 13 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 1 |
9 files changed, 458 insertions, 255 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 6e88528..daa0d5d 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -8648,7 +8648,10 @@ Keep your key file in a safe place. You will need it to create new versions of y </message> </if> <message name="IDS_PROFILES_CREATE_NEW_PROFILE_LINK" desc="Link in the avatar menu bubble view to create a new profile."> - Add new user + New user + </message> + <message name="IDS_PROFILES_EDIT_PROFILE_LINK" desc="Link in the avatar menu bubble to edit a profile."> + edit your profile </message> <message name="IDS_PROFILES_CUSTOMIZE_PROFILE_ACCESSIBLE_NAME" desc="Description of the customize profile button. This is used for accessibility."> Customize user: <ph name="PROFILE_NAME">$1<ex>First user</ex></ph> diff --git a/chrome/app/nibs/AvatarMenuItem.xib b/chrome/app/nibs/AvatarMenuItem.xib index f6b9422..cf71f71 100644 --- a/chrome/app/nibs/AvatarMenuItem.xib +++ b/chrome/app/nibs/AvatarMenuItem.xib @@ -3,12 +3,12 @@ <data> <int key="IBDocument.SystemTarget">1050</int> <string key="IBDocument.SystemVersion">10K549</string> - <string key="IBDocument.InterfaceBuilderVersion">804</string> + <string key="IBDocument.InterfaceBuilderVersion">851</string> <string key="IBDocument.AppKitVersion">1038.36</string> <string key="IBDocument.HIToolboxVersion">461.00</string> <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> - <string key="NS.object.0">804</string> + <string key="NS.object.0">851</string> </object> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -43,31 +43,57 @@ <int key="NSvFlags">290</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSButton" id="988307549"> + <object class="NSButton" id="520854825"> <reference key="NSNextResponder" ref="1005"/> - <int key="NSvFlags">266</int> - <string key="NSFrame">{{2, 2}, {145, 44}}</string> + <int key="NSvFlags">268</int> + <string key="NSFrame">{{49, 8}, {120, 16}}</string> <reference key="NSSuperview" ref="1005"/> <bool key="NSEnabled">YES</bool> - <object class="NSButtonCell" key="NSCell" id="531385668"> + <object class="NSButtonCell" key="NSCell" id="909176510"> <int key="NSCellFlags">67239424</int> - <int key="NSCellFlags2">134217728</int> - <string key="NSContents"/> - <object class="NSFont" key="NSSupport" id="569992860"> + <int key="NSCellFlags2">0</int> + <string key="NSContents">^IDS_PROFILES_EDIT_PROFILE_LINK</string> + <object class="NSFont" key="NSSupport" id="541332804"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">13</double> - <int key="NSfFlags">1044</int> + <double key="NSSize">12</double> + <int key="NSfFlags">16</int> </object> - <reference key="NSControlView" ref="988307549"/> - <int key="NSButtonFlags">-2046639873</int> - <int key="NSButtonFlags2">129</int> - <reference key="NSAlternateImage" ref="569992860"/> + <reference key="NSControlView" ref="520854825"/> + <int key="NSButtonFlags">-2046672641</int> + <int key="NSButtonFlags2">134</int> <string key="NSAlternateContents"/> <string key="NSKeyEquivalent"/> <int key="NSPeriodicDelay">200</int> <int key="NSPeriodicInterval">25</int> </object> </object> + <object class="NSTextField" id="441443194"> + <reference key="NSNextResponder" ref="1005"/> + <int key="NSvFlags">266</int> + <string key="NSFrame">{{49, 8}, {120, 16}}</string> + <reference key="NSSuperview" ref="1005"/> + <bool key="NSEnabled">YES</bool> + <object class="NSTextFieldCell" key="NSCell" id="309690559"> + <int key="NSCellFlags">67239488</int> + <int key="NSCellFlags2">272631808</int> + <string key="NSContents">email@example.com</string> + <reference key="NSSupport" ref="541332804"/> + <reference key="NSControlView" ref="441443194"/> + <object class="NSColor" key="NSBackgroundColor" id="814442900"> + <int key="NSColorSpace">6</int> + <string key="NSCatalogName">System</string> + <string key="NSColorName">controlColor</string> + <object class="NSColor" key="NSColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> + </object> + </object> + <object class="NSColor" key="NSTextColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC4xMgA</bytes> + </object> + </object> + </object> <object class="NSImageView" id="416344038"> <reference key="NSNextResponder" ref="1005"/> <int key="NSvFlags">268</int> @@ -100,63 +126,26 @@ </object> <bool key="NSEditable">YES</bool> </object> - <object class="NSButton" id="696236440"> - <reference key="NSNextResponder" ref="1005"/> - <int key="NSvFlags">265</int> - <string key="NSFrame">{{149, 15}, {18, 18}}</string> - <reference key="NSSuperview" ref="1005"/> - <bool key="NSEnabled">YES</bool> - <object class="NSButtonCell" key="NSCell" id="286615677"> - <int key="NSCellFlags">-2080244224</int> - <int key="NSCellFlags2">134217728</int> - <string key="NSContents"/> - <reference key="NSSupport" ref="569992860"/> - <reference key="NSControlView" ref="696236440"/> - <int key="NSButtonFlags">-2041822977</int> - <int key="NSButtonFlags2">98</int> - <object class="NSCustomResource" key="NSNormalImage"> - <string key="NSClassName">NSImage</string> - <string key="NSResourceName">NSInfo</string> - </object> - <string key="NSAlternateContents"/> - <string key="NSKeyEquivalent"/> - <int key="NSPeriodicDelay">400</int> - <int key="NSPeriodicInterval">75</int> - </object> - </object> <object class="NSTextField" id="436994758"> <reference key="NSNextResponder" ref="1005"/> <int key="NSvFlags">266</int> - <string key="NSFrame">{{49, 16}, {95, 16}}</string> + <string key="NSFrame">{{49, 25}, {120, 17}}</string> <reference key="NSSuperview" ref="1005"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="217181972"> <int key="NSCellFlags">67239488</int> <int key="NSCellFlags2">272631808</int> - <string key="NSContents">Label</string> + <string key="NSContents">Username</string> <object class="NSFont" key="NSSupport"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">12</double> + <double key="NSSize">13</double> <int key="NSfFlags">16</int> </object> <reference key="NSControlView" ref="436994758"/> - <object class="NSColor" key="NSBackgroundColor"> - <int key="NSColorSpace">6</int> - <string key="NSCatalogName">System</string> - <string key="NSColorName">controlColor</string> - <object class="NSColor" key="NSColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> - </object> - </object> + <reference key="NSBackgroundColor" ref="814442900"/> <object class="NSColor" key="NSTextColor"> - <int key="NSColorSpace">6</int> - <string key="NSCatalogName">System</string> - <string key="NSColorName">controlTextColor</string> - <object class="NSColor" key="NSColor"> - <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MAA</bytes> - </object> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC4xMgA</bytes> </object> </object> </object> @@ -195,7 +184,10 @@ </object> <string key="NSFrameSize">{175, 48}</string> <reference key="NSSuperview"/> - <string key="NSClassName">NSView</string> + <string key="NSClassName">AvatarMenuItemView</string> + </object> + <object class="NSCustomObject" id="711726002"> + <string key="NSClassName">ChromeUILocalizer</string> </object> </object> <object class="IBObjectContainer" key="IBDocument.Objects"> @@ -227,43 +219,51 @@ </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">editButton</string> + <string key="label">iconView</string> <reference key="source" ref="1001"/> - <reference key="destination" ref="696236440"/> + <reference key="destination" ref="772277894"/> </object> - <int key="connectionID">14</int> + <int key="connectionID">15</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">iconView</string> + <string key="label">viewController</string> + <reference key="source" ref="1005"/> + <reference key="destination" ref="1001"/> + </object> + <int key="connectionID">22</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">editButton</string> <reference key="source" ref="1001"/> - <reference key="destination" ref="772277894"/> + <reference key="destination" ref="520854825"/> </object> - <int key="connectionID">15</int> + <int key="connectionID">39</int> </object> <object class="IBConnectionRecord"> - <object class="IBActionConnection" key="connection"> - <string key="label">switchToProfile:</string> + <object class="IBOutletConnection" key="connection"> + <string key="label">emailField</string> <reference key="source" ref="1001"/> - <reference key="destination" ref="988307549"/> + <reference key="destination" ref="441443194"/> </object> - <int key="connectionID">18</int> + <int key="connectionID">40</int> </object> <object class="IBConnectionRecord"> <object class="IBActionConnection" key="connection"> <string key="label">editProfile:</string> <reference key="source" ref="1001"/> - <reference key="destination" ref="696236440"/> + <reference key="destination" ref="520854825"/> </object> - <int key="connectionID">19</int> + <int key="connectionID">41</int> </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> - <string key="label">viewController</string> - <reference key="source" ref="531385668"/> + <string key="label">owner_</string> + <reference key="source" ref="711726002"/> <reference key="destination" ref="1001"/> </object> - <int key="connectionID">21</int> + <int key="connectionID">48</int> </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> @@ -300,9 +300,9 @@ <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="772277894"/> <reference ref="436994758"/> - <reference ref="696236440"/> <reference ref="416344038"/> - <reference ref="988307549"/> + <reference ref="441443194"/> + <reference ref="520854825"/> </object> <reference key="parent" ref="0"/> </object> @@ -335,46 +335,51 @@ <reference key="parent" ref="436994758"/> </object> <object class="IBObjectRecord"> - <int key="objectID">6</int> - <reference key="object" ref="696236440"/> + <int key="objectID">8</int> + <reference key="object" ref="416344038"/> <object class="NSMutableArray" key="children"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="286615677"/> + <reference ref="857899611"/> </object> <reference key="parent" ref="1005"/> </object> <object class="IBObjectRecord"> - <int key="objectID">7</int> - <reference key="object" ref="286615677"/> - <reference key="parent" ref="696236440"/> + <int key="objectID">9</int> + <reference key="object" ref="857899611"/> + <reference key="parent" ref="416344038"/> </object> <object class="IBObjectRecord"> - <int key="objectID">8</int> - <reference key="object" ref="416344038"/> + <int key="objectID">23</int> + <reference key="object" ref="441443194"/> <object class="NSMutableArray" key="children"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="857899611"/> + <reference ref="309690559"/> </object> <reference key="parent" ref="1005"/> </object> <object class="IBObjectRecord"> - <int key="objectID">9</int> - <reference key="object" ref="857899611"/> - <reference key="parent" ref="416344038"/> + <int key="objectID">24</int> + <reference key="object" ref="309690559"/> + <reference key="parent" ref="441443194"/> </object> <object class="IBObjectRecord"> - <int key="objectID">16</int> - <reference key="object" ref="988307549"/> + <int key="objectID">25</int> + <reference key="object" ref="520854825"/> <object class="NSMutableArray" key="children"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference ref="531385668"/> + <reference ref="909176510"/> </object> <reference key="parent" ref="1005"/> </object> <object class="IBObjectRecord"> - <int key="objectID">17</int> - <reference key="object" ref="531385668"/> - <reference key="parent" ref="988307549"/> + <int key="objectID">26</int> + <reference key="object" ref="909176510"/> + <reference key="parent" ref="520854825"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">42</int> + <reference key="object" ref="711726002"/> + <reference key="parent" ref="0"/> </object> </object> </object> @@ -387,23 +392,23 @@ <string>-3.IBPluginDependency</string> <string>1.IBEditorWindowLastContentRect</string> <string>1.IBPluginDependency</string> + <string>1.IBViewBoundsToFrameTransform</string> <string>1.IBViewEditorWindowController.showingBoundsRectangles</string> <string>1.WindowOrigin</string> <string>1.editorWindowContentRectSynchronizationRect</string> - <string>16.IBPluginDependency</string> - <string>16.IBViewBoundsToFrameTransform</string> - <string>17.CustomClassName</string> - <string>17.IBPluginDependency</string> <string>2.IBPluginDependency</string> <string>2.IBViewBoundsToFrameTransform</string> + <string>23.IBPluginDependency</string> + <string>23.IBViewBoundsToFrameTransform</string> + <string>24.IBPluginDependency</string> + <string>25.IBPluginDependency</string> + <string>26.CustomClassName</string> + <string>26.IBPluginDependency</string> <string>3.IBPluginDependency</string> <string>4.IBPluginDependency</string> <string>4.IBViewBoundsToFrameTransform</string> + <string>42.IBPluginDependency</string> <string>5.IBPluginDependency</string> - <string>6.CustomClassName</string> - <string>6.IBPluginDependency</string> - <string>6.IBViewBoundsToFrameTransform</string> - <string>7.IBPluginDependency</string> <string>8.IBPluginDependency</string> <string>8.IBViewBoundsToFrameTransform</string> <string>9.IBPluginDependency</string> @@ -415,32 +420,30 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>{{596, 888}, {175, 48}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <object class="NSAffineTransform"/> <boolean value="YES"/> <string>{628, 654}</string> <string>{{357, 416}, {480, 272}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSAffineTransform"> - <bytes key="NSTransformStruct">P4AAAL+AAABAAAAAwjAAAA</bytes> + <bytes key="NSTransformStruct">AUJkAABAQAAAA</bytes> </object> - <string>SwitchProfileButtonCell</string> - <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSAffineTransform"> - <bytes key="NSTransformStruct">AUJkAABAQAAAA</bytes> + <bytes key="NSTransformStruct">P4AAAL+AAABCRAAAwiQAAA</bytes> </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <object class="NSAffineTransform"> - <bytes key="NSTransformStruct">P4AAAL+AAABCRAAAwfgAAA</bytes> - </object> + <string>HyperlinkButtonCell</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>HoverImageButton</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSAffineTransform"> - <bytes key="NSTransformStruct">P4AAAL+AAABDFQAAwdgAAA</bytes> + <bytes key="NSTransformStruct">P4AAAL+AAABCRAAAwiQAAA</bytes> </object> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> + <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <object class="NSAffineTransform"> <bytes key="NSTransformStruct">AUKiAABAAAAAA</bytes> </object> @@ -463,7 +466,7 @@ </object> </object> <nil key="sourceID"/> - <int key="maxID">21</int> + <int key="maxID">48</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -549,12 +552,59 @@ </object> </object> </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="424151936"> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> <string key="minorKey">browser/ui/cocoa/browser/avatar_menu_bubble_controller.h</string> </object> </object> <object class="IBPartialClassDescription"> + <string key="className">GTMUILocalizer</string> + <string key="superclassName">NSObject</string> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>otherObjectToLocalize_</string> + <string>owner_</string> + <string>yetAnotherObjectToLocalize_</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="toOneOutletInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>otherObjectToLocalize_</string> + <string>owner_</string> + <string>yetAnotherObjectToLocalize_</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBToOneOutletInfo"> + <string key="name">otherObjectToLocalize_</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">owner_</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">yetAnotherObjectToLocalize_</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">../third_party/GTM/AppKit/GTMUILocalizer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> <string key="className">HoverButton</string> <string key="superclassName">NSButton</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> @@ -599,13 +649,6 @@ </object> </object> <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBProjectSource</string> - <string key="minorKey">common/mac/objc_zombie.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> <string key="className">NSView</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> <string key="majorKey">IBProjectSource</string> @@ -619,9 +662,105 @@ <string key="minorKey">browser/ui/cocoa/view_id_util.h</string> </object> </object> + </object> + <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.1+"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBPartialClassDescription"> + <string key="className">AvatarMenuItemController</string> + <string key="superclassName">NSViewController</string> + <object class="NSMutableDictionary" key="actions"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>editProfile:</string> + <string>switchToProfile:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>id</string> + <string>id</string> + </object> + </object> + <object class="NSMutableDictionary" key="actionInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>editProfile:</string> + <string>switchToProfile:</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBActionInfo"> + <string key="name">editProfile:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo"> + <string key="name">switchToProfile:</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>activeView</string> + <string>editButton</string> + <string>emailField</string> + <string>iconView</string> + <string>nameField</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>NSImageView</string> + <string>NSButton</string> + <string>NSTextField</string> + <string>NSImageView</string> + <string>NSTextField</string> + </object> + </object> + <object class="NSMutableDictionary" key="toOneOutletInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>activeView</string> + <string>editButton</string> + <string>emailField</string> + <string>iconView</string> + <string>nameField</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBToOneOutletInfo"> + <string key="name">activeView</string> + <string key="candidateClassName">NSImageView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">editButton</string> + <string key="candidateClassName">NSButton</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">emailField</string> + <string key="candidateClassName">NSTextField</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">iconView</string> + <string key="candidateClassName">NSImageView</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">nameField</string> + <string key="candidateClassName">NSTextField</string> + </object> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier" id="980300083"> + <string key="majorKey">IBDocumentRelativeSource</string> + <string key="minorKey">../../browser/ui/cocoa/browser/avatar_menu_bubble_controller.h</string> + </object> + </object> <object class="IBPartialClassDescription"> - <string key="className">SwitchProfileButtonCell</string> - <string key="superclassName">NSButtonCell</string> + <string key="className">AvatarMenuItemView</string> + <string key="superclassName">NSView</string> <object class="NSMutableDictionary" key="outlets"> <string key="NS.key.0">viewController</string> <string key="NS.object.0">AvatarMenuItemController</string> @@ -633,7 +772,62 @@ <string key="candidateClassName">AvatarMenuItemController</string> </object> </object> - <reference key="sourceIdentifier" ref="424151936"/> + <reference key="sourceIdentifier" ref="980300083"/> + </object> + <object class="IBPartialClassDescription"> + <string key="className">ChromeUILocalizer</string> + <string key="superclassName">GTMUILocalizer</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBDocumentRelativeSource</string> + <string key="minorKey">../../browser/ui/cocoa/ui_localizer.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">GTMUILocalizer</string> + <string key="superclassName">NSObject</string> + <object class="NSMutableDictionary" key="outlets"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>otherObjectToLocalize_</string> + <string>owner_</string> + <string>yetAnotherObjectToLocalize_</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="toOneOutletInfosByName"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + <string>otherObjectToLocalize_</string> + <string>owner_</string> + <string>yetAnotherObjectToLocalize_</string> + </object> + <object class="NSMutableArray" key="dict.values"> + <bool key="EncodedWithXMLCoder">YES</bool> + <object class="IBToOneOutletInfo"> + <string key="name">otherObjectToLocalize_</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">owner_</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBToOneOutletInfo"> + <string key="name">yetAnotherObjectToLocalize_</string> + <string key="candidateClassName">id</string> + </object> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBDocumentRelativeSource</string> + <string key="minorKey">../../../third_party/GTM/AppKit/GTMUILocalizer.h</string> + </object> </object> </object> <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> @@ -691,14 +885,6 @@ </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"> @@ -1324,7 +1510,7 @@ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string> <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults"> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> - <integer value="1050" key="NS.object.0"/> + <integer value="1060" key="NS.object.0"/> </object> <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string> @@ -1337,13 +1523,11 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>NSInfo</string> <string>NSLockLockedTemplate</string> <string>NSUser</string> </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> - <string>{32, 32}</string> <string>{9, 12}</string> <string>{32, 32}</string> </object> diff --git a/chrome/browser/ui/cocoa/base_bubble_controller.h b/chrome/browser/ui/cocoa/base_bubble_controller.h index 27d750e..773ec58 100644 --- a/chrome/browser/ui/cocoa/base_bubble_controller.h +++ b/chrome/browser/ui/cocoa/base_bubble_controller.h @@ -64,4 +64,8 @@ class Bridge; parentWindow:(NSWindow*)parentWindow anchoredAt:(NSPoint)anchoredAt; +// Creates an autoreleased separator view with a given frame. The height of the +// frame is ignored. +- (NSBox*)separatorWithFrame:(NSRect)frame; + @end diff --git a/chrome/browser/ui/cocoa/base_bubble_controller.mm b/chrome/browser/ui/cocoa/base_bubble_controller.mm index 808ec8e..69160d7 100644 --- a/chrome/browser/ui/cocoa/base_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/base_bubble_controller.mm @@ -133,6 +133,15 @@ class Bridge : public NotificationObserver { [self updateOriginFromAnchor]; } +- (NSBox*)separatorWithFrame:(NSRect)frame { + frame.size.height = 1.0; + scoped_nsobject<NSBox> spacer([[NSBox alloc] initWithFrame:frame]); + [spacer setBoxType:NSBoxSeparator]; + [spacer setBorderType:NSLineBorder]; + [spacer setAlphaValue:0.2]; + return [spacer.release() autorelease]; +} + - (void)parentWindowWillClose:(NSNotification*)notification { [self close]; } diff --git a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h index d78e434..aa3191f 100644 --- a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h +++ b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h @@ -10,6 +10,7 @@ #include "base/memory/scoped_nsobject.h" #include "base/memory/scoped_ptr.h" #import "chrome/browser/ui/cocoa/base_bubble_controller.h" +#import "chrome/browser/ui/cocoa/tracking_area.h" class AvatarMenuModel; class AvatarMenuModelObserver; @@ -61,13 +62,18 @@ class Browser; __weak NSImageView* iconView_; __weak NSImageView* activeView_; __weak NSTextField* nameField_; - __weak HoverImageButton* editButton_; + // These two views sit on top of each other, and only one is visible at a + // time. The editButton_ is visible when the mouse is over the item and the + // emailField_ is visible otherwise. + __weak NSTextField* emailField_; + __weak NSButton* editButton_; } @property(readonly, nonatomic) size_t modelIndex; @property(assign, nonatomic) IBOutlet NSImageView* iconView; @property(assign, nonatomic) IBOutlet NSImageView* activeView; @property(assign, nonatomic) IBOutlet NSTextField* nameField; -@property(assign, nonatomic) IBOutlet HoverImageButton* editButton; +@property(assign, nonatomic) IBOutlet NSTextField* emailField; +@property(assign, nonatomic) IBOutlet NSButton* editButton; // Designated initializer. - (id)initWithModelIndex:(size_t)modelIndex @@ -89,10 +95,16 @@ class Browser; // view controller for changing highlight style of the item subviews. This is // an invisible button that underlays most of the menu item and is responsible // for performing the switch profile action. -@interface SwitchProfileButtonCell : NSButtonCell { +@interface AvatarMenuItemView : NSView { @private // The controller that manages this. __weak AvatarMenuItemController* viewController_; + + // Used to highlight the background on hover. + ScopedCrTrackingArea trackingArea_; + + // Whether the mouse is inside the bounds of this view. + BOOL mouseInside_; } @property(assign, nonatomic) IBOutlet AvatarMenuItemController* viewController; @end diff --git a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.mm b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.mm index 2a21437..f14b522 100644 --- a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.mm @@ -27,7 +27,6 @@ @interface AvatarMenuBubbleController (Private) - (AvatarMenuModel*)model; - (NSButton*)configureNewUserButton:(CGFloat)yOffset; -- (void)configureEditButton:(HoverImageButton*)button; @end namespace AvatarMenuInternal { @@ -132,7 +131,14 @@ const CGFloat kLabelInset = 49.0; // Since drawing happens bottom-up, start with the "New User" link. NSButton* newButton = [self configureNewUserButton:yOffset]; [contentView addSubview:newButton]; - yOffset += NSHeight([newButton frame]) + (kLinkSpacing - kVerticalSpacing); + yOffset += NSHeight([newButton frame]) + kVerticalSpacing; + + NSBox* separator = [self separatorWithFrame: + NSMakeRect(10, yOffset, NSWidth([contentView frame]) - 20, 0)]; + [separator setAutoresizingMask:NSViewWidthSizable]; + [contentView addSubview:separator]; + + yOffset += NSHeight([separator frame]); // Loop over the profiles in reverse, constructing the menu items. CGFloat widthAdjust = 0; @@ -154,20 +160,23 @@ const CGFloat kLabelInset = 49.0; if (delta.width > 0) widthAdjust = std::max(widthAdjust, delta.width); + // Repeat for the sync state/email. + NSTextField* emailField = itemView.emailField; + emailField.stringValue = base::SysUTF16ToNSString(item.sync_state); + delta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:emailField]; + if (delta.width > 0) + widthAdjust = std::max(widthAdjust, delta.width); + if (!item.active) { // In the inactive case, hide additional UI. [itemView.activeView setHidden:YES]; [itemView.editButton setHidden:YES]; } else { // Otherwise, set up the edit button and its three interaction states. - [self configureEditButton:itemView.editButton]; itemView.activeView.image = rb.GetImageNamed(IDR_PROFILE_SELECTED).ToNSImage(); } - // Force a highlight of the default state to get the text colored correctly. - [itemView highlightForEventType:NSLeftMouseUp]; - // Add the item to the content view. [[itemView view] setFrameOrigin:NSMakePoint(0, yOffset)]; [contentView addSubview:[itemView view]]; @@ -177,7 +186,7 @@ const CGFloat kLabelInset = 49.0; [items_ addObject:itemView]; } - yOffset += kVerticalSpacing; + yOffset += kVerticalSpacing * 1.5; // Set the window frame, clamping the width at a sensible max. NSRect frame = [[self window] frame]; @@ -203,23 +212,6 @@ const CGFloat kLabelInset = 49.0; return [newButton.release() autorelease]; } -- (void)configureEditButton:(HoverImageButton*)button { - [button setTrackingEnabled:YES]; - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - [button setDefaultImage:rb.GetImageNamed(IDR_PROFILE_EDIT).ToNSImage()]; - [button setDefaultOpacity:1.0]; - - [button setHoverImage:rb.GetImageNamed(IDR_PROFILE_EDIT_HOVER).ToNSImage()]; - [button setHoverOpacity:1.0]; - - [button setPressedImage: - rb.GetImageNamed(IDR_PROFILE_EDIT_PRESSED).ToNSImage()]; - [button setPressedOpacity:1.0]; - - [[button cell] setHighlightsBy:NSNoCellMask]; -} - - (NSMutableArray*)items { return items_.get(); } @@ -234,6 +226,7 @@ const CGFloat kLabelInset = 49.0; @synthesize iconView = iconView_; @synthesize activeView = activeView_; @synthesize nameField = nameField_; +@synthesize emailField = emailField_; @synthesize editButton = editButton_; - (id)initWithModelIndex:(size_t)modelIndex @@ -247,6 +240,16 @@ const CGFloat kLabelInset = 49.0; return self; } +- (void)dealloc { + static_cast<AvatarMenuItemView*>(self.view).viewController = nil; + [super dealloc]; +} + +- (void)awakeFromNib { + [GTMUILocalizerAndLayoutTweaker sizeToFitView:self.editButton]; + self.editButton.hidden = YES; +} + - (IBAction)switchToProfile:(id)sender { [controller_ switchToProfile:self]; } @@ -257,70 +260,80 @@ const CGFloat kLabelInset = 49.0; - (void)highlightForEventType:(NSEventType)type { BOOL active = !self.activeView.isHidden; - NSColor* color = nil; switch (type) { case NSMouseEntered: - case NSLeftMouseDown: if (active) { - color = [NSColor colorWithCalibratedRed:0 green:0 blue:0 alpha:1]; - } else { - color = [NSColor colorWithCalibratedRed:0.25 - green:0.25 - blue:0.25 - alpha:1]; + self.editButton.hidden = NO; + self.emailField.hidden = YES; } break; case NSMouseExited: - case NSLeftMouseUp: - if (active) { - color = [NSColor colorWithCalibratedRed:0.12 - green:0.12 - blue:0.12 - alpha:1]; - } else { - color = [NSColor colorWithCalibratedRed:0.5 - green:0.5 - blue:0.5 - alpha:1]; - } + self.editButton.hidden = YES; + self.emailField.hidden = NO; break; default: NOTREACHED(); }; - - DCHECK(color); - self.nameField.textColor = color; } @end // Profile Switch Button /////////////////////////////////////////////////////// -@implementation SwitchProfileButtonCell +@implementation AvatarMenuItemView @synthesize viewController = viewController_; - (void)awakeFromNib { - // Needed to get entered and exited events. - self.showsBorderOnlyWhileMouseInside = YES; + [self updateTrackingAreas]; +} + +- (void)updateTrackingAreas { + if (trackingArea_.get()) + [self removeTrackingArea:trackingArea_.get()]; + + trackingArea_.reset( + [[CrTrackingArea alloc] initWithRect:[self bounds] + options:NSTrackingMouseEnteredAndExited | + NSTrackingActiveInKeyWindow + proxiedOwner:self + userInfo:nil]); + [self addTrackingArea:trackingArea_.get()]; + + [super updateTrackingAreas]; } - (void)mouseEntered:(id)sender { [viewController_ highlightForEventType:[[NSApp currentEvent] type]]; + mouseInside_ = YES; + [self setNeedsDisplay:YES]; } - (void)mouseExited:(id)sender { [viewController_ highlightForEventType:[[NSApp currentEvent] type]]; + mouseInside_ = NO; + [self setNeedsDisplay:YES]; } -- (void)mouseDown:(id)sender { - [viewController_ highlightForEventType:[[NSApp currentEvent] type]]; +- (void)mouseUp:(id)sender { + [viewController_ switchToProfile:self]; } -- (void)mouseUp:(id)sender { - [viewController_ highlightForEventType:[[NSApp currentEvent] type]]; +- (void)drawRect:(NSRect)dirtyRect { + NSColor* backgroundColor = nil; + if (mouseInside_) { + backgroundColor = [NSColor colorWithCalibratedRed:223.0/255 + green:238.0/255 + blue:246.0/255 + alpha:1.0]; + } else { + backgroundColor = [NSColor whiteColor]; + } + + [backgroundColor set]; + NSRectFill([self bounds]); } @end diff --git a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm index b4b2e27..ba017c2 100644 --- a/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller_unittest.mm @@ -64,9 +64,9 @@ class AvatarMenuBubbleControllerTest : public CocoaTest { TEST_F(AvatarMenuBubbleControllerTest, InitialLayout) { [controller() showWindow:nil]; - // Two profiles means two item views and the new button. + // Two profiles means two item views and the new button with separator. NSView* contents = [[controller() window] contentView]; - EXPECT_EQ(3U, [[contents subviews] count]); + EXPECT_EQ(4U, [[contents subviews] count]); // Loop over the itmes and match the viewController views to subviews. NSMutableArray* subviews = @@ -81,14 +81,27 @@ TEST_F(AvatarMenuBubbleControllerTest, InitialLayout) { } // The one remaining subview should be the new user button. - EXPECT_EQ(1U, [subviews count]); - - NSButton* newUser = [subviews lastObject]; - ASSERT_TRUE([newUser isKindOfClass:[NSButton class]]); - - EXPECT_EQ(@selector(newProfile:), [newUser action]); - EXPECT_EQ(controller(), [newUser target]); - EXPECT_TRUE([[newUser cell] isKindOfClass:[HyperlinkButtonCell class]]); + EXPECT_EQ(2U, [subviews count]); + + BOOL hasButton = NO; + BOOL hasSeparator = NO; + for (NSView* subview in subviews) { + if ([subview isKindOfClass:[NSButton class]]) { + EXPECT_FALSE(hasButton); + hasButton = YES; + + NSButton* button = static_cast<NSButton*>(subview); + EXPECT_EQ(@selector(newProfile:), [button action]); + EXPECT_EQ(controller(), [button target]); + EXPECT_TRUE([[button cell] isKindOfClass:[HyperlinkButtonCell class]]); + } else if ([subview isKindOfClass:[NSBox class]]) { + EXPECT_FALSE(hasSeparator); + hasSeparator = YES; + } else { + EXPECT_FALSE(subview) << "Unexpected subview: " + << [[subview description] UTF8String]; + } + } [controller() close]; } @@ -97,7 +110,7 @@ TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) { [controller() showWindow:nil]; NSView* contents = [[controller() window] contentView]; - EXPECT_EQ(3U, [[contents subviews] count]); + EXPECT_EQ(4U, [[contents subviews] count]); scoped_nsobject<NSMutableArray> oldItems([[controller() items] copy]); @@ -107,7 +120,7 @@ TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) { // Testing the bridge is not worth the effort... [controller() performLayout]; - EXPECT_EQ(4U, [[contents subviews] count]); + EXPECT_EQ(5U, [[contents subviews] count]); // Make sure that none of the old items exit. NSArray* newItems = [controller() items]; @@ -123,60 +136,29 @@ TEST_F(AvatarMenuBubbleControllerTest, HighlightForEventType) { scoped_nsobject<AvatarMenuItemController> item( [[AvatarMenuItemController alloc] initWithModelIndex:0 menuController:nil]); - NSTextField* field = [item nameField]; // Test non-active states first. [[item activeView] setHidden:YES]; - NSColor* startColor = [NSColor controlTextColor]; - NSColor* upColor = nil; - NSColor* downColor = nil; - NSColor* enterColor = nil; - NSColor* exitColor = nil; - - EXPECT_NSEQ(startColor, field.textColor); - - // The controller does this in |-performLayout|. - [item highlightForEventType:NSLeftMouseUp]; - EXPECT_NSNE(startColor, field.textColor); - startColor = field.textColor; - - [item highlightForEventType:NSLeftMouseDown]; - downColor = field.textColor; + NSView* editButton = [item editButton]; + NSView* emailField = [item emailField]; + // The edit link remains hidden. [item highlightForEventType:NSMouseEntered]; - enterColor = field.textColor; + EXPECT_TRUE(editButton.isHidden); + EXPECT_FALSE(emailField.isHidden); [item highlightForEventType:NSMouseExited]; - exitColor = field.textColor; - - [item highlightForEventType:NSLeftMouseUp]; - upColor = field.textColor; - - // Use transitivity to determine that all colors for each state are correct. - EXPECT_NSEQ(startColor, upColor); - EXPECT_NSEQ(upColor, exitColor); - EXPECT_NSEQ(downColor, enterColor); - EXPECT_NSNE(enterColor, exitColor); + EXPECT_TRUE(editButton.isHidden); + EXPECT_FALSE(emailField.isHidden); // Make the item "active" and re-test. [[item activeView] setHidden:NO]; - [item highlightForEventType:NSLeftMouseUp]; - EXPECT_NSNE(startColor, field.textColor); - upColor = field.textColor; - - [item highlightForEventType:NSLeftMouseDown]; - EXPECT_NSNE(downColor, field.textColor); - downColor = field.textColor; [item highlightForEventType:NSMouseEntered]; - EXPECT_NSNE(enterColor, field.textColor); - enterColor = field.textColor; + EXPECT_FALSE(editButton.isHidden); + EXPECT_TRUE(emailField.isHidden); [item highlightForEventType:NSMouseExited]; - EXPECT_NSNE(exitColor, field.textColor); - exitColor = field.textColor; - - EXPECT_NSEQ(upColor, exitColor); - EXPECT_NSEQ(downColor, enterColor); - EXPECT_NSNE(upColor, downColor); + EXPECT_TRUE(editButton.isHidden); + EXPECT_FALSE(emailField.isHidden); } diff --git a/chrome/browser/ui/cocoa/page_info_bubble_controller.mm b/chrome/browser/ui/cocoa/page_info_bubble_controller.mm index bdb0389..3ae8aac 100644 --- a/chrome/browser/ui/cocoa/page_info_bubble_controller.mm +++ b/chrome/browser/ui/cocoa/page_info_bubble_controller.mm @@ -453,15 +453,10 @@ void ShowPageInfoBubble(gfx::NativeWindow parent, // next offset. - (CGFloat)addSeparatorToSubviews:(NSMutableArray*)subviews atOffset:(CGFloat)offset { - const CGFloat kSpacerHeight = 1.0; - NSRect frame = NSMakeRect(kFramePadding, offset, - kWindowWidth - 2 * kFramePadding, kSpacerHeight); - scoped_nsobject<NSBox> spacer([[NSBox alloc] initWithFrame:frame]); - [spacer setBoxType:NSBoxSeparator]; - [spacer setBorderType:NSLineBorder]; - [spacer setAlphaValue:0.2]; - [subviews addObject:spacer.get()]; - return kVerticalSpacing + kSpacerHeight; + NSBox* spacer = [self separatorWithFrame:NSMakeRect(kFramePadding, offset, + kWindowWidth - 2 * kFramePadding, 0)]; + [subviews addObject:spacer]; + return kVerticalSpacing + NSHeight([spacer frame]); } // Takes in the bubble's height and the parent window, which should be a diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 6882c8a..72d751b 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -4311,6 +4311,7 @@ 'xib_files_to_scan': [ # The xibs that need localization 'app/nibs/About.xib', + 'app/nibs/AvatarMenuItem.xib', 'app/nibs/BookmarkAllTabs.xib', 'app/nibs/BookmarkBar.xib', 'app/nibs/BookmarkBubble.xib', |