| OLD | NEW |
| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 [buttonTweaker_ setFrameOrigin:frameOrigin]; | 156 [buttonTweaker_ setFrameOrigin:frameOrigin]; |
| 157 | 157 |
| 158 bridge_->LoadIcon(); | 158 bridge_->LoadIcon(); |
| 159 [self updateToolTip]; | 159 [self updateToolTip]; |
| 160 } | 160 } |
| 161 | 161 |
| 162 - (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel { | 162 - (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel { |
| 163 DCHECK_EQ(bridge_->download_model(), downloadModel); | 163 DCHECK_EQ(bridge_->download_model(), downloadModel); |
| 164 | 164 |
| 165 // Handle dangerous downloads. | 165 // Handle dangerous downloads. |
| 166 if (downloadModel->download()->safety_state() == DownloadItem::DANGEROUS) { | 166 if (downloadModel->download()->GetSafetyState() == DownloadItem::DANGEROUS) { |
| 167 [self setState:kDangerous]; | 167 [self setState:kDangerous]; |
| 168 | 168 |
| 169 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 169 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 170 NSString* dangerousWarning; | 170 NSString* dangerousWarning; |
| 171 NSString* confirmButtonTitle; | 171 NSString* confirmButtonTitle; |
| 172 NSImage* alertIcon; | 172 NSImage* alertIcon; |
| 173 | 173 |
| 174 // The dangerous download label, button text and icon are different under | 174 // The dangerous download label, button text and icon are different under |
| 175 // different cases. | 175 // different cases. |
| 176 if (downloadModel->download()->GetDangerType() == | 176 if (downloadModel->download()->GetDangerType() == |
| (...skipping 12 matching lines...) Expand all Loading... |
| 189 if (ChromeDownloadManagerDelegate::IsExtensionDownload( | 189 if (ChromeDownloadManagerDelegate::IsExtensionDownload( |
| 190 downloadModel->download())) { | 190 downloadModel->download())) { |
| 191 dangerousWarning = l10n_util::GetNSStringWithFixup( | 191 dangerousWarning = l10n_util::GetNSStringWithFixup( |
| 192 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); | 192 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); |
| 193 confirmButtonTitle = l10n_util::GetNSStringWithFixup( | 193 confirmButtonTitle = l10n_util::GetNSStringWithFixup( |
| 194 IDS_CONTINUE_EXTENSION_DOWNLOAD); | 194 IDS_CONTINUE_EXTENSION_DOWNLOAD); |
| 195 } else { | 195 } else { |
| 196 // This basic fixup copies Windows DownloadItemView::DownloadItemView(). | 196 // This basic fixup copies Windows DownloadItemView::DownloadItemView(). |
| 197 | 197 |
| 198 // Extract the file extension (if any). | 198 // Extract the file extension (if any). |
| 199 FilePath filename(downloadModel->download()->target_name()); | 199 FilePath filename(downloadModel->download()->GetTargetName()); |
| 200 FilePath::StringType extension = filename.Extension(); | 200 FilePath::StringType extension = filename.Extension(); |
| 201 | 201 |
| 202 // Remove leading '.' from the extension | 202 // Remove leading '.' from the extension |
| 203 if (extension.length() > 0) | 203 if (extension.length() > 0) |
| 204 extension = extension.substr(1); | 204 extension = extension.substr(1); |
| 205 | 205 |
| 206 // Elide giant extensions. | 206 // Elide giant extensions. |
| 207 if (extension.length() > kFileNameMaxLength / 2) { | 207 if (extension.length() > kFileNameMaxLength / 2) { |
| 208 string16 utf16_extension; | 208 string16 utf16_extension; |
| 209 ui::ElideString(UTF8ToUTF16(extension), kFileNameMaxLength / 2, | 209 ui::ElideString(UTF8ToUTF16(extension), kFileNameMaxLength / 2, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 230 DCHECK(dangerousWarning); | 230 DCHECK(dangerousWarning); |
| 231 [dangerousDownloadLabel_ setStringValue:dangerousWarning]; | 231 [dangerousDownloadLabel_ setStringValue:dangerousWarning]; |
| 232 DCHECK(confirmButtonTitle); | 232 DCHECK(confirmButtonTitle); |
| 233 [dangerousDownloadConfirmButton_ setTitle:confirmButtonTitle]; | 233 [dangerousDownloadConfirmButton_ setTitle:confirmButtonTitle]; |
| 234 return; | 234 return; |
| 235 } | 235 } |
| 236 | 236 |
| 237 // Set correct popup menu. Also, set draggable download on completion. | 237 // Set correct popup menu. Also, set draggable download on completion. |
| 238 if (downloadModel->download()->IsComplete()) { | 238 if (downloadModel->download()->IsComplete()) { |
| 239 [progressView_ setMenu:completeDownloadMenu_]; | 239 [progressView_ setMenu:completeDownloadMenu_]; |
| 240 [progressView_ setDownload:downloadModel->download()->full_path()]; | 240 [progressView_ setDownload:downloadModel->download()->GetFullPath()]; |
| 241 } else { | 241 } else { |
| 242 [progressView_ setMenu:activeDownloadMenu_]; | 242 [progressView_ setMenu:activeDownloadMenu_]; |
| 243 } | 243 } |
| 244 | 244 |
| 245 [cell_ setStateFromDownload:downloadModel]; | 245 [cell_ setStateFromDownload:downloadModel]; |
| 246 } | 246 } |
| 247 | 247 |
| 248 - (void)setIcon:(NSImage*)icon { | 248 - (void)setIcon:(NSImage*)icon { |
| 249 [cell_ setImage:icon]; | 249 [cell_ setImage:icon]; |
| 250 } | 250 } |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 [sender setTitle:l10n_util::GetNSStringWithFixup( | 413 [sender setTitle:l10n_util::GetNSStringWithFixup( |
| 414 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; | 414 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; |
| 415 } else { | 415 } else { |
| 416 [sender setTitle:l10n_util::GetNSStringWithFixup( | 416 [sender setTitle:l10n_util::GetNSStringWithFixup( |
| 417 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; | 417 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; |
| 418 } | 418 } |
| 419 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); | 419 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); |
| 420 } | 420 } |
| 421 | 421 |
| 422 @end | 422 @end |
| OLD | NEW |