Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/ui/cocoa/download/download_item_controller.mm

Issue 10421021: Make DownloadProtectionService not use BrowserList::GetLastActive() to load a link. Instead pass th… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string16.h" 10 #include "base/string16.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/download/chrome_download_manager_delegate.h" 14 #include "chrome/browser/download/chrome_download_manager_delegate.h"
15 #include "chrome/browser/download/download_item_model.h" 15 #include "chrome/browser/download/download_item_model.h"
16 #include "chrome/browser/download/download_shelf_context_menu.h" 16 #include "chrome/browser/download/download_shelf_context_menu.h"
17 #include "chrome/browser/download/download_util.h" 17 #include "chrome/browser/download/download_util.h"
18 #import "chrome/browser/themes/theme_service.h" 18 #import "chrome/browser/themes/theme_service.h"
19 #import "chrome/browser/ui/cocoa/download/download_item_button.h" 19 #import "chrome/browser/ui/cocoa/download/download_item_button.h"
20 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" 20 #import "chrome/browser/ui/cocoa/download/download_item_cell.h"
21 #include "chrome/browser/ui/cocoa/download/download_item_mac.h" 21 #include "chrome/browser/ui/cocoa/download/download_item_mac.h"
22 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" 22 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
23 #import "chrome/browser/ui/cocoa/themed_window.h" 23 #import "chrome/browser/ui/cocoa/themed_window.h"
24 #import "chrome/browser/ui/cocoa/ui_localizer.h" 24 #import "chrome/browser/ui/cocoa/ui_localizer.h"
25 #include "content/public/browser/download_item.h" 25 #include "content/public/browser/download_item.h"
26 #include "content/public/browser/page_navigator.h"
26 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
27 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
28 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 29 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
29 #include "ui/base/l10n/l10n_util_mac.h" 30 #include "ui/base/l10n/l10n_util_mac.h"
30 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/base/text/text_elider.h" 32 #include "ui/base/text/text_elider.h"
32 #include "ui/gfx/font.h" 33 #include "ui/gfx/font.h"
33 #include "ui/gfx/image/image.h" 34 #include "ui/gfx/image/image.h"
34 35
35 using content::DownloadItem; 36 using content::DownloadItem;
(...skipping 30 matching lines...) Expand all
66 [contentView setAutoresizesSubviews:YES]; 67 [contentView setAutoresizesSubviews:YES];
67 } 68 }
68 } 69 }
69 70
70 } // namespace 71 } // namespace
71 72
72 // A class for the chromium-side part of the download shelf context menu. 73 // A class for the chromium-side part of the download shelf context menu.
73 74
74 class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { 75 class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
75 public: 76 public:
76 DownloadShelfContextMenuMac(BaseDownloadItemModel* model) 77 DownloadShelfContextMenuMac(BaseDownloadItemModel* model,
77 : DownloadShelfContextMenu(model) { } 78 content::PageNavigator* navigator)
79 : DownloadShelfContextMenu(model, navigator) { }
78 80
79 using DownloadShelfContextMenu::ExecuteCommand; 81 using DownloadShelfContextMenu::ExecuteCommand;
80 using DownloadShelfContextMenu::IsCommandIdChecked; 82 using DownloadShelfContextMenu::IsCommandIdChecked;
81 using DownloadShelfContextMenu::IsCommandIdEnabled; 83 using DownloadShelfContextMenu::IsCommandIdEnabled;
82 84
83 using DownloadShelfContextMenu::SHOW_IN_FOLDER; 85 using DownloadShelfContextMenu::SHOW_IN_FOLDER;
84 using DownloadShelfContextMenu::OPEN_WHEN_COMPLETE; 86 using DownloadShelfContextMenu::OPEN_WHEN_COMPLETE;
85 using DownloadShelfContextMenu::ALWAYS_OPEN_TYPE; 87 using DownloadShelfContextMenu::ALWAYS_OPEN_TYPE;
86 using DownloadShelfContextMenu::CANCEL; 88 using DownloadShelfContextMenu::CANCEL;
87 using DownloadShelfContextMenu::TOGGLE_PAUSE; 89 using DownloadShelfContextMenu::TOGGLE_PAUSE;
88 }; 90 };
89 91
90 @interface DownloadItemController (Private) 92 @interface DownloadItemController (Private)
91 - (void)themeDidChangeNotification:(NSNotification*)aNotification; 93 - (void)themeDidChangeNotification:(NSNotification*)aNotification;
92 - (void)updateTheme:(ui::ThemeProvider*)themeProvider; 94 - (void)updateTheme:(ui::ThemeProvider*)themeProvider;
93 - (void)setState:(DownoadItemState)state; 95 - (void)setState:(DownoadItemState)state;
94 @end 96 @end
95 97
96 // Implementation of DownloadItemController 98 // Implementation of DownloadItemController
97 99
98 @implementation DownloadItemController 100 @implementation DownloadItemController
99 101
100 - (id)initWithModel:(BaseDownloadItemModel*)downloadModel 102 - (id)initWithModel:(BaseDownloadItemModel*)downloadModel
101 shelf:(DownloadShelfController*)shelf { 103 shelf:(DownloadShelfController*)shelf
104 navigator:(content::PageNavigator*)navigator {
102 if ((self = [super initWithNibName:@"DownloadItem" 105 if ((self = [super initWithNibName:@"DownloadItem"
103 bundle:base::mac::FrameworkBundle()])) { 106 bundle:base::mac::FrameworkBundle()])) {
104 // Must be called before [self view], so that bridge_ is set in awakeFromNib 107 // Must be called before [self view], so that bridge_ is set in awakeFromNib
105 bridge_.reset(new DownloadItemMac(downloadModel, self)); 108 bridge_.reset(new DownloadItemMac(downloadModel, self));
106 menuBridge_.reset(new DownloadShelfContextMenuMac(downloadModel)); 109 menuBridge_.reset(new DownloadShelfContextMenuMac(downloadModel,
110 navigator));
107 111
108 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; 112 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
109 [defaultCenter addObserver:self 113 [defaultCenter addObserver:self
110 selector:@selector(themeDidChangeNotification:) 114 selector:@selector(themeDidChangeNotification:)
111 name:kBrowserThemeDidChangeNotification 115 name:kBrowserThemeDidChangeNotification
112 object:nil]; 116 object:nil];
113 117
114 shelf_ = shelf; 118 shelf_ = shelf;
115 state_ = kNormal; 119 state_ = kNormal;
116 creationTime_ = base::Time::Now(); 120 creationTime_ = base::Time::Now();
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 [sender setTitle:l10n_util::GetNSStringWithFixup( 371 [sender setTitle:l10n_util::GetNSStringWithFixup(
368 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; 372 IDS_DOWNLOAD_MENU_PAUSE_ITEM)];
369 } else { 373 } else {
370 [sender setTitle:l10n_util::GetNSStringWithFixup( 374 [sender setTitle:l10n_util::GetNSStringWithFixup(
371 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; 375 IDS_DOWNLOAD_MENU_RESUME_ITEM)];
372 } 376 }
373 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); 377 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE);
374 } 378 }
375 379
376 @end 380 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698