 Chromium Code Reviews
 Chromium Code Reviews Issue 209613002:
  Download shelf autohides on showing in shell, just same as regular open 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 209613002:
  Download shelf autohides on showing in shell, just same as regular open 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/cocoa/download/download_item_controller.h" | 5 #import "chrome/browser/ui/cocoa/download/download_item_controller.h" | 
| 6 | 6 | 
| 7 #include "base/mac/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" | 
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" | 
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" | 
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" | 
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 | 232 | 
| 233 NSView* view = [self view]; | 233 NSView* view = [self view]; | 
| 234 NSRect containerFrame = [[view superview] frame]; | 234 NSRect containerFrame = [[view superview] frame]; | 
| 235 [view setHidden:(NSMaxX([view frame]) > NSWidth(containerFrame))]; | 235 [view setHidden:(NSMaxX([view frame]) > NSWidth(containerFrame))]; | 
| 236 } | 236 } | 
| 237 | 237 | 
| 238 - (void)downloadWasOpened { | 238 - (void)downloadWasOpened { | 
| 239 [shelf_ downloadWasOpened:self]; | 239 [shelf_ downloadWasOpened:self]; | 
| 240 } | 240 } | 
| 241 | 241 | 
| 242 - (void)downloadWasShown { | |
| 243 [shelf_ downloadWasShown:self]; | |
| 244 } | |
| 245 | |
| 242 - (IBAction)handleButtonClick:(id)sender { | 246 - (IBAction)handleButtonClick:(id)sender { | 
| 243 NSEvent* event = [NSApp currentEvent]; | 247 NSEvent* event = [NSApp currentEvent]; | 
| 244 DownloadItem* download = [self download]; | 248 DownloadItem* download = [self download]; | 
| 245 if ([event modifierFlags] & NSCommandKeyMask) { | 249 if ([event modifierFlags] & NSCommandKeyMask) { | 
| 246 // Let cmd-click show the file in Finder, like e.g. in Safari and Spotlight. | 250 // Let cmd-click show the file in Finder, like e.g. in Safari and Spotlight. | 
| 247 download->ShowDownloadInShell(); | 251 download->ShowDownloadInShell(); | 
| 248 } else { | 252 } else { | 
| 249 download->OpenDownload(); | 253 download->OpenDownload(); | 
| 250 } | 254 } | 
| 251 } | 255 } | 
| 252 | 256 | 
| 253 - (NSSize)preferredSize { | 257 - (NSSize)preferredSize { | 
| 254 if (state_ == kNormal) | 258 if (state_ == kNormal) | 
| 255 return [progressView_ frame].size; | 259 return [progressView_ frame].size; | 
| 256 DCHECK_EQ(kDangerous, state_); | 260 DCHECK_EQ(kDangerous, state_); | 
| 257 return [dangerousDownloadView_ frame].size; | 261 return [dangerousDownloadView_ frame].size; | 
| 258 } | 262 } | 
| 259 | 263 | 
| 260 - (DownloadItem*)download { | 264 - (DownloadItem*)download { | 
| 261 return bridge_->download_model()->download(); | 265 return bridge_->download_model()->download(); | 
| 262 } | 266 } | 
| 263 | 267 | 
| 268 - (DownloadItemModel*)downloadItemModel{ | |
| 269 return bridge_->download_model(); | |
| 
asanka
2014/06/12 21:08:47
This method shouldn't be necessary. If you have a
 | |
| 270 } | |
| 271 | |
| 264 - (ui::MenuModel*)contextMenuModel { | 272 - (ui::MenuModel*)contextMenuModel { | 
| 265 return menuBridge_->GetMenuModel(); | 273 return menuBridge_->GetMenuModel(); | 
| 266 } | 274 } | 
| 267 | 275 | 
| 268 - (void)updateToolTip { | 276 - (void)updateToolTip { | 
| 269 base::string16 tooltip_text = | 277 base::string16 tooltip_text = | 
| 270 bridge_->download_model()->GetTooltipText(*font_list_, kToolTipMaxWidth); | 278 bridge_->download_model()->GetTooltipText(*font_list_, kToolTipMaxWidth); | 
| 271 [progressView_ setToolTip:base::SysUTF16ToNSString(tooltip_text)]; | 279 [progressView_ setToolTip:base::SysUTF16ToNSString(tooltip_text)]; | 
| 272 } | 280 } | 
| 273 | 281 | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 base::scoped_nsobject<DownloadShelfContextMenuController> menuController( | 349 base::scoped_nsobject<DownloadShelfContextMenuController> menuController( | 
| 342 [[DownloadShelfContextMenuController alloc] | 350 [[DownloadShelfContextMenuController alloc] | 
| 343 initWithItemController:self | 351 initWithItemController:self | 
| 344 withDelegate:nil]); | 352 withDelegate:nil]); | 
| 345 [NSMenu popUpContextMenu:[menuController menu] | 353 [NSMenu popUpContextMenu:[menuController menu] | 
| 346 withEvent:[NSApp currentEvent] | 354 withEvent:[NSApp currentEvent] | 
| 347 forView:[self view]]; | 355 forView:[self view]]; | 
| 348 } | 356 } | 
| 349 | 357 | 
| 350 @end | 358 @end | 
| OLD | NEW |