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

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

Issue 8503018: Split DownloadItem into an ABC, an Impl, and a Mock. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: CamelCase Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 [buttonTweaker_ setFrameOrigin:frameOrigin]; 155 [buttonTweaker_ setFrameOrigin:frameOrigin];
156 156
157 bridge_->LoadIcon(); 157 bridge_->LoadIcon();
158 [self updateToolTip]; 158 [self updateToolTip];
159 } 159 }
160 160
161 - (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel { 161 - (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel {
162 DCHECK_EQ(bridge_->download_model(), downloadModel); 162 DCHECK_EQ(bridge_->download_model(), downloadModel);
163 163
164 // Handle dangerous downloads. 164 // Handle dangerous downloads.
165 if (downloadModel->download()->safety_state() == DownloadItem::DANGEROUS) { 165 if (downloadModel->download()->GetSafetyState() == DownloadItem::DANGEROUS) {
166 [self setState:kDangerous]; 166 [self setState:kDangerous];
167 167
168 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 168 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
169 NSString* dangerousWarning; 169 NSString* dangerousWarning;
170 NSString* confirmButtonTitle; 170 NSString* confirmButtonTitle;
171 NSImage* alertIcon; 171 NSImage* alertIcon;
172 172
173 // The dangerous download label, button text and icon are different under 173 // The dangerous download label, button text and icon are different under
174 // different cases. 174 // different cases.
175 if (downloadModel->download()->GetDangerType() == 175 if (downloadModel->download()->GetDangerType() ==
(...skipping 12 matching lines...) Expand all
188 if (ChromeDownloadManagerDelegate::IsExtensionDownload( 188 if (ChromeDownloadManagerDelegate::IsExtensionDownload(
189 downloadModel->download())) { 189 downloadModel->download())) {
190 dangerousWarning = l10n_util::GetNSStringWithFixup( 190 dangerousWarning = l10n_util::GetNSStringWithFixup(
191 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); 191 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION);
192 confirmButtonTitle = l10n_util::GetNSStringWithFixup( 192 confirmButtonTitle = l10n_util::GetNSStringWithFixup(
193 IDS_CONTINUE_EXTENSION_DOWNLOAD); 193 IDS_CONTINUE_EXTENSION_DOWNLOAD);
194 } else { 194 } else {
195 // This basic fixup copies Windows DownloadItemView::DownloadItemView(). 195 // This basic fixup copies Windows DownloadItemView::DownloadItemView().
196 196
197 // Extract the file extension (if any). 197 // Extract the file extension (if any).
198 FilePath filename(downloadModel->download()->target_name()); 198 FilePath filename(downloadModel->download()->GetTargetName());
199 FilePath::StringType extension = filename.Extension(); 199 FilePath::StringType extension = filename.Extension();
200 200
201 // Remove leading '.' from the extension 201 // Remove leading '.' from the extension
202 if (extension.length() > 0) 202 if (extension.length() > 0)
203 extension = extension.substr(1); 203 extension = extension.substr(1);
204 204
205 // Elide giant extensions. 205 // Elide giant extensions.
206 if (extension.length() > kFileNameMaxLength / 2) { 206 if (extension.length() > kFileNameMaxLength / 2) {
207 string16 utf16_extension; 207 string16 utf16_extension;
208 ui::ElideString(UTF8ToUTF16(extension), kFileNameMaxLength / 2, 208 ui::ElideString(UTF8ToUTF16(extension), kFileNameMaxLength / 2,
(...skipping 20 matching lines...) Expand all
229 DCHECK(dangerousWarning); 229 DCHECK(dangerousWarning);
230 [dangerousDownloadLabel_ setStringValue:dangerousWarning]; 230 [dangerousDownloadLabel_ setStringValue:dangerousWarning];
231 DCHECK(confirmButtonTitle); 231 DCHECK(confirmButtonTitle);
232 [dangerousDownloadConfirmButton_ setTitle:confirmButtonTitle]; 232 [dangerousDownloadConfirmButton_ setTitle:confirmButtonTitle];
233 return; 233 return;
234 } 234 }
235 235
236 // Set correct popup menu. Also, set draggable download on completion. 236 // Set correct popup menu. Also, set draggable download on completion.
237 if (downloadModel->download()->IsComplete()) { 237 if (downloadModel->download()->IsComplete()) {
238 [progressView_ setMenu:completeDownloadMenu_]; 238 [progressView_ setMenu:completeDownloadMenu_];
239 [progressView_ setDownload:downloadModel->download()->full_path()]; 239 [progressView_ setDownload:downloadModel->download()->GetFullPath()];
240 } else { 240 } else {
241 [progressView_ setMenu:activeDownloadMenu_]; 241 [progressView_ setMenu:activeDownloadMenu_];
242 } 242 }
243 243
244 [cell_ setStateFromDownload:downloadModel]; 244 [cell_ setStateFromDownload:downloadModel];
245 } 245 }
246 246
247 - (void)setIcon:(NSImage*)icon { 247 - (void)setIcon:(NSImage*)icon {
248 [cell_ setImage:icon]; 248 [cell_ setImage:icon];
249 } 249 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 [sender setTitle:l10n_util::GetNSStringWithFixup( 412 [sender setTitle:l10n_util::GetNSStringWithFixup(
413 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; 413 IDS_DOWNLOAD_MENU_PAUSE_ITEM)];
414 } else { 414 } else {
415 [sender setTitle:l10n_util::GetNSStringWithFixup( 415 [sender setTitle:l10n_util::GetNSStringWithFixup(
416 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; 416 IDS_DOWNLOAD_MENU_RESUME_ITEM)];
417 } 417 }
418 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); 418 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE);
419 } 419 }
420 420
421 @end 421 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698