summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 23:02:08 +0000
committerpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 23:02:08 +0000
commit8358105e6826be9bbb7ef2a43671d596aa492ba6 (patch)
treef3aa6026df83d2ab8befec964f6abb3bb4bde9d6 /chrome
parenta796793059916e64b9c45191c1945868f4bff2a5 (diff)
downloadchromium_src-8358105e6826be9bbb7ef2a43671d596aa492ba6.zip
chromium_src-8358105e6826be9bbb7ef2a43671d596aa492ba6.tar.gz
chromium_src-8358105e6826be9bbb7ef2a43671d596aa492ba6.tar.bz2
The Mac version of the download shelf from the original CL by thakis:
http://codereview.chromium.org/150216 Original description: Move download item to its own view and a xib, paving the way for a custom download item view. I didn't change the look of the download items yet. The context menu is now in the download item xib as well. BUG=14659,15098,14660 TEST=Download something. Everything should look like before (except for the smaller icon), but the context menu items should be disabled/enabled and checked/unchecked correctly. Review URL: http://codereview.chromium.org/149276 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20200 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/nibs/en.lproj/DownloadItem.xib700
-rw-r--r--chrome/browser/cocoa/download_item_controller.h40
-rw-r--r--chrome/browser/cocoa/download_item_controller.mm133
-rw-r--r--chrome/browser/cocoa/download_item_mac.h20
-rw-r--r--chrome/browser/cocoa/download_item_mac.mm145
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.h19
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.mm63
-rw-r--r--chrome/browser/cocoa/download_shelf_mac.h3
-rw-r--r--chrome/browser/cocoa/download_shelf_mac.mm33
-rw-r--r--chrome/chrome.gyp3
10 files changed, 948 insertions, 211 deletions
diff --git a/chrome/app/nibs/en.lproj/DownloadItem.xib b/chrome/app/nibs/en.lproj/DownloadItem.xib
new file mode 100644
index 0000000..44ed1d21
--- /dev/null
+++ b/chrome/app/nibs/en.lproj/DownloadItem.xib
@@ -0,0 +1,700 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
+ <data>
+ <int key="IBDocument.SystemTarget">1050</int>
+ <string key="IBDocument.SystemVersion">9J61</string>
+ <string key="IBDocument.InterfaceBuilderVersion">677</string>
+ <string key="IBDocument.AppKitVersion">949.46</string>
+ <string key="IBDocument.HIToolboxVersion">353.00</string>
+ <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="24"/>
+ <integer value="4"/>
+ <integer value="13"/>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSCustomObject" id="1001">
+ <string key="NSClassName">DownloadItemController</string>
+ </object>
+ <object class="NSCustomObject" id="1003">
+ <string key="NSClassName">FirstResponder</string>
+ </object>
+ <object class="NSCustomObject" id="1004">
+ <string key="NSClassName">NSApplication</string>
+ </object>
+ <object class="NSCustomView" id="1005">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">268</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSPopUpButton" id="690119733">
+ <reference key="NSNextResponder" ref="1005"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{0, 3}, {200, 26}}</string>
+ <reference key="NSSuperview" ref="1005"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSPopUpButtonCell" key="NSCell" id="750218797">
+ <int key="NSCellFlags">-2076049856</int>
+ <int key="NSCellFlags2">134219776</int>
+ <object class="NSFont" key="NSSupport">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">1.300000e+01</double>
+ <int key="NSfFlags">1044</int>
+ </object>
+ <reference key="NSControlView" ref="690119733"/>
+ <int key="NSButtonFlags">-2035269377</int>
+ <int key="NSButtonFlags2">129</int>
+ <object class="NSImage" key="NSNormalImage">
+ <int key="NSImageFlags">549650432</int>
+ <string key="NSSize">{1, 1}</string>
+ <object class="NSMutableArray" key="NSReps">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="0"/>
+ <object class="NSBitmapImageRep">
+ <object class="NSData" key="NSTIFFRepresentation">
+ <bytes key="NS.bytes">TU0AKgAAAAoAAAANAQAAAwAAAAEAAQAAAQEAAwAAAAEAAQAAAQIAAwAAAAIACAAIAQMAAwAAAAEAAQAA
+AQYAAwAAAAEAAQAAAREABAAAAAEAAAAIARIAAwAAAAEAAQAAARUAAwAAAAEAAgAAARYAAwAAAAEQAAAA
+ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="NSColor" key="NSColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MCAwAA</bytes>
+ </object>
+ </object>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ <object class="NSMenuItem" key="NSMenuItem" id="593643111">
+ <reference key="NSMenu" ref="672782413"/>
+ <bool key="NSIsHidden">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <object class="NSCustomResource" key="NSOnImage" id="503301017">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuCheckmark</string>
+ </object>
+ <object class="NSCustomResource" key="NSMixedImage" id="246735032">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">NSMenuMixedState</string>
+ </object>
+ <string key="NSAction">_popUpItemAction:</string>
+ <reference key="NSTarget" ref="750218797"/>
+ </object>
+ <bool key="NSMenuItemRespectAlignment">YES</bool>
+ <object class="NSMenu" key="NSMenu" id="672782413">
+ <string key="NSTitle">Unused</string>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="593643111"/>
+ </object>
+ </object>
+ <int key="NSSelectedIndex">-1</int>
+ <bool key="NSPullDown">YES</bool>
+ <int key="NSPreferredEdge">1</int>
+ <bool key="NSUsesItemFromMenu">YES</bool>
+ <bool key="NSAltersState">YES</bool>
+ <int key="NSArrowPosition">2</int>
+ </object>
+ </object>
+ </object>
+ <string key="NSFrameSize">{200, 32}</string>
+ <reference key="NSSuperview"/>
+ <string key="NSClassName">NSView</string>
+ </object>
+ <object class="NSMenu" id="571207526">
+ <string key="NSTitle">Completed Download</string>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMenuItem" id="426590582">
+ <reference key="NSMenu" ref="571207526"/>
+ <bool key="NSIsHidden">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ <object class="NSMenuItem" id="770771657">
+ <reference key="NSMenu" ref="571207526"/>
+ <string key="NSTitle">Open</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ <object class="NSMenuItem" id="530126839">
+ <reference key="NSMenu" ref="571207526"/>
+ <string key="NSTitle">Always open type</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ <object class="NSMenuItem" id="812951457">
+ <reference key="NSMenu" ref="571207526"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ </object>
+ <object class="NSMenuItem" id="191249624">
+ <reference key="NSMenu" ref="571207526"/>
+ <string key="NSTitle">Reveal in Finder</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ <object class="NSMenuItem" id="285298090">
+ <reference key="NSMenu" ref="571207526"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ </object>
+ <object class="NSMenuItem" id="693025028">
+ <reference key="NSMenu" ref="571207526"/>
+ <string key="NSTitle">Cancel</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ </object>
+ </object>
+ <object class="NSMenu" id="231354576">
+ <string key="NSTitle">Active Download</string>
+ <object class="NSMutableArray" key="NSMenuItems">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMenuItem" id="372396952">
+ <reference key="NSMenu" ref="231354576"/>
+ <bool key="NSIsHidden">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ <object class="NSMenuItem" id="514660119">
+ <reference key="NSMenu" ref="231354576"/>
+ <string type="base64-UTF8" key="NSTitle">T3BlbiB3aGVuIGNvbXBsZXRl4oCmA</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ <object class="NSMenuItem" id="769910664">
+ <reference key="NSMenu" ref="231354576"/>
+ <string key="NSTitle">Always open type</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ <object class="NSMenuItem" id="858143630">
+ <reference key="NSMenu" ref="231354576"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ </object>
+ <object class="NSMenuItem" id="434679781">
+ <reference key="NSMenu" ref="231354576"/>
+ <string key="NSTitle">Reveal in Finder</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ <object class="NSMenuItem" id="158646227">
+ <reference key="NSMenu" ref="231354576"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ </object>
+ <object class="NSMenuItem" id="93640760">
+ <reference key="NSMenu" ref="231354576"/>
+ <string key="NSTitle">Cancel</string>
+ <string key="NSKeyEquiv"/>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="503301017"/>
+ <reference key="NSMixedImage" ref="246735032"/>
+ <string key="NSAction">_popUpItemAction:</string>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <object class="NSMutableArray" key="connectionRecords">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">popupButton_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="690119733"/>
+ </object>
+ <int key="connectionID">12</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">completeDownloadMenu_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="571207526"/>
+ </object>
+ <int key="connectionID">21</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">view</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="1005"/>
+ </object>
+ <int key="connectionID">23</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">activeDownloadMenu_</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="231354576"/>
+ </object>
+ <int key="connectionID">32</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">handleOpen:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="514660119"/>
+ </object>
+ <int key="connectionID">36</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">handleAlwaysOpen:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="769910664"/>
+ </object>
+ <int key="connectionID">37</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">handleReveal:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="434679781"/>
+ </object>
+ <int key="connectionID">38</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">handleCancel:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="93640760"/>
+ </object>
+ <int key="connectionID">39</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">handleOpen:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="770771657"/>
+ </object>
+ <int key="connectionID">40</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">handleAlwaysOpen:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="530126839"/>
+ </object>
+ <int key="connectionID">41</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">handleReveal:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="191249624"/>
+ </object>
+ <int key="connectionID">42</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">handleCancel:</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="693025028"/>
+ </object>
+ <int key="connectionID">43</int>
+ </object>
+ </object>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <object class="NSArray" key="orderedObjects">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <object class="NSArray" key="object" id="1002">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="1001"/>
+ <reference key="parent" ref="1002"/>
+ <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="1003"/>
+ <reference key="parent" ref="1002"/>
+ <string key="objectName">First Responder</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-3</int>
+ <reference key="object" ref="1004"/>
+ <reference key="parent" ref="1002"/>
+ <string key="objectName">Application</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">1</int>
+ <reference key="object" ref="1005"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="690119733"/>
+ </object>
+ <reference key="parent" ref="1002"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">2</int>
+ <reference key="object" ref="690119733"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="750218797"/>
+ </object>
+ <reference key="parent" ref="1005"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">3</int>
+ <reference key="object" ref="750218797"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="672782413"/>
+ </object>
+ <reference key="parent" ref="690119733"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">4</int>
+ <reference key="object" ref="672782413"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="593643111"/>
+ </object>
+ <reference key="parent" ref="750218797"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">8</int>
+ <reference key="object" ref="593643111"/>
+ <reference key="parent" ref="672782413"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">13</int>
+ <reference key="object" ref="571207526"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="285298090"/>
+ <reference ref="693025028"/>
+ <reference ref="812951457"/>
+ <reference ref="426590582"/>
+ <reference ref="191249624"/>
+ <reference ref="530126839"/>
+ <reference ref="770771657"/>
+ </object>
+ <reference key="parent" ref="1002"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">14</int>
+ <reference key="object" ref="285298090"/>
+ <reference key="parent" ref="571207526"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">15</int>
+ <reference key="object" ref="693025028"/>
+ <reference key="parent" ref="571207526"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">16</int>
+ <reference key="object" ref="812951457"/>
+ <reference key="parent" ref="571207526"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">17</int>
+ <reference key="object" ref="426590582"/>
+ <reference key="parent" ref="571207526"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">18</int>
+ <reference key="object" ref="191249624"/>
+ <reference key="parent" ref="571207526"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">19</int>
+ <reference key="object" ref="530126839"/>
+ <reference key="parent" ref="571207526"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">20</int>
+ <reference key="object" ref="770771657"/>
+ <reference key="parent" ref="571207526"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">24</int>
+ <reference key="object" ref="231354576"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="158646227"/>
+ <reference ref="93640760"/>
+ <reference ref="858143630"/>
+ <reference ref="372396952"/>
+ <reference ref="434679781"/>
+ <reference ref="769910664"/>
+ <reference ref="514660119"/>
+ </object>
+ <reference key="parent" ref="1002"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">25</int>
+ <reference key="object" ref="158646227"/>
+ <reference key="parent" ref="231354576"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">26</int>
+ <reference key="object" ref="93640760"/>
+ <reference key="parent" ref="231354576"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">27</int>
+ <reference key="object" ref="858143630"/>
+ <reference key="parent" ref="231354576"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">28</int>
+ <reference key="object" ref="372396952"/>
+ <reference key="parent" ref="231354576"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">29</int>
+ <reference key="object" ref="434679781"/>
+ <reference key="parent" ref="231354576"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">30</int>
+ <reference key="object" ref="769910664"/>
+ <reference key="parent" ref="231354576"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">31</int>
+ <reference key="object" ref="514660119"/>
+ <reference key="parent" ref="231354576"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="flattenedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>-1.IBPluginDependency</string>
+ <string>-2.IBPluginDependency</string>
+ <string>-3.IBPluginDependency</string>
+ <string>1.IBEditorWindowLastContentRect</string>
+ <string>1.IBPluginDependency</string>
+ <string>1.WindowOrigin</string>
+ <string>1.editorWindowContentRectSynchronizationRect</string>
+ <string>13.IBEditorWindowLastContentRect</string>
+ <string>13.IBPluginDependency</string>
+ <string>14.IBPluginDependency</string>
+ <string>15.IBPluginDependency</string>
+ <string>16.IBPluginDependency</string>
+ <string>17.IBPluginDependency</string>
+ <string>18.IBPluginDependency</string>
+ <string>19.IBPluginDependency</string>
+ <string>2.IBPluginDependency</string>
+ <string>20.IBPluginDependency</string>
+ <string>24.IBEditorWindowLastContentRect</string>
+ <string>24.IBPluginDependency</string>
+ <string>25.IBPluginDependency</string>
+ <string>26.IBPluginDependency</string>
+ <string>27.IBPluginDependency</string>
+ <string>28.IBPluginDependency</string>
+ <string>29.IBPluginDependency</string>
+ <string>3.IBPluginDependency</string>
+ <string>30.IBPluginDependency</string>
+ <string>31.IBPluginDependency</string>
+ <string>4.IBEditorWindowLastContentRect</string>
+ <string>4.IBPluginDependency</string>
+ <string>8.IBPluginDependency</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{348, 715}, {200, 32}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{628, 654}</string>
+ <string>{{357, 416}, {480, 272}}</string>
+ <string>{{47, 630}, {188, 123}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{337, 621}, {227, 123}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{337, 721}, {200, 23}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="activeLocalization"/>
+ <object class="NSMutableDictionary" key="localizations">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ </object>
+ <nil key="sourceID"/>
+ <int key="maxID">43</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">DownloadItemController</string>
+ <string key="superclassName">NSViewController</string>
+ <object class="NSMutableDictionary" key="actions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>handleAlwaysOpen:</string>
+ <string>handleCancel:</string>
+ <string>handleOpen:</string>
+ <string>handleReveal:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>activeDownloadMenu_</string>
+ <string>completeDownloadMenu_</string>
+ <string>popupButton_</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>NSMenu</string>
+ <string>NSMenu</string>
+ <string>NSPopUpButton</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/download_item_controller.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">browser/cocoa/tab_strip_model_observer_bridge.h</string>
+ </object>
+ </object>
+ </object>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.LastKnownRelativeProjectPath">../../../chrome.xcodeproj</string>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ </data>
+</archive>
diff --git a/chrome/browser/cocoa/download_item_controller.h b/chrome/browser/cocoa/download_item_controller.h
new file mode 100644
index 0000000..d55231d
--- /dev/null
+++ b/chrome/browser/cocoa/download_item_controller.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/scoped_ptr.h"
+
+class BaseDownloadItemModel;
+class DownloadItemMac;
+class DownloadShelfContextMenuMac;
+
+// A controller class that manages one download item.
+
+@interface DownloadItemController : NSViewController {
+ @private
+ IBOutlet NSPopUpButton* popupButton_;
+
+ IBOutlet NSMenu* activeDownloadMenu_;
+ IBOutlet NSMenu* completeDownloadMenu_;
+
+ scoped_ptr<DownloadItemMac> bridge_;
+ scoped_ptr<DownloadShelfContextMenuMac> menuBridge_;
+};
+
+// Takes ownership of |downloadModel|.
+- (id)initWithFrame:(NSRect)frameRect
+ model:(BaseDownloadItemModel*)downloadModel;
+
+// Updates the UI and menu state from |downloadModel|.
+- (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel;
+
+// Context menu handlers.
+- (IBAction)handleOpen:(id)sender;
+- (IBAction)handleAlwaysOpen:(id)sender;
+- (IBAction)handleReveal:(id)sender;
+- (IBAction)handleCancel:(id)sender;
+
+@end
+
diff --git a/chrome/browser/cocoa/download_item_controller.mm b/chrome/browser/cocoa/download_item_controller.mm
new file mode 100644
index 0000000..c189c66
--- /dev/null
+++ b/chrome/browser/cocoa/download_item_controller.mm
@@ -0,0 +1,133 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/cocoa/download_item_controller.h"
+
+#include "app/l10n_util.h"
+#include "base/mac_util.h"
+#include "base/sys_string_conversions.h"
+#include "chrome/browser/cocoa/download_item_mac.h"
+#include "chrome/browser/download/download_item_model.h"
+#include "chrome/browser/download/download_shelf.h"
+
+// A class for the chromium-side part of the download shelf context menu.
+
+class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
+ public:
+ DownloadShelfContextMenuMac(BaseDownloadItemModel* model)
+ : DownloadShelfContextMenu(model) { }
+
+ using DownloadShelfContextMenu::ExecuteItemCommand;
+ using DownloadShelfContextMenu::ItemIsChecked;
+ using DownloadShelfContextMenu::IsItemCommandEnabled;
+
+ using DownloadShelfContextMenu::SHOW_IN_FOLDER;
+ using DownloadShelfContextMenu::OPEN_WHEN_COMPLETE;
+ using DownloadShelfContextMenu::ALWAYS_OPEN_TYPE;
+ using DownloadShelfContextMenu::CANCEL;
+};
+
+// Implementation of DownloadItemController
+
+@implementation DownloadItemController
+
+- (id)initWithFrame:(NSRect)frameRect
+ model:(BaseDownloadItemModel*)downloadModel {
+ if ((self = [super initWithNibName:@"DownloadItem"
+ bundle:mac_util::MainAppBundle()])) {
+ // Must be called before [self view], so that bridge_ is set in awakeFromNib
+ bridge_.reset(new DownloadItemMac(downloadModel, self));
+ menuBridge_.reset(new DownloadShelfContextMenuMac(downloadModel));
+
+ [[self view] setFrame:frameRect];
+ }
+ return self;
+}
+
+- (void)awakeFromNib {
+ [self setStateFromDownload:bridge_->download_model()];
+}
+
+- (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel {
+ // TODO(thakis): The windows version of this does all kinds of things
+ // (gratituous use of animation, special handling of dangerous downloads)
+ // that we don't currently do.
+
+ // Set correct popup menu.
+ if (downloadModel->download()->state() == DownloadItem::COMPLETE)
+ [popupButton_ setMenu:completeDownloadMenu_];
+ else
+ [popupButton_ setMenu:activeDownloadMenu_];
+
+ // Set name and icon of download.
+ FilePath downloadPath = downloadModel->download()->GetFileName();
+
+ // TODO(thakis): use filename eliding like gtk/windows versions.
+ NSString* titleString = base::SysWideToNSString(downloadPath.ToWStringHack());
+ [[popupButton_ itemAtIndex:0] setTitle:titleString];
+
+ // TODO(paulg): Use IconManager for loading icons on the file thread
+ // (crbug.com/16226).
+ NSString* extension = base::SysUTF8ToNSString(downloadPath.Extension());
+ [[popupButton_ itemAtIndex:0] setImage:
+ [[NSWorkspace sharedWorkspace] iconForFileType:extension]];
+
+ // Set status text.
+ std::wstring statusText = downloadModel->GetStatusText();
+ // Remove the status text label.
+ if (statusText.empty()) {
+ // TODO(thakis): Once there is a status label, hide it here.
+ return;
+ }
+
+ // TODO(thakis): Set status_text as status label.
+}
+
+// Sets the enabled and checked state of a particular menu item for this
+// download. We translate the NSMenuItem selection to menu selections understood
+// by the non platform specific download context menu.
+- (BOOL)validateMenuItem:(NSMenuItem *)item {
+ SEL action = [item action];
+
+ int actionId = 0;
+ if (action == @selector(handleOpen:)) {
+ actionId = DownloadShelfContextMenuMac::OPEN_WHEN_COMPLETE;
+ } else if (action == @selector(handleAlwaysOpen:)) {
+ actionId = DownloadShelfContextMenuMac::ALWAYS_OPEN_TYPE;
+ } else if (action == @selector(handleReveal:)) {
+ actionId = DownloadShelfContextMenuMac::SHOW_IN_FOLDER;
+ } else if (action == @selector(handleCancel:)) {
+ actionId = DownloadShelfContextMenuMac::CANCEL;
+ } else {
+ NOTREACHED();
+ return YES;
+ }
+
+ if (menuBridge_->ItemIsChecked(actionId))
+ [item setState:NSOnState];
+ else
+ [item setState:NSOffState];
+
+ return menuBridge_->IsItemCommandEnabled(actionId) ? YES : NO;
+}
+
+- (IBAction)handleOpen:(id)sender {
+ menuBridge_->ExecuteItemCommand(
+ DownloadShelfContextMenuMac::OPEN_WHEN_COMPLETE);
+}
+
+- (IBAction)handleAlwaysOpen:(id)sender {
+ menuBridge_->ExecuteItemCommand(
+ DownloadShelfContextMenuMac::ALWAYS_OPEN_TYPE);
+}
+
+- (IBAction)handleReveal:(id)sender {
+ menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::SHOW_IN_FOLDER);
+}
+
+- (IBAction)handleCancel:(id)sender {
+ menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::CANCEL);
+}
+
+@end
diff --git a/chrome/browser/cocoa/download_item_mac.h b/chrome/browser/cocoa/download_item_mac.h
index 4af3d53..7f31c2a 100644
--- a/chrome/browser/cocoa/download_item_mac.h
+++ b/chrome/browser/cocoa/download_item_mac.h
@@ -12,19 +12,16 @@
#include "chrome/browser/download/download_manager.h"
class BaseDownloadItemModel;
-@class DownloadShelfController;
-@class DownloadShelfContextMenuBridge;
-
+@class DownloadItemController;
// A class that bridges the visible mac download items to chromium's
// download model.
class DownloadItemMac : DownloadItem::Observer {
public:
- // DownloadItemMac takes ownership of |download_item_model|.
- DownloadItemMac(BaseDownloadItemModel* download_item_model,
- NSRect frame,
- DownloadShelfController* parent);
+ // DownloadItemMac takes ownership of |download_model|.
+ DownloadItemMac(BaseDownloadItemModel* download_model,
+ DownloadItemController* controller);
// Destructor.
~DownloadItemMac();
@@ -33,15 +30,14 @@ class DownloadItemMac : DownloadItem::Observer {
virtual void OnDownloadUpdated(DownloadItem* download);
virtual void OnDownloadOpened(DownloadItem* download) { }
+ BaseDownloadItemModel* download_model() { return download_model_.get(); }
+
private:
// The download item model we represent.
scoped_ptr<BaseDownloadItemModel> download_model_;
- // Our parent view
- DownloadShelfController* parent_; // weak
-
- // Context menu
- scoped_nsobject<DownloadShelfContextMenuBridge> menu_;
+ // The objective-c controller object.
+ DownloadItemController* item_controller_; // weak, owns us.
};
#endif // CHROME_BROWSER_COCOA_DOWNLOAD_ITEM_MAC_H_
diff --git a/chrome/browser/cocoa/download_item_mac.mm b/chrome/browser/cocoa/download_item_mac.mm
index e9d86d2..05d4717 100644
--- a/chrome/browser/cocoa/download_item_mac.mm
+++ b/chrome/browser/cocoa/download_item_mac.mm
@@ -4,145 +4,15 @@
#include "chrome/browser/cocoa/download_item_mac.h"
-#include "base/basictypes.h"
-#include "base/string_util.h"
-#include "base/sys_string_conversions.h"
-#import "chrome/browser/cocoa/download_shelf_controller.h"
-#import "chrome/browser/cocoa/download_shelf_mac.h"
-#import "chrome/browser/cocoa/download_shelf_view.h"
+#import "chrome/browser/cocoa/download_item_controller.h"
#include "chrome/browser/download/download_item_model.h"
-#include "chrome/browser/download/download_manager.h"
-#include "chrome/browser/download/download_shelf.h"
-
-// A class for the chromium-side part of the download shelf context menu.
-
-class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
- public:
- DownloadShelfContextMenuMac(BaseDownloadItemModel* model,
- DownloadShelfContextMenuBridge* bridge)
- : DownloadShelfContextMenu(model), bridge_(bridge) {
- }
-
- NSMenu* GetCocoaMenu();
-
- using DownloadShelfContextMenu::ExecuteItemCommand;
-
- private:
- DownloadShelfContextMenuBridge* bridge_; // weak, owns us
-};
-
-NSMenu* DownloadShelfContextMenuMac::GetCocoaMenu() {
- // TODO(thakis): win/gtk show slightly different menus when the download is
- // in progress/done (mainly the first item)
- // TODO(thakis): this probably wants to be in a xib file or at least use
- // localized strings
-
- NSMenuItem* item;
- NSMenu* menu =
- [[[NSMenu alloc] initWithTitle:@"DownloadItemPopup"] autorelease];
- SEL action = @selector(performAction:);
-
- item = [menu addItemWithTitle:@"Open" action:action keyEquivalent:@""];
- // [item addItemWithTitle:@"Open when complete" ...]; // In-progress text.
- [item setTag:OPEN_WHEN_COMPLETE];
- [item setTarget:bridge_];
-
- // TODO(thakis): Set correct checkbox state, make this a checkbox item
- item = [menu addItemWithTitle:@"Always open type"
- action:action
- keyEquivalent:@""];
- [item setTag:ALWAYS_OPEN_TYPE];
- [item setTarget:bridge_];
-
- [menu addItem:[NSMenuItem separatorItem]];
-
- item = [menu addItemWithTitle:@"Reveal in Finder"
- action:action
- keyEquivalent:@""];
- [item setTag:SHOW_IN_FOLDER];
- [item setTarget:bridge_];
-
- [menu addItem:[NSMenuItem separatorItem]];
-
- item = [menu addItemWithTitle:@"Cancel" action:action keyEquivalent:@""];
- [item setTag:CANCEL];
- [item setTarget:bridge_];
-
- return menu;
-}
-
-
-// A class for the cocoa side of the download shelf context menu.
-
-@interface DownloadShelfContextMenuBridge : NSObject {
- @private
- scoped_ptr<DownloadShelfContextMenuMac> contextMenu_;
-}
-
-- (DownloadShelfContextMenuBridge*)initWithModel:(BaseDownloadItemModel*)model;
-@end
-
-@interface DownloadShelfContextMenuBridge(Private)
-- (void)performAction:(id)sender;
-- (NSMenu*)menu;
-@end
-
-@implementation DownloadShelfContextMenuBridge
-
-- (DownloadShelfContextMenuBridge*)initWithModel:(BaseDownloadItemModel*)model {
- if ((self = [super init]) == nil) {
- return nil;
- }
- contextMenu_.reset(new DownloadShelfContextMenuMac(model, self));
- return self;
-}
-
-@end
-
-@implementation DownloadShelfContextMenuBridge(Private)
-
-- (void)performAction:(id)sender {
- contextMenu_->ExecuteItemCommand([sender tag]);
-}
-
-- (NSMenu*)menu {
- return contextMenu_->GetCocoaMenu();
-}
-
-@end
-
// DownloadItemMac -------------------------------------------------------------
DownloadItemMac::DownloadItemMac(BaseDownloadItemModel* download_model,
- NSRect frame,
- DownloadShelfController* parent)
- : download_model_(download_model), parent_(parent) {
+ DownloadItemController* controller)
+ : download_model_(download_model), item_controller_(controller) {
download_model_->download()->AddObserver(this);
-
- // TODO(thakis): The windows version of this does all kinds of things
- // (gratituous use of animation, special handling of dangerous downloads)
- // that we don't currently do.
-
- scoped_nsobject<NSPopUpButton> view(
- [[NSPopUpButton alloc] initWithFrame:frame pullsDown:YES]);
- [parent_ addDownloadItem:view.get()];
-
- FilePath download_path = download_model->download()->GetFileName();
-
- // TODO(thakis): use filename eliding like gtk/windows versions
- NSString* titleString = base::SysWideToNSString(
- download_path.ToWStringHack());
-
- menu_.reset([[DownloadShelfContextMenuBridge alloc]
- initWithModel:download_model_.get()]);
- [view.get() setMenu:[menu_.get() menu]];
-
- [view.get() insertItemWithTitle:titleString atIndex:0];
-
- NSString* extension = base::SysUTF8ToNSString(download_path.Extension());
- [[view.get() itemAtIndex:0] setImage:
- [[NSWorkspace sharedWorkspace] iconForFileType:extension]];
}
DownloadItemMac::~DownloadItemMac() {
@@ -152,12 +22,5 @@ DownloadItemMac::~DownloadItemMac() {
void DownloadItemMac::OnDownloadUpdated(DownloadItem* download) {
DCHECK_EQ(download, download_model_->download());
- std::wstring status_text = download_model_->GetStatusText();
- // Remove the status text label.
- if (status_text.empty()) {
- // TODO(thakis): Once there is a status label, hide it here
- return;
- }
-
- // TODO(thakis): Set status_text as status label
+ [item_controller_ setStateFromDownload:download_model_.get()];
}
diff --git a/chrome/browser/cocoa/download_shelf_controller.h b/chrome/browser/cocoa/download_shelf_controller.h
index 58241c6..c1beb69 100644
--- a/chrome/browser/cocoa/download_shelf_controller.h
+++ b/chrome/browser/cocoa/download_shelf_controller.h
@@ -4,10 +4,13 @@
#import <Cocoa/Cocoa.h>
+#include "base/scoped_nsobject.h"
#include "base/scoped_ptr.h"
+class BaseDownloadItemModel;
class Browser;
@class BrowserWindowController;
+@class DownloadItemController;
class DownloadShelf;
@class DownloadShelfView;
@@ -17,19 +20,21 @@ class DownloadShelf;
@private
IBOutlet NSTextView* showAllDownloadsLink_;
- // Currently these two are always the same, but they mean slightly
- // different things. contentAreaHasOffset_ is an implementation
- // detail of download shelf visibility.
+ // Currently these two are always the same, but they mean slightly different
+ // things. |contentAreaHasOffset_| is an implementation detail of the download
+ // shelf visibility.
BOOL contentAreaHasOffset_;
BOOL barIsVisible_;
scoped_ptr<DownloadShelf> bridge_;
NSView* contentArea_;
int shelfHeight_;
+
+ // The download items we have added to our shelf.
+ scoped_nsobject<NSMutableArray> downloadItemControllers_;
};
-- (id)initWithBrowser:(Browser*)browser
- contentArea:(NSView*)content;
+- (id)initWithBrowser:(Browser*)browser contentArea:(NSView*)content;
- (DownloadShelf*)bridge;
- (BOOL)isVisible;
@@ -37,9 +42,7 @@ class DownloadShelf;
- (IBAction)show:(id)sender;
- (IBAction)hide:(id)sender;
-// TODO(thakis): this should internally build an item and get only
-// the model as parameter.
-- (void)addDownloadItem:(NSView*)view;
+- (void)addDownloadItem:(BaseDownloadItemModel*)model;
// Resizes the download shelf based on the state of the content area.
- (void)resizeDownloadShelf;
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm
index da0d199..a8ebd5c 100644
--- a/chrome/browser/cocoa/download_shelf_controller.mm
+++ b/chrome/browser/cocoa/download_shelf_controller.mm
@@ -2,17 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import "download_shelf_controller.h"
+#import "chrome/browser/cocoa/download_shelf_controller.h"
#include "app/l10n_util.h"
#include "base/mac_util.h"
#include "base/sys_string_conversions.h"
#import "chrome/browser/cocoa/browser_window_controller.h"
#include "chrome/browser/cocoa/browser_window_cocoa.h"
+#include "chrome/browser/cocoa/download_item_controller.h"
#include "chrome/browser/cocoa/download_shelf_mac.h"
#import "chrome/browser/cocoa/download_shelf_view.h"
#include "grit/generated_resources.h"
+namespace {
+
+// TODO(thakis): These are all temporary until there's a download item view.
+
+// Border padding of a download item.
+const int kDownloadItemBorderPadding = 4;
+
+// Width of a download item.
+const int kDownloadItemWidth = 200;
+
+// Height of a download item.
+const int kDownloadItemHeight = 32;
+
+// Horizontal padding between two download items.
+const int kDownloadItemPadding = 10;
+
+} // namespace
@interface DownloadShelfController(Private)
- (void)applyContentAreaOffset:(BOOL)apply;
@@ -33,6 +51,8 @@
[self positionBar];
[[[contentArea_ window] contentView] addSubview:[self view]];
+ downloadItemControllers_.reset([[NSMutableArray alloc] init]);
+
// This calls show:, so it needs to be last.
bridge_.reset(new DownloadShelfMac(browser, self));
}
@@ -70,18 +90,17 @@
// Initializes the download shelf at the bottom edge of |contentArea_|.
- (void)positionBar {
- // Set the bar's height to zero and position it at the bottom of the
- // content area, within the window's content view (as opposed to the
- // tab strip, which is a sibling). We'll enlarge it and slide the
- // content area up when we need to show this strip.
+ // Set the bar's height to zero and position it at the bottom of the content
+ // area, within the window's content view (as opposed to the tab strip, which
+ // is a sibling). We'll enlarge it and slide the content area up when we need
+ // to show this strip.
NSRect contentFrame = [contentArea_ frame];
- NSRect barFrame = NSMakeRect(0, 0,
- contentFrame.size.width, shelfHeight_);
+ NSRect barFrame = NSMakeRect(0, 0, contentFrame.size.width, shelfHeight_);
[[self view] setFrame:barFrame];
}
-// Called when the contentArea's frame changes. Enlarge the view to
-// stay with the bottom of the contentArea.
+// Called when the contentArea's frame changes. Enlarge the view to stay with
+// the bottom of the contentArea.
- (void)resizeDownloadShelf {
NSRect barFrame = [[self view] frame];
barFrame.origin.y = 0;
@@ -102,10 +121,9 @@
barIsVisible_ = enable;
}
-// Apply a contents box offset to make (or remove) room for the
-// download shelf. If apply==YES, always make room (the contentView_ is
-// "full size"). If apply==NO we are trying to undo an offset. If no
-// offset there is nothing to undo.
+// Apply a contents box offset to make (or remove) room for the download shelf.
+// If apply is YES, always make room (the contentView_ is "full size"). If apply
+// is NO, we are trying to undo an offset. If no offset there is nothing to undo.
- (void)applyContentAreaOffset:(BOOL)apply {
if (!contentAreaHasOffset_ && apply) {
// There is no offset to unconditionally apply.
@@ -142,8 +160,23 @@
[self showDownloadShelf:NO];
}
-- (void)addDownloadItem:(NSView*)view {
- [[self view] addSubview:view];
+- (void)addDownloadItem:(BaseDownloadItemModel*)model {
+ // TODO(thakis): we need to delete these at some point. There's no explicit
+ // mass delete on windows, figure out where they do it.
+
+ // TODO(thakis): RTL support?
+ // (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
+ int startX = kDownloadItemBorderPadding +
+ (kDownloadItemWidth + kDownloadItemPadding) *
+ [downloadItemControllers_ count];
+
+ NSRect position = NSMakeRect(startX, kDownloadItemBorderPadding,
+ kDownloadItemWidth, kDownloadItemHeight);
+ scoped_nsobject<DownloadItemController> controller(
+ [[DownloadItemController alloc] initWithFrame:position model:model]);
+ [downloadItemControllers_ addObject:controller.get()];
+
+ [[self view] addSubview:[controller.get() view]];
}
@end
diff --git a/chrome/browser/cocoa/download_shelf_mac.h b/chrome/browser/cocoa/download_shelf_mac.h
index 2959fe5..61736c1 100644
--- a/chrome/browser/cocoa/download_shelf_mac.h
+++ b/chrome/browser/cocoa/download_shelf_mac.h
@@ -35,9 +35,6 @@ class DownloadShelfMac : public DownloadShelf {
virtual void Close();
private:
- // The download items we have added to our shelf.
- std::vector<DownloadItemMac*> download_items_;
-
DownloadShelfController* shelf_controller_; // weak, owns us
};
diff --git a/chrome/browser/cocoa/download_shelf_mac.mm b/chrome/browser/cocoa/download_shelf_mac.mm
index 18fca59..f18377e 100644
--- a/chrome/browser/cocoa/download_shelf_mac.mm
+++ b/chrome/browser/cocoa/download_shelf_mac.mm
@@ -8,24 +8,6 @@
#include "chrome/browser/cocoa/download_item_mac.h"
#include "chrome/browser/download/download_item_model.h"
-namespace {
-
-// TODO(thakis): These are all temporary until there's a download item view
-
-// Border padding of a download item
-const int kDownloadItemBorderPadding = 4;
-
-// Width of a download item
-const int kDownloadItemWidth = 200;
-
-// Height of a download item
-const int kDownloadItemHeight = 32;
-
-// Horizontal padding between two download items
-const int kDownloadItemPadding = 10;
-
-} // namespace
-
DownloadShelfMac::DownloadShelfMac(Browser* browser,
DownloadShelfController* controller)
: DownloadShelf(browser),
@@ -34,20 +16,7 @@ DownloadShelfMac::DownloadShelfMac(Browser* browser,
}
void DownloadShelfMac::AddDownload(BaseDownloadItemModel* download_model) {
-
- // TODO(thakis): we need to delete these at some point. There's no explicit
- // mass delete on windows, figure out where they do it.
-
- // TODO(thakis): This should just forward to the controller.
-
- // TODO(thakis): RTL support?
- int startX = kDownloadItemBorderPadding +
- (kDownloadItemWidth + kDownloadItemPadding) * download_items_.size();
- download_items_.push_back(new DownloadItemMac(download_model,
- NSMakeRect(startX, kDownloadItemBorderPadding,
- kDownloadItemWidth, kDownloadItemHeight),
- shelf_controller_));
-
+ [shelf_controller_ addDownloadItem:download_model];
Show();
}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index d8d1859..26cd2a7 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -750,6 +750,8 @@
'browser/cocoa/command_observer_bridge.mm',
'browser/cocoa/custom_home_pages_model.h',
'browser/cocoa/custom_home_pages_model.mm',
+ 'browser/cocoa/download_item_controller.h',
+ 'browser/cocoa/download_item_controller.mm',
'browser/cocoa/download_item_mac.h',
'browser/cocoa/download_item_mac.mm',
'browser/cocoa/download_shelf_controller.h',
@@ -2450,6 +2452,7 @@
'app/nibs/en.lproj/About.xib',
'app/nibs/en.lproj/BrowserWindow.xib',
'app/nibs/en.lproj/ClearBrowsingData.xib',
+ 'app/nibs/en.lproj/DownloadItem.xib',
'app/nibs/en.lproj/DownloadShelf.xib',
'app/nibs/en.lproj/FindBar.xib',
'app/nibs/en.lproj/FirstRunDialog.xib',