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 #include "chrome/browser/ui/views/download/download_item_view.h" | 5 #include "chrome/browser/ui/views/download/download_item_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/i18n/break_iterator.h" | 13 #include "base/i18n/break_iterator.h" |
14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/sys_string_conversions.h" | 17 #include "base/sys_string_conversions.h" |
18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 20 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
21 #include "chrome/browser/download/download_item_model.h" | 21 #include "chrome/browser/download/download_item_model.h" |
22 #include "chrome/browser/download/download_util.h" | 22 #include "chrome/browser/download/download_util.h" |
23 #include "chrome/browser/themes/theme_service.h" | 23 #include "chrome/browser/themes/theme_service.h" |
24 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" | 24 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" |
25 #include "chrome/browser/ui/views/download/download_shelf_view.h" | 25 #include "chrome/browser/ui/views/download/download_shelf_view.h" |
| 26 #include "content/browser/download/download_state_info.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 "ui/base/accessibility/accessible_view_state.h" | 29 #include "ui/base/accessibility/accessible_view_state.h" |
29 #include "ui/base/animation/slide_animation.h" | 30 #include "ui/base/animation/slide_animation.h" |
30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
32 #include "ui/base/text/text_elider.h" | 33 #include "ui/base/text/text_elider.h" |
33 #include "ui/gfx/canvas_skia.h" | 34 #include "ui/gfx/canvas_skia.h" |
34 #include "ui/gfx/color_utils.h" | 35 #include "ui/gfx/color_utils.h" |
35 #include "ui/gfx/image/image.h" | 36 #include "ui/gfx/image/image.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 #endif | 248 #endif |
248 | 249 |
249 // Elide giant extensions (this shouldn't currently be hit, but might | 250 // Elide giant extensions (this shouldn't currently be hit, but might |
250 // in future, should we ever notice unsafe giant extensions). | 251 // in future, should we ever notice unsafe giant extensions). |
251 if (extension.length() > kFileNameMaxLength / 2) | 252 if (extension.length() > kFileNameMaxLength / 2) |
252 ui::ElideString(extension, kFileNameMaxLength / 2, &extension); | 253 ui::ElideString(extension, kFileNameMaxLength / 2, &extension); |
253 | 254 |
254 // The dangerous download label text and icon are different | 255 // The dangerous download label text and icon are different |
255 // under different cases. | 256 // under different cases. |
256 string16 dangerous_label; | 257 string16 dangerous_label; |
257 if (download->GetDangerType() == DownloadItem::DANGEROUS_URL) { | 258 if (download->GetDangerType() == DownloadStateInfo::DANGEROUS_URL) { |
258 // Safebrowsing shows the download URL leads to malicious file. | 259 // Safebrowsing shows the download URL leads to malicious file. |
259 warning_icon_ = rb.GetBitmapNamed(IDR_SAFEBROWSING_WARNING); | 260 warning_icon_ = rb.GetBitmapNamed(IDR_SAFEBROWSING_WARNING); |
260 dangerous_label = | 261 dangerous_label = |
261 l10n_util::GetStringUTF16(IDS_PROMPT_UNSAFE_DOWNLOAD_URL); | 262 l10n_util::GetStringUTF16(IDS_PROMPT_UNSAFE_DOWNLOAD_URL); |
262 } else { | 263 } else { |
263 // The download file has dangerous file type (e.g.: an executable). | 264 // The download file has dangerous file type (e.g.: an executable). |
264 DCHECK(download->GetDangerType() == DownloadItem::DANGEROUS_FILE); | 265 DCHECK(download->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE); |
265 warning_icon_ = rb.GetBitmapNamed(IDR_WARNING); | 266 warning_icon_ = rb.GetBitmapNamed(IDR_WARNING); |
266 if (ChromeDownloadManagerDelegate::IsExtensionDownload(download)) { | 267 if (ChromeDownloadManagerDelegate::IsExtensionDownload(download)) { |
267 dangerous_label = | 268 dangerous_label = |
268 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); | 269 l10n_util::GetStringUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); |
269 } else { | 270 } else { |
270 ui::ElideString(rootname, | 271 ui::ElideString(rootname, |
271 kFileNameMaxLength - extension.length(), | 272 kFileNameMaxLength - extension.length(), |
272 &rootname); | 273 &rootname); |
273 string16 filename = rootname + ASCIIToUTF16(".") + extension; | 274 string16 filename = rootname + ASCIIToUTF16(".") + extension; |
274 filename = base::i18n::GetDisplayStringInLTRDirectionality(filename); | 275 filename = base::i18n::GetDisplayStringInLTRDirectionality(filename); |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 // If the name has changed, notify assistive technology that the name | 1109 // If the name has changed, notify assistive technology that the name |
1109 // has changed so they can announce it immediately. | 1110 // has changed so they can announce it immediately. |
1110 if (new_name != accessible_name_) { | 1111 if (new_name != accessible_name_) { |
1111 accessible_name_ = new_name; | 1112 accessible_name_ = new_name; |
1112 if (GetWidget()) { | 1113 if (GetWidget()) { |
1113 GetWidget()->NotifyAccessibilityEvent( | 1114 GetWidget()->NotifyAccessibilityEvent( |
1114 this, ui::AccessibilityTypes::EVENT_NAME_CHANGED, true); | 1115 this, ui::AccessibilityTypes::EVENT_NAME_CHANGED, true); |
1115 } | 1116 } |
1116 } | 1117 } |
1117 } | 1118 } |
OLD | NEW |