OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/download_item_view.h" | 5 #include "chrome/browser/views/download_item_view.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "app/slide_animation.h" | |
12 #include "app/text_elider.h" | 11 #include "app/text_elider.h" |
13 #include "base/callback.h" | 12 #include "base/callback.h" |
14 #include "base/file_path.h" | 13 #include "base/file_path.h" |
15 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
16 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
17 #include "base/string_util.h" | 16 #include "base/string_util.h" |
18 #include "base/sys_string_conversions.h" | 17 #include "base/sys_string_conversions.h" |
19 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/download/download_item_model.h" | 20 #include "chrome/browser/download/download_item_model.h" |
22 #include "chrome/browser/download/download_util.h" | 21 #include "chrome/browser/download/download_util.h" |
23 #include "chrome/browser/themes/browser_theme_provider.h" | 22 #include "chrome/browser/themes/browser_theme_provider.h" |
24 #include "chrome/browser/views/download_shelf_view.h" | 23 #include "chrome/browser/views/download_shelf_view.h" |
25 #include "gfx/canvas_skia.h" | 24 #include "gfx/canvas_skia.h" |
26 #include "gfx/color_utils.h" | 25 #include "gfx/color_utils.h" |
27 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
28 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 28 #include "ui/base/animation/slide_animation.h" |
29 #include "views/controls/button/native_button.h" | 29 #include "views/controls/button/native_button.h" |
30 #include "views/controls/menu/menu_2.h" | 30 #include "views/controls/menu/menu_2.h" |
31 #include "views/widget/root_view.h" | 31 #include "views/widget/root_view.h" |
32 #include "views/widget/widget.h" | 32 #include "views/widget/widget.h" |
33 | 33 |
34 using base::TimeDelta; | 34 using base::TimeDelta; |
35 | 35 |
36 // TODO(paulg): These may need to be adjusted when download progress | 36 // TODO(paulg): These may need to be adjusted when download progress |
37 // animation is added, and also possibly to take into account | 37 // animation is added, and also possibly to take into account |
38 // different screen resolutions. | 38 // different screen resolutions. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // Drop down button is glued to the left of the download shelf. | 230 // Drop down button is glued to the left of the download shelf. |
231 drop_down_x_left_ = 0; | 231 drop_down_x_left_ = 0; |
232 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); | 232 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); |
233 } else { | 233 } else { |
234 // Drop down button is glued to the right of the download shelf. | 234 // Drop down button is glued to the right of the download shelf. |
235 drop_down_x_left_ = | 235 drop_down_x_left_ = |
236 size.width() - normal_drop_down_image_set_.top->width(); | 236 size.width() - normal_drop_down_image_set_.top->width(); |
237 drop_down_x_right_ = size.width(); | 237 drop_down_x_right_ = size.width(); |
238 } | 238 } |
239 | 239 |
240 body_hover_animation_.reset(new SlideAnimation(this)); | 240 body_hover_animation_.reset(new ui::SlideAnimation(this)); |
241 drop_hover_animation_.reset(new SlideAnimation(this)); | 241 drop_hover_animation_.reset(new ui::SlideAnimation(this)); |
242 | 242 |
243 if (download->safety_state() == DownloadItem::DANGEROUS) { | 243 if (download->safety_state() == DownloadItem::DANGEROUS) { |
244 tooltip_text_.clear(); | 244 tooltip_text_.clear(); |
245 body_state_ = DANGEROUS; | 245 body_state_ = DANGEROUS; |
246 drop_down_state_ = DANGEROUS; | 246 drop_down_state_ = DANGEROUS; |
247 | 247 |
248 warning_icon_ = rb.GetBitmapNamed(IDR_WARNING); | 248 warning_icon_ = rb.GetBitmapNamed(IDR_WARNING); |
249 save_button_ = new views::NativeButton(this, | 249 save_button_ = new views::NativeButton(this, |
250 UTF16ToWide(l10n_util::GetStringUTF16( | 250 UTF16ToWide(l10n_util::GetStringUTF16( |
251 download->is_extension_install() ? | 251 download->is_extension_install() ? |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 switch (download_->state()) { | 360 switch (download_->state()) { |
361 case DownloadItem::IN_PROGRESS: | 361 case DownloadItem::IN_PROGRESS: |
362 download_->is_paused() ? StopDownloadProgress() : StartDownloadProgress(); | 362 download_->is_paused() ? StopDownloadProgress() : StartDownloadProgress(); |
363 break; | 363 break; |
364 case DownloadItem::COMPLETE: | 364 case DownloadItem::COMPLETE: |
365 if (download_->auto_opened()) { | 365 if (download_->auto_opened()) { |
366 parent_->RemoveDownloadView(this); // This will delete us! | 366 parent_->RemoveDownloadView(this); // This will delete us! |
367 return; | 367 return; |
368 } | 368 } |
369 StopDownloadProgress(); | 369 StopDownloadProgress(); |
370 complete_animation_.reset(new SlideAnimation(this)); | 370 complete_animation_.reset(new ui::SlideAnimation(this)); |
371 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); | 371 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); |
372 complete_animation_->SetTweenType(Tween::LINEAR); | 372 complete_animation_->SetTweenType(ui::Tween::LINEAR); |
373 complete_animation_->Show(); | 373 complete_animation_->Show(); |
374 if (status_text.empty()) | 374 if (status_text.empty()) |
375 show_status_text_ = false; | 375 show_status_text_ = false; |
376 SchedulePaint(); | 376 SchedulePaint(); |
377 LoadIcon(); | 377 LoadIcon(); |
378 break; | 378 break; |
379 case DownloadItem::CANCELLED: | 379 case DownloadItem::CANCELLED: |
380 StopDownloadProgress(); | 380 StopDownloadProgress(); |
381 LoadIcon(); | 381 LoadIcon(); |
382 break; | 382 break; |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 } | 935 } |
936 | 936 |
937 AccessibilityTypes::State DownloadItemView::GetAccessibleState() { | 937 AccessibilityTypes::State DownloadItemView::GetAccessibleState() { |
938 if (download_->safety_state() == DownloadItem::DANGEROUS) { | 938 if (download_->safety_state() == DownloadItem::DANGEROUS) { |
939 return AccessibilityTypes::STATE_UNAVAILABLE; | 939 return AccessibilityTypes::STATE_UNAVAILABLE; |
940 } else { | 940 } else { |
941 return AccessibilityTypes::STATE_HASPOPUP; | 941 return AccessibilityTypes::STATE_HASPOPUP; |
942 } | 942 } |
943 } | 943 } |
944 | 944 |
945 void DownloadItemView::AnimationProgressed(const Animation* animation) { | 945 void DownloadItemView::AnimationProgressed(const ui::Animation* animation) { |
946 // We don't care if what animation (body button/drop button/complete), | 946 // We don't care if what animation (body button/drop button/complete), |
947 // is calling back, as they all have to go through the same paint call. | 947 // is calling back, as they all have to go through the same paint call. |
948 SchedulePaint(); | 948 SchedulePaint(); |
949 } | 949 } |
950 | 950 |
951 void DownloadItemView::OpenDownload() { | 951 void DownloadItemView::OpenDownload() { |
952 // We're interested in how long it takes users to open downloads. If they | 952 // We're interested in how long it takes users to open downloads. If they |
953 // open downloads super quickly, we should be concerned about clickjacking. | 953 // open downloads super quickly, we should be concerned about clickjacking. |
954 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", | 954 UMA_HISTOGRAM_LONG_TIMES("clickjacking.open_download", |
955 base::Time::Now() - creation_time_); | 955 base::Time::Now() - creation_time_); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 | 1073 |
1074 // If the name has changed, call SetAccessibleName and notify | 1074 // If the name has changed, call SetAccessibleName and notify |
1075 // assistive technology that the name has changed so they can | 1075 // assistive technology that the name has changed so they can |
1076 // announce it immediately. | 1076 // announce it immediately. |
1077 if (new_name != current_name) { | 1077 if (new_name != current_name) { |
1078 SetAccessibleName(new_name); | 1078 SetAccessibleName(new_name); |
1079 if (GetWidget()) | 1079 if (GetWidget()) |
1080 NotifyAccessibilityEvent(AccessibilityTypes::EVENT_NAME_CHANGED); | 1080 NotifyAccessibilityEvent(AccessibilityTypes::EVENT_NAME_CHANGED); |
1081 } | 1081 } |
1082 } | 1082 } |
OLD | NEW |