| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/cocoa/download_shelf_mac.h" | 5 #include "chrome/browser/cocoa/download_shelf_mac.h" |
| 6 | 6 |
| 7 #import "chrome/browser/cocoa/download_shelf_controller.h" | 7 #import "chrome/browser/cocoa/download_shelf_controller.h" |
| 8 #include "chrome/browser/cocoa/download_item_mac.h" | 8 #include "chrome/browser/cocoa/download_item_mac.h" |
| 9 #include "chrome/browser/download/download_item_model.h" | 9 #include "chrome/browser/download/download_item_model.h" |
| 10 | 10 |
| 11 namespace { | |
| 12 | |
| 13 // TODO(thakis): These are all temporary until there's a download item view | |
| 14 | |
| 15 // Border padding of a download item | |
| 16 const int kDownloadItemBorderPadding = 4; | |
| 17 | |
| 18 // Width of a download item | |
| 19 const int kDownloadItemWidth = 200; | |
| 20 | |
| 21 // Height of a download item | |
| 22 const int kDownloadItemHeight = 32; | |
| 23 | |
| 24 // Horizontal padding between two download items | |
| 25 const int kDownloadItemPadding = 10; | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 DownloadShelfMac::DownloadShelfMac(Browser* browser, | 11 DownloadShelfMac::DownloadShelfMac(Browser* browser, |
| 30 DownloadShelfController* controller) | 12 DownloadShelfController* controller) |
| 31 : DownloadShelf(browser), | 13 : DownloadShelf(browser), |
| 32 shelf_controller_(controller) { | 14 shelf_controller_(controller) { |
| 33 Show(); | 15 Show(); |
| 34 } | 16 } |
| 35 | 17 |
| 36 void DownloadShelfMac::AddDownload(BaseDownloadItemModel* download_model) { | 18 void DownloadShelfMac::AddDownload(BaseDownloadItemModel* download_model) { |
| 37 | 19 [shelf_controller_ addDownloadItem:download_model]; |
| 38 // TODO(thakis): we need to delete these at some point. There's no explicit | |
| 39 // mass delete on windows, figure out where they do it. | |
| 40 | |
| 41 // TODO(thakis): This should just forward to the controller. | |
| 42 | |
| 43 // TODO(thakis): RTL support? | |
| 44 int startX = kDownloadItemBorderPadding + | |
| 45 (kDownloadItemWidth + kDownloadItemPadding) * download_items_.size(); | |
| 46 download_items_.push_back(new DownloadItemMac(download_model, | |
| 47 NSMakeRect(startX, kDownloadItemBorderPadding, | |
| 48 kDownloadItemWidth, kDownloadItemHeight), | |
| 49 shelf_controller_)); | |
| 50 | |
| 51 Show(); | 20 Show(); |
| 52 } | 21 } |
| 53 | 22 |
| 54 bool DownloadShelfMac::IsShowing() const { | 23 bool DownloadShelfMac::IsShowing() const { |
| 55 return [shelf_controller_ isVisible] == YES; | 24 return [shelf_controller_ isVisible] == YES; |
| 56 } | 25 } |
| 57 | 26 |
| 58 bool DownloadShelfMac::IsClosing() const { | 27 bool DownloadShelfMac::IsClosing() const { |
| 59 // TODO(estade): This is never called. For now just return false. | 28 // TODO(estade): This is never called. For now just return false. |
| 60 return false; | 29 return false; |
| 61 } | 30 } |
| 62 | 31 |
| 63 void DownloadShelfMac::Show() { | 32 void DownloadShelfMac::Show() { |
| 64 [shelf_controller_ show:nil]; | 33 [shelf_controller_ show:nil]; |
| 65 } | 34 } |
| 66 | 35 |
| 67 void DownloadShelfMac::Close() { | 36 void DownloadShelfMac::Close() { |
| 68 [shelf_controller_ hide:nil]; | 37 [shelf_controller_ hide:nil]; |
| 69 } | 38 } |
| OLD | NEW |