| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 NSImage* alertIcon; | 170 NSImage* alertIcon; |
| 171 | 171 |
| 172 // The dangerous download label, button text and icon are different under | 172 // The dangerous download label, button text and icon are different under |
| 173 // different cases. | 173 // different cases. |
| 174 if (downloadModel->download()->GetDangerType() == | 174 if (downloadModel->download()->GetDangerType() == |
| 175 DownloadItem::DANGEROUS_URL) { | 175 DownloadItem::DANGEROUS_URL) { |
| 176 // Safebrowsing shows the download URL leads to malicious file. | 176 // Safebrowsing shows the download URL leads to malicious file. |
| 177 alertIcon = rb.GetNativeImageNamed(IDR_SAFEBROWSING_WARNING); | 177 alertIcon = rb.GetNativeImageNamed(IDR_SAFEBROWSING_WARNING); |
| 178 dangerousWarning = l10n_util::GetNSStringWithFixup( | 178 dangerousWarning = l10n_util::GetNSStringWithFixup( |
| 179 IDS_PROMPT_UNSAFE_DOWNLOAD_URL); | 179 IDS_PROMPT_UNSAFE_DOWNLOAD_URL); |
| 180 confirmButtonTitle = l10n_util::GetNSStringWithFixup(IDS_SAVE_DOWNLOAD); | 180 confirmButtonTitle = l10n_util::GetNSStringWithFixup( |
| 181 IDS_CONFIRM_DOWNLOAD); |
| 181 } else { | 182 } else { |
| 182 // It's a dangerous file type (e.g.: an executable). | 183 // It's a dangerous file type (e.g.: an executable). |
| 183 DCHECK_EQ(downloadModel->download()->GetDangerType(), | 184 DCHECK_EQ(downloadModel->download()->GetDangerType(), |
| 184 DownloadItem::DANGEROUS_FILE); | 185 DownloadItem::DANGEROUS_FILE); |
| 185 alertIcon = rb.GetNativeImageNamed(IDR_WARNING); | 186 alertIcon = rb.GetNativeImageNamed(IDR_WARNING); |
| 186 if (downloadModel->download()->is_extension_install()) { | 187 if (downloadModel->download()->is_extension_install()) { |
| 187 dangerousWarning = l10n_util::GetNSStringWithFixup( | 188 dangerousWarning = l10n_util::GetNSStringWithFixup( |
| 188 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); | 189 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); |
| 189 confirmButtonTitle = l10n_util::GetNSStringWithFixup( | 190 confirmButtonTitle = l10n_util::GetNSStringWithFixup( |
| 190 IDS_CONTINUE_EXTENSION_DOWNLOAD); | 191 IDS_CONTINUE_EXTENSION_DOWNLOAD); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 211 string16 rootname = UTF8ToUTF16(filename.RemoveExtension().value()); | 212 string16 rootname = UTF8ToUTF16(filename.RemoveExtension().value()); |
| 212 ui::ElideString(rootname, kFileNameMaxLength - extension.length(), | 213 ui::ElideString(rootname, kFileNameMaxLength - extension.length(), |
| 213 &rootname); | 214 &rootname); |
| 214 std::string new_filename = UTF16ToUTF8(rootname); | 215 std::string new_filename = UTF16ToUTF8(rootname); |
| 215 if (extension.length()) | 216 if (extension.length()) |
| 216 new_filename += std::string(".") + extension; | 217 new_filename += std::string(".") + extension; |
| 217 | 218 |
| 218 dangerousWarning = l10n_util::GetNSStringFWithFixup( | 219 dangerousWarning = l10n_util::GetNSStringFWithFixup( |
| 219 IDS_PROMPT_DANGEROUS_DOWNLOAD, UTF8ToUTF16(new_filename)); | 220 IDS_PROMPT_DANGEROUS_DOWNLOAD, UTF8ToUTF16(new_filename)); |
| 220 confirmButtonTitle = | 221 confirmButtonTitle = |
| 221 l10n_util::GetNSStringWithFixup(IDS_SAVE_DOWNLOAD); | 222 l10n_util::GetNSStringWithFixup(IDS_CONFIRM_DOWNLOAD); |
| 222 } | 223 } |
| 223 } | 224 } |
| 224 DCHECK(alertIcon); | 225 DCHECK(alertIcon); |
| 225 [image_ setImage:alertIcon]; | 226 [image_ setImage:alertIcon]; |
| 226 DCHECK(dangerousWarning); | 227 DCHECK(dangerousWarning); |
| 227 [dangerousDownloadLabel_ setStringValue:dangerousWarning]; | 228 [dangerousDownloadLabel_ setStringValue:dangerousWarning]; |
| 228 DCHECK(confirmButtonTitle); | 229 DCHECK(confirmButtonTitle); |
| 229 [dangerousDownloadConfirmButton_ setTitle:confirmButtonTitle]; | 230 [dangerousDownloadConfirmButton_ setTitle:confirmButtonTitle]; |
| 230 return; | 231 return; |
| 231 } | 232 } |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 [sender setTitle:l10n_util::GetNSStringWithFixup( | 410 [sender setTitle:l10n_util::GetNSStringWithFixup( |
| 410 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; | 411 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; |
| 411 } else { | 412 } else { |
| 412 [sender setTitle:l10n_util::GetNSStringWithFixup( | 413 [sender setTitle:l10n_util::GetNSStringWithFixup( |
| 413 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; | 414 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; |
| 414 } | 415 } |
| 415 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); | 416 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); |
| 416 } | 417 } |
| 417 | 418 |
| 418 @end | 419 @end |
| OLD | NEW |