| Index: chrome/browser/ui/views/download/download_item_view.cc
|
| diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc
|
| index 77e704c7d965ead84a6b1a5c51abba7445384272..eea080095be29cc76a9a2fda4c3299d483b85364 100644
|
| --- a/chrome/browser/ui/views/download/download_item_view.cc
|
| +++ b/chrome/browser/ui/views/download/download_item_view.cc
|
| @@ -96,16 +96,6 @@ static const int kDisabledOnOpenDuration = 3000;
|
| // light-on-dark themes.
|
| static const double kDownloadItemLuminanceMod = 0.8;
|
|
|
| -namespace {
|
| -
|
| -// Callback for DownloadShelf paint functions to mirror the progress animation
|
| -// in RTL locales.
|
| -void RTLMirrorXForView(views::View* containing_view, gfx::Rect* bounds) {
|
| - bounds->set_x(containing_view->GetMirroredXForRect(*bounds));
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| DownloadItemView::DownloadItemView(DownloadItem* download_item,
|
| DownloadShelfView* parent)
|
| : warning_icon_(NULL),
|
| @@ -114,7 +104,6 @@ DownloadItemView::DownloadItemView(DownloadItem* download_item,
|
| body_state_(NORMAL),
|
| drop_down_state_(NORMAL),
|
| mode_(NORMAL_MODE),
|
| - progress_angle_(DownloadShelf::kStartAngleDegrees),
|
| drop_down_pressed_(false),
|
| dragging_(false),
|
| starting_drag_(false),
|
| @@ -217,8 +206,8 @@ DownloadItemView::DownloadItemView(DownloadItem* download_item,
|
| normal_body_image_set_.top_left->height() +
|
| normal_body_image_set_.bottom_left->height());
|
|
|
| - if (DownloadShelf::kSmallProgressIconSize > box_height_)
|
| - box_y_ = (DownloadShelf::kSmallProgressIconSize - box_height_) / 2;
|
| + if (DownloadShelf::kProgressIndicatorSize > box_height_)
|
| + box_y_ = (DownloadShelf::kProgressIndicatorSize - box_height_) / 2;
|
| else
|
| box_y_ = 0;
|
|
|
| @@ -244,19 +233,13 @@ DownloadItemView::~DownloadItemView() {
|
|
|
| // Progress animation handlers.
|
|
|
| -void DownloadItemView::UpdateDownloadProgress() {
|
| - progress_angle_ =
|
| - (progress_angle_ + DownloadShelf::kUnknownIncrementDegrees) %
|
| - DownloadShelf::kMaxDegrees;
|
| - SchedulePaint();
|
| -}
|
| -
|
| void DownloadItemView::StartDownloadProgress() {
|
| if (progress_timer_.IsRunning())
|
| return;
|
| - progress_timer_.Start(FROM_HERE,
|
| - base::TimeDelta::FromMilliseconds(DownloadShelf::kProgressRateMs), this,
|
| - &DownloadItemView::UpdateDownloadProgress);
|
| + progress_start_time_ = base::TimeTicks::Now();
|
| + progress_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(
|
| + DownloadShelf::kProgressRateMs),
|
| + this, &DownloadItemView::SchedulePaint);
|
| }
|
|
|
| void DownloadItemView::StopDownloadProgress() {
|
| @@ -393,7 +376,7 @@ gfx::Size DownloadItemView::GetPreferredSize() const {
|
| height = 2 * kVerticalPadding + 2 * font_list_.GetHeight() +
|
| kVerticalTextPadding;
|
| // Then we increase the size if the progress icon doesn't fit.
|
| - height = std::max<int>(height, DownloadShelf::kSmallProgressIconSize);
|
| + height = std::max<int>(height, DownloadShelf::kProgressIndicatorSize);
|
|
|
| if (IsShowingWarningDialog()) {
|
| const BodyImageSet* body_image_set =
|
| @@ -416,7 +399,7 @@ gfx::Size DownloadItemView::GetPreferredSize() const {
|
| width += normal_drop_down_image_set_.top->width();
|
| } else {
|
| width = kLeftPadding + normal_body_image_set_.top_left->width();
|
| - width += DownloadShelf::kSmallProgressIconSize;
|
| + width += DownloadShelf::kProgressIndicatorSize;
|
| width += kTextWidth;
|
| width += normal_body_image_set_.top_right->width();
|
| width += normal_drop_down_image_set_.top->width();
|
| @@ -712,7 +695,7 @@ void DownloadItemView::OnPaintBackground(gfx::Canvas* canvas) {
|
| if (!IsShowingWarningDialog()) {
|
| if (!status_text_.empty()) {
|
| int mirrored_x = GetMirroredXWithWidthInView(
|
| - DownloadShelf::kSmallProgressIconSize, kTextWidth);
|
| + DownloadShelf::kProgressIndicatorSize, kTextWidth);
|
| // Add font_list_.height() to compensate for title, which is drawn later.
|
| int y = box_y_ + kVerticalPadding + font_list_.GetHeight() +
|
| kVerticalTextPadding;
|
| @@ -838,7 +821,7 @@ void DownloadItemView::OnPaintBackground(gfx::Canvas* canvas) {
|
| }
|
|
|
| int mirrored_x = GetMirroredXWithWidthInView(
|
| - DownloadShelf::kSmallProgressIconSize, kTextWidth);
|
| + DownloadShelf::kProgressIndicatorSize, kTextWidth);
|
| SkColor file_name_color = GetThemeProvider()->GetColor(
|
| ThemeProperties::COLOR_BOOKMARK_TEXT);
|
| int y =
|
| @@ -870,23 +853,29 @@ void DownloadItemView::OnPaintBackground(gfx::Canvas* canvas) {
|
| if (icon) {
|
| if (!IsShowingWarningDialog()) {
|
| DownloadItem::DownloadState state = download()->GetState();
|
| - DownloadShelf::BoundsAdjusterCallback rtl_mirror =
|
| - base::Bind(&RTLMirrorXForView, base::Unretained(this));
|
| + canvas->Save();
|
| + if (base::i18n::IsRTL())
|
| + canvas->Translate(
|
| + gfx::Vector2d(width() - DownloadShelf::kProgressIndicatorSize, 0));
|
| +
|
| if (state == DownloadItem::IN_PROGRESS) {
|
| - DownloadShelf::PaintDownloadProgress(canvas, rtl_mirror, 0, 0,
|
| - progress_angle_,
|
| + DownloadShelf::PaintDownloadProgress(canvas, *GetThemeProvider(),
|
| + progress_start_time_,
|
| model_.PercentComplete());
|
| } else if (complete_animation_.get() &&
|
| complete_animation_->is_animating()) {
|
| if (state == DownloadItem::INTERRUPTED) {
|
| DownloadShelf::PaintDownloadInterrupted(
|
| - canvas, rtl_mirror, 0, 0, complete_animation_->GetCurrentValue());
|
| + canvas, *GetThemeProvider(),
|
| + complete_animation_->GetCurrentValue());
|
| } else {
|
| DCHECK_EQ(DownloadItem::COMPLETE, state);
|
| DownloadShelf::PaintDownloadComplete(
|
| - canvas, rtl_mirror, 0, 0, complete_animation_->GetCurrentValue());
|
| + canvas, *GetThemeProvider(),
|
| + complete_animation_->GetCurrentValue());
|
| }
|
| }
|
| + canvas->Restore();
|
| }
|
|
|
| // Draw the icon image.
|
| @@ -896,8 +885,8 @@ void DownloadItemView::OnPaintBackground(gfx::Canvas* canvas) {
|
| icon_x = kLeftPadding + body_image_set->top_left->width();
|
| icon_y = (height() - icon->height()) / 2;
|
| } else {
|
| - icon_x = DownloadShelf::kSmallProgressIconOffset;
|
| - icon_y = DownloadShelf::kSmallProgressIconOffset;
|
| + icon_x = DownloadShelf::kFiletypeIconOffset;
|
| + icon_y = DownloadShelf::kFiletypeIconOffset;
|
| }
|
| icon_x = GetMirroredXWithWidthInView(icon_x, icon->width());
|
| if (enabled()) {
|
|
|