| 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" |
| 11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 13 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 14 #include "chrome/browser/download/download_item_model.h" | 14 #include "chrome/browser/download/download_item_model.h" |
| 15 #include "chrome/browser/download/download_shelf_context_menu.h" | 15 #include "chrome/browser/download/download_shelf_context_menu.h" |
| 16 #include "chrome/browser/download/download_util.h" | 16 #include "chrome/browser/download/download_util.h" |
| 17 #import "chrome/browser/themes/theme_service.h" | 17 #import "chrome/browser/themes/theme_service.h" |
| 18 #import "chrome/browser/ui/cocoa/download/download_item_button.h" | 18 #import "chrome/browser/ui/cocoa/download/download_item_button.h" |
| 19 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" | 19 #import "chrome/browser/ui/cocoa/download/download_item_cell.h" |
| 20 #include "chrome/browser/ui/cocoa/download/download_item_mac.h" | 20 #include "chrome/browser/ui/cocoa/download/download_item_mac.h" |
| 21 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 21 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
| 22 #import "chrome/browser/ui/cocoa/themed_window.h" | 22 #import "chrome/browser/ui/cocoa/themed_window.h" |
| 23 #import "chrome/browser/ui/cocoa/ui_localizer.h" | 23 #import "chrome/browser/ui/cocoa/ui_localizer.h" |
| 24 #include "content/browser/download/download_item.h" | 24 #include "content/browser/download/download_item.h" |
| 25 #include "content/browser/download/download_state_info.h" |
| 25 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 26 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 27 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 28 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
| 28 #include "ui/base/l10n/l10n_util_mac.h" | 29 #include "ui/base/l10n/l10n_util_mac.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/base/text/text_elider.h" | 31 #include "ui/base/text/text_elider.h" |
| 31 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 [self setState:kDangerous]; | 167 [self setState:kDangerous]; |
| 167 | 168 |
| 168 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 169 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 169 NSString* dangerousWarning; | 170 NSString* dangerousWarning; |
| 170 NSString* confirmButtonTitle; | 171 NSString* confirmButtonTitle; |
| 171 NSImage* alertIcon; | 172 NSImage* alertIcon; |
| 172 | 173 |
| 173 // The dangerous download label, button text and icon are different under | 174 // The dangerous download label, button text and icon are different under |
| 174 // different cases. | 175 // different cases. |
| 175 if (downloadModel->download()->GetDangerType() == | 176 if (downloadModel->download()->GetDangerType() == |
| 176 DownloadItem::DANGEROUS_URL) { | 177 DownloadStateInfo::DANGEROUS_URL) { |
| 177 // Safebrowsing shows the download URL leads to malicious file. | 178 // Safebrowsing shows the download URL leads to malicious file. |
| 178 alertIcon = rb.GetNativeImageNamed(IDR_SAFEBROWSING_WARNING); | 179 alertIcon = rb.GetNativeImageNamed(IDR_SAFEBROWSING_WARNING); |
| 179 dangerousWarning = l10n_util::GetNSStringWithFixup( | 180 dangerousWarning = l10n_util::GetNSStringWithFixup( |
| 180 IDS_PROMPT_UNSAFE_DOWNLOAD_URL); | 181 IDS_PROMPT_UNSAFE_DOWNLOAD_URL); |
| 181 confirmButtonTitle = l10n_util::GetNSStringWithFixup( | 182 confirmButtonTitle = l10n_util::GetNSStringWithFixup( |
| 182 IDS_CONFIRM_DOWNLOAD); | 183 IDS_CONFIRM_DOWNLOAD); |
| 183 } else { | 184 } else { |
| 184 // It's a dangerous file type (e.g.: an executable). | 185 // It's a dangerous file type (e.g.: an executable). |
| 185 DCHECK_EQ(downloadModel->download()->GetDangerType(), | 186 DCHECK_EQ(downloadModel->download()->GetDangerType(), |
| 186 DownloadItem::DANGEROUS_FILE); | 187 DownloadStateInfo::DANGEROUS_FILE); |
| 187 alertIcon = rb.GetNativeImageNamed(IDR_WARNING); | 188 alertIcon = rb.GetNativeImageNamed(IDR_WARNING); |
| 188 if (ChromeDownloadManagerDelegate::IsExtensionDownload( | 189 if (ChromeDownloadManagerDelegate::IsExtensionDownload( |
| 189 downloadModel->download())) { | 190 downloadModel->download())) { |
| 190 dangerousWarning = l10n_util::GetNSStringWithFixup( | 191 dangerousWarning = l10n_util::GetNSStringWithFixup( |
| 191 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); | 192 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); |
| 192 confirmButtonTitle = l10n_util::GetNSStringWithFixup( | 193 confirmButtonTitle = l10n_util::GetNSStringWithFixup( |
| 193 IDS_CONTINUE_EXTENSION_DOWNLOAD); | 194 IDS_CONTINUE_EXTENSION_DOWNLOAD); |
| 194 } else { | 195 } else { |
| 195 // This basic fixup copies Windows DownloadItemView::DownloadItemView(). | 196 // This basic fixup copies Windows DownloadItemView::DownloadItemView(). |
| 196 | 197 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 [sender setTitle:l10n_util::GetNSStringWithFixup( | 413 [sender setTitle:l10n_util::GetNSStringWithFixup( |
| 413 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; | 414 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; |
| 414 } else { | 415 } else { |
| 415 [sender setTitle:l10n_util::GetNSStringWithFixup( | 416 [sender setTitle:l10n_util::GetNSStringWithFixup( |
| 416 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; | 417 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; |
| 417 } | 418 } |
| 418 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); | 419 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); |
| 419 } | 420 } |
| 420 | 421 |
| 421 @end | 422 @end |
| OLD | NEW |