| 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 #import "chrome/browser/cocoa/download_shelf_controller.h" | 5 #import "chrome/browser/cocoa/download_shelf_controller.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 - (BOOL)isVisible { | 171 - (BOOL)isVisible { |
| 172 return barIsVisible_; | 172 return barIsVisible_; |
| 173 } | 173 } |
| 174 | 174 |
| 175 - (void)show:(id)sender { | 175 - (void)show:(id)sender { |
| 176 [self showDownloadShelf:YES]; | 176 [self showDownloadShelf:YES]; |
| 177 } | 177 } |
| 178 | 178 |
| 179 - (void)hide:(id)sender { | 179 - (void)hide:(id)sender { |
| 180 [self showDownloadShelf:NO]; | 180 // If |sender| isn't nil, then we're being closed from the UI by the user and |
| 181 // we need to tell our shelf implementation to close. Otherwise, we're being |
| 182 // closed programmatically by our shelf implementation. |
| 183 if (sender) |
| 184 bridge_->Close(); |
| 185 else |
| 186 [self showDownloadShelf:NO]; |
| 187 } |
| 188 |
| 189 - (float)height { |
| 190 return shelfHeight_; |
| 181 } | 191 } |
| 182 | 192 |
| 183 - (void)addDownloadItem:(BaseDownloadItemModel*)model { | 193 - (void)addDownloadItem:(BaseDownloadItemModel*)model { |
| 184 // TODO(thakis): we need to delete these at some point. There's no explicit | 194 // TODO(thakis): we need to delete these at some point. There's no explicit |
| 185 // mass delete on windows, figure out where they do it. | 195 // mass delete on windows, figure out where they do it. |
| 186 | 196 |
| 187 // TODO(thakis): RTL support? | 197 // TODO(thakis): RTL support? |
| 188 // (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 198 // (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) |
| 189 int startX = kDownloadItemBorderPadding + | 199 int startX = kDownloadItemBorderPadding + |
| 190 (kDownloadItemWidth + kDownloadItemPadding) * | 200 (kDownloadItemWidth + kDownloadItemPadding) * |
| 191 [downloadItemControllers_ count]; | 201 [downloadItemControllers_ count]; |
| 192 | 202 |
| 193 NSRect position = NSMakeRect(startX, kDownloadItemBorderPadding, | 203 NSRect position = NSMakeRect(startX, kDownloadItemBorderPadding, |
| 194 kDownloadItemWidth, kDownloadItemHeight); | 204 kDownloadItemWidth, kDownloadItemHeight); |
| 195 scoped_nsobject<DownloadItemController> controller( | 205 scoped_nsobject<DownloadItemController> controller( |
| 196 [[DownloadItemController alloc] initWithFrame:position | 206 [[DownloadItemController alloc] initWithFrame:position |
| 197 model:model | 207 model:model |
| 198 shelf:self]); | 208 shelf:self]); |
| 199 [downloadItemControllers_ addObject:controller.get()]; | 209 [downloadItemControllers_ addObject:controller.get()]; |
| 200 | 210 |
| 201 [[self view] addSubview:[controller.get() view]]; | 211 [[self view] addSubview:[controller.get() view]]; |
| 202 } | 212 } |
| 203 | 213 |
| 204 @end | 214 @end |
| OLD | NEW |