| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 static const double kDownloadItemLuminanceMod = 0.8; | 79 static const double kDownloadItemLuminanceMod = 0.8; |
| 80 | 80 |
| 81 DownloadItemView::DownloadItemView(DownloadItem* download, | 81 DownloadItemView::DownloadItemView(DownloadItem* download, |
| 82 DownloadShelfView* parent, | 82 DownloadShelfView* parent, |
| 83 BaseDownloadItemModel* model) | 83 BaseDownloadItemModel* model) |
| 84 : warning_icon_(NULL), | 84 : warning_icon_(NULL), |
| 85 download_(download), | 85 download_(download), |
| 86 parent_(parent), | 86 parent_(parent), |
| 87 status_text_(UTF16ToWide( | 87 status_text_(UTF16ToWide( |
| 88 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING))), | 88 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING))), |
| 89 show_status_text_(true), | |
| 90 body_state_(NORMAL), | 89 body_state_(NORMAL), |
| 91 drop_down_state_(NORMAL), | 90 drop_down_state_(NORMAL), |
| 92 progress_angle_(download_util::kStartAngleDegrees), | 91 progress_angle_(download_util::kStartAngleDegrees), |
| 93 drop_down_pressed_(false), | 92 drop_down_pressed_(false), |
| 94 dragging_(false), | 93 dragging_(false), |
| 95 starting_drag_(false), | 94 starting_drag_(false), |
| 96 model_(model), | 95 model_(model), |
| 97 save_button_(NULL), | 96 save_button_(NULL), |
| 98 discard_button_(NULL), | 97 discard_button_(NULL), |
| 99 dangerous_download_label_(NULL), | 98 dangerous_download_label_(NULL), |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 switch (download_->state()) { | 347 switch (download_->state()) { |
| 349 case DownloadItem::IN_PROGRESS: | 348 case DownloadItem::IN_PROGRESS: |
| 350 download_->is_paused() ? StopDownloadProgress() : StartDownloadProgress(); | 349 download_->is_paused() ? StopDownloadProgress() : StartDownloadProgress(); |
| 351 break; | 350 break; |
| 352 case DownloadItem::INTERRUPTED: | 351 case DownloadItem::INTERRUPTED: |
| 353 StopDownloadProgress(); | 352 StopDownloadProgress(); |
| 354 complete_animation_.reset(new ui::SlideAnimation(this)); | 353 complete_animation_.reset(new ui::SlideAnimation(this)); |
| 355 complete_animation_->SetSlideDuration(kInterruptedAnimationDurationMs); | 354 complete_animation_->SetSlideDuration(kInterruptedAnimationDurationMs); |
| 356 complete_animation_->SetTweenType(ui::Tween::LINEAR); | 355 complete_animation_->SetTweenType(ui::Tween::LINEAR); |
| 357 complete_animation_->Show(); | 356 complete_animation_->Show(); |
| 358 if (status_text.empty()) | |
| 359 show_status_text_ = false; | |
| 360 SchedulePaint(); | 357 SchedulePaint(); |
| 361 LoadIcon(); | 358 LoadIcon(); |
| 362 break; | 359 break; |
| 363 case DownloadItem::COMPLETE: | 360 case DownloadItem::COMPLETE: |
| 364 if (download_->auto_opened()) { | 361 if (download_->auto_opened()) { |
| 365 parent_->RemoveDownloadView(this); // This will delete us! | 362 parent_->RemoveDownloadView(this); // This will delete us! |
| 366 return; | 363 return; |
| 367 } | 364 } |
| 368 StopDownloadProgress(); | 365 StopDownloadProgress(); |
| 369 complete_animation_.reset(new ui::SlideAnimation(this)); | 366 complete_animation_.reset(new ui::SlideAnimation(this)); |
| 370 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); | 367 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); |
| 371 complete_animation_->SetTweenType(ui::Tween::LINEAR); | 368 complete_animation_->SetTweenType(ui::Tween::LINEAR); |
| 372 complete_animation_->Show(); | 369 complete_animation_->Show(); |
| 373 if (status_text.empty()) | |
| 374 show_status_text_ = false; | |
| 375 SchedulePaint(); | 370 SchedulePaint(); |
| 376 LoadIcon(); | 371 LoadIcon(); |
| 377 break; | 372 break; |
| 378 case DownloadItem::CANCELLED: | 373 case DownloadItem::CANCELLED: |
| 379 StopDownloadProgress(); | 374 StopDownloadProgress(); |
| 380 LoadIcon(); | 375 LoadIcon(); |
| 381 break; | 376 break; |
| 382 case DownloadItem::REMOVING: | 377 case DownloadItem::REMOVING: |
| 383 parent_->RemoveDownloadView(this); // This will delete us! | 378 parent_->RemoveDownloadView(this); // This will delete us! |
| 384 return; | 379 return; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 (drop_down_image_set ? | 711 (drop_down_image_set ? |
| 717 normal_drop_down_image_set_.center->width() : | 712 normal_drop_down_image_set_.center->width() : |
| 718 0); | 713 0); |
| 719 | 714 |
| 720 // May be caused by animation. | 715 // May be caused by animation. |
| 721 if (center_width <= 0) | 716 if (center_width <= 0) |
| 722 return; | 717 return; |
| 723 | 718 |
| 724 // Draw status before button image to effectively lighten text. | 719 // Draw status before button image to effectively lighten text. |
| 725 if (!IsDangerousMode()) { | 720 if (!IsDangerousMode()) { |
| 726 if (show_status_text_) { | 721 if (!status_text_.empty()) { |
| 727 int mirrored_x = GetMirroredXWithWidthInView( | 722 int mirrored_x = GetMirroredXWithWidthInView( |
| 728 download_util::kSmallProgressIconSize, kTextWidth); | 723 download_util::kSmallProgressIconSize, kTextWidth); |
| 729 // Add font_.height() to compensate for title, which is drawn later. | 724 // Add font_.height() to compensate for title, which is drawn later. |
| 730 int y = box_y_ + kVerticalPadding + font_.GetHeight() + | 725 int y = box_y_ + kVerticalPadding + font_.GetHeight() + |
| 731 kVerticalTextPadding; | 726 kVerticalTextPadding; |
| 732 SkColor file_name_color = GetThemeProvider()->GetColor( | 727 SkColor file_name_color = GetThemeProvider()->GetColor( |
| 733 ThemeService::COLOR_BOOKMARK_TEXT); | 728 ThemeService::COLOR_BOOKMARK_TEXT); |
| 734 // If text is light-on-dark, lightening it alone will do nothing. | 729 // If text is light-on-dark, lightening it alone will do nothing. |
| 735 // Therefore we mute luminance a wee bit before drawing in this case. | 730 // Therefore we mute luminance a wee bit before drawing in this case. |
| 736 if (color_utils::RelativeLuminance(file_name_color) > 0.5) | 731 if (color_utils::RelativeLuminance(file_name_color) > 0.5) |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 // Last, concat the whole string. | 844 // Last, concat the whole string. |
| 850 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, | 845 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, |
| 851 filename_string); | 846 filename_string); |
| 852 } | 847 } |
| 853 | 848 |
| 854 int mirrored_x = GetMirroredXWithWidthInView( | 849 int mirrored_x = GetMirroredXWithWidthInView( |
| 855 download_util::kSmallProgressIconSize, kTextWidth); | 850 download_util::kSmallProgressIconSize, kTextWidth); |
| 856 SkColor file_name_color = GetThemeProvider()->GetColor( | 851 SkColor file_name_color = GetThemeProvider()->GetColor( |
| 857 ThemeService::COLOR_BOOKMARK_TEXT); | 852 ThemeService::COLOR_BOOKMARK_TEXT); |
| 858 int y = | 853 int y = |
| 859 box_y_ + (show_status_text_ ? kVerticalPadding : | 854 box_y_ + (status_text_.empty() ? |
| 860 (box_height_ - font_.GetHeight()) / 2); | 855 ((box_height_ - font_.GetHeight()) / 2) : kVerticalPadding); |
| 861 | 856 |
| 862 // Draw the file's name. | 857 // Draw the file's name. |
| 863 canvas->DrawStringInt(filename, font_, | 858 canvas->DrawStringInt(filename, font_, |
| 864 IsEnabled() ? file_name_color : | 859 IsEnabled() ? file_name_color : |
| 865 kFileNameDisabledColor, | 860 kFileNameDisabledColor, |
| 866 mirrored_x, y, kTextWidth, font_.GetHeight()); | 861 mirrored_x, y, kTextWidth, font_.GetHeight()); |
| 867 } | 862 } |
| 868 | 863 |
| 869 // Load the icon. | 864 // Load the icon. |
| 870 IconManager* im = g_browser_process->icon_manager(); | 865 IconManager* im = g_browser_process->icon_manager(); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 // If the name has changed, notify assistive technology that the name | 1107 // If the name has changed, notify assistive technology that the name |
| 1113 // has changed so they can announce it immediately. | 1108 // has changed so they can announce it immediately. |
| 1114 if (new_name != accessible_name_) { | 1109 if (new_name != accessible_name_) { |
| 1115 accessible_name_ = new_name; | 1110 accessible_name_ = new_name; |
| 1116 if (GetWidget()) { | 1111 if (GetWidget()) { |
| 1117 GetWidget()->NotifyAccessibilityEvent( | 1112 GetWidget()->NotifyAccessibilityEvent( |
| 1118 this, ui::AccessibilityTypes::EVENT_NAME_CHANGED, true); | 1113 this, ui::AccessibilityTypes::EVENT_NAME_CHANGED, true); |
| 1119 } | 1114 } |
| 1120 } | 1115 } |
| 1121 } | 1116 } |
| OLD | NEW |