| 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_item_view.h" | 5 #include "chrome/browser/ui/views/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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 normal_drop_down_image_set_.center->width() : | 491 normal_drop_down_image_set_.center->width() : |
| 492 0); | 492 0); |
| 493 | 493 |
| 494 // May be caused by animation. | 494 // May be caused by animation. |
| 495 if (center_width <= 0) | 495 if (center_width <= 0) |
| 496 return; | 496 return; |
| 497 | 497 |
| 498 // Draw status before button image to effectively lighten text. | 498 // Draw status before button image to effectively lighten text. |
| 499 if (!IsDangerousMode()) { | 499 if (!IsDangerousMode()) { |
| 500 if (show_status_text_) { | 500 if (show_status_text_) { |
| 501 int mirrored_x = MirroredXWithWidthInsideView( | 501 int mirrored_x = GetMirroredXWithWidthInView( |
| 502 download_util::kSmallProgressIconSize, kTextWidth); | 502 download_util::kSmallProgressIconSize, kTextWidth); |
| 503 // Add font_.height() to compensate for title, which is drawn later. | 503 // Add font_.height() to compensate for title, which is drawn later. |
| 504 int y = box_y_ + kVerticalPadding + font_.GetHeight() + | 504 int y = box_y_ + kVerticalPadding + font_.GetHeight() + |
| 505 kVerticalTextPadding; | 505 kVerticalTextPadding; |
| 506 SkColor file_name_color = GetThemeProvider()->GetColor( | 506 SkColor file_name_color = GetThemeProvider()->GetColor( |
| 507 BrowserThemeProvider::COLOR_BOOKMARK_TEXT); | 507 BrowserThemeProvider::COLOR_BOOKMARK_TEXT); |
| 508 // If text is light-on-dark, lightening it alone will do nothing. | 508 // If text is light-on-dark, lightening it alone will do nothing. |
| 509 // Therefore we mute luminance a wee bit before drawing in this case. | 509 // Therefore we mute luminance a wee bit before drawing in this case. |
| 510 if (color_utils::RelativeLuminance(file_name_color) > 0.5) | 510 if (color_utils::RelativeLuminance(file_name_color) > 0.5) |
| 511 file_name_color = SkColorSetRGB( | 511 file_name_color = SkColorSetRGB( |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 int status_string_width = font_.GetStringWidth(status_string); | 618 int status_string_width = font_.GetStringWidth(status_string); |
| 619 // Then, elide the file name. | 619 // Then, elide the file name. |
| 620 string16 filename_string = | 620 string16 filename_string = |
| 621 ui::ElideFilename(download_->GetFileNameToReportUser(), font_, | 621 ui::ElideFilename(download_->GetFileNameToReportUser(), font_, |
| 622 kTextWidth - status_string_width); | 622 kTextWidth - status_string_width); |
| 623 // Last, concat the whole string. | 623 // Last, concat the whole string. |
| 624 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, | 624 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, |
| 625 filename_string); | 625 filename_string); |
| 626 } | 626 } |
| 627 | 627 |
| 628 int mirrored_x = MirroredXWithWidthInsideView( | 628 int mirrored_x = GetMirroredXWithWidthInView( |
| 629 download_util::kSmallProgressIconSize, kTextWidth); | 629 download_util::kSmallProgressIconSize, kTextWidth); |
| 630 SkColor file_name_color = GetThemeProvider()->GetColor( | 630 SkColor file_name_color = GetThemeProvider()->GetColor( |
| 631 BrowserThemeProvider::COLOR_BOOKMARK_TEXT); | 631 BrowserThemeProvider::COLOR_BOOKMARK_TEXT); |
| 632 int y = | 632 int y = |
| 633 box_y_ + (show_status_text_ ? kVerticalPadding : | 633 box_y_ + (show_status_text_ ? kVerticalPadding : |
| 634 (box_height_ - font_.GetHeight()) / 2); | 634 (box_height_ - font_.GetHeight()) / 2); |
| 635 | 635 |
| 636 // Draw the file's name. | 636 // Draw the file's name. |
| 637 canvas->DrawStringInt(filename, font_, | 637 canvas->DrawStringInt(filename, font_, |
| 638 IsEnabled() ? file_name_color : | 638 IsEnabled() ? file_name_color : |
| (...skipping 21 matching lines...) Expand all Loading... |
| 660 } else if (download_->state() == DownloadItem::COMPLETE && | 660 } else if (download_->state() == DownloadItem::COMPLETE && |
| 661 complete_animation_.get() && | 661 complete_animation_.get() && |
| 662 complete_animation_->is_animating()) { | 662 complete_animation_->is_animating()) { |
| 663 download_util::PaintDownloadComplete(canvas, this, 0, 0, | 663 download_util::PaintDownloadComplete(canvas, this, 0, 0, |
| 664 complete_animation_->GetCurrentValue(), | 664 complete_animation_->GetCurrentValue(), |
| 665 download_util::SMALL); | 665 download_util::SMALL); |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 | 668 |
| 669 // Draw the icon image. | 669 // Draw the icon image. |
| 670 int mirrored_x = MirroredXWithWidthInsideView( | 670 int mirrored_x = GetMirroredXWithWidthInView( |
| 671 download_util::kSmallProgressIconOffset, icon->width()); | 671 download_util::kSmallProgressIconOffset, icon->width()); |
| 672 if (IsEnabled()) { | 672 if (IsEnabled()) { |
| 673 canvas->DrawBitmapInt(*icon, mirrored_x, | 673 canvas->DrawBitmapInt(*icon, mirrored_x, |
| 674 download_util::kSmallProgressIconOffset); | 674 download_util::kSmallProgressIconOffset); |
| 675 } else { | 675 } else { |
| 676 // Use an alpha to make the image look disabled. | 676 // Use an alpha to make the image look disabled. |
| 677 SkPaint paint; | 677 SkPaint paint; |
| 678 paint.setAlpha(120); | 678 paint.setAlpha(120); |
| 679 canvas->DrawBitmapInt(*icon, mirrored_x, | 679 canvas->DrawBitmapInt(*icon, mirrored_x, |
| 680 download_util::kSmallProgressIconOffset, paint); | 680 download_util::kSmallProgressIconOffset, paint); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 | 1074 |
| 1075 // If the name has changed, call SetAccessibleName and notify | 1075 // If the name has changed, call SetAccessibleName and notify |
| 1076 // assistive technology that the name has changed so they can | 1076 // assistive technology that the name has changed so they can |
| 1077 // announce it immediately. | 1077 // announce it immediately. |
| 1078 if (new_name != current_name) { | 1078 if (new_name != current_name) { |
| 1079 SetAccessibleName(new_name); | 1079 SetAccessibleName(new_name); |
| 1080 if (GetWidget()) | 1080 if (GetWidget()) |
| 1081 NotifyAccessibilityEvent(AccessibilityTypes::EVENT_NAME_CHANGED); | 1081 NotifyAccessibilityEvent(AccessibilityTypes::EVENT_NAME_CHANGED); |
| 1082 } | 1082 } |
| 1083 } | 1083 } |
| OLD | NEW |