Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/browser/ui/views/download/download_item_view.cc

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/safe_browsing/download_protection_service.h" 25 #include "chrome/browser/safe_browsing/download_protection_service.h"
26 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 26 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
27 #include "chrome/browser/themes/theme_properties.h" 27 #include "chrome/browser/themes/theme_properties.h"
28 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h" 28 #include "chrome/browser/ui/views/download/download_shelf_context_menu_view.h"
29 #include "chrome/browser/ui/views/download/download_shelf_view.h" 29 #include "chrome/browser/ui/views/download/download_shelf_view.h"
30 #include "content/public/browser/download_danger_type.h" 30 #include "content/public/browser/download_danger_type.h"
31 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
32 #include "grit/theme_resources.h" 32 #include "grit/theme_resources.h"
33 #include "third_party/icu/source/common/unicode/uchar.h" 33 #include "third_party/icu/source/common/unicode/uchar.h"
34 #include "ui/base/accessibility/accessible_view_state.h" 34 #include "ui/base/accessibility/accessible_view_state.h"
35 #include "ui/base/animation/slide_animation.h"
36 #include "ui/base/events/event.h" 35 #include "ui/base/events/event.h"
37 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/base/theme_provider.h" 38 #include "ui/base/theme_provider.h"
39 #include "ui/gfx/animation/slide_animation.h"
40 #include "ui/gfx/canvas.h" 40 #include "ui/gfx/canvas.h"
41 #include "ui/gfx/color_utils.h" 41 #include "ui/gfx/color_utils.h"
42 #include "ui/gfx/image/image.h" 42 #include "ui/gfx/image/image.h"
43 #include "ui/gfx/text_elider.h" 43 #include "ui/gfx/text_elider.h"
44 #include "ui/views/controls/button/label_button.h" 44 #include "ui/views/controls/button/label_button.h"
45 #include "ui/views/controls/label.h" 45 #include "ui/views/controls/label.h"
46 #include "ui/views/widget/root_view.h" 46 #include "ui/views/widget/root_view.h"
47 #include "ui/views/widget/widget.h" 47 #include "ui/views/widget/widget.h"
48 48
49 // TODO(paulg): These may need to be adjusted when download progress 49 // TODO(paulg): These may need to be adjusted when download progress
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 kVerticalTextPadding + font_list_.GetHeight(), 195 kVerticalTextPadding + font_list_.GetHeight(),
196 2 * kVerticalPadding + 196 2 * kVerticalPadding +
197 normal_body_image_set_.top_left->height() + 197 normal_body_image_set_.top_left->height() +
198 normal_body_image_set_.bottom_left->height()); 198 normal_body_image_set_.bottom_left->height());
199 199
200 if (DownloadShelf::kSmallProgressIconSize > box_height_) 200 if (DownloadShelf::kSmallProgressIconSize > box_height_)
201 box_y_ = (DownloadShelf::kSmallProgressIconSize - box_height_) / 2; 201 box_y_ = (DownloadShelf::kSmallProgressIconSize - box_height_) / 2;
202 else 202 else
203 box_y_ = 0; 203 box_y_ = 0;
204 204
205 body_hover_animation_.reset(new ui::SlideAnimation(this)); 205 body_hover_animation_.reset(new gfx::SlideAnimation(this));
206 drop_hover_animation_.reset(new ui::SlideAnimation(this)); 206 drop_hover_animation_.reset(new gfx::SlideAnimation(this));
207 207
208 set_accessibility_focusable(true); 208 set_accessibility_focusable(true);
209 209
210 OnDownloadUpdated(download()); 210 OnDownloadUpdated(download());
211 UpdateDropDownButtonPosition(); 211 UpdateDropDownButtonPosition();
212 } 212 }
213 213
214 DownloadItemView::~DownloadItemView() { 214 DownloadItemView::~DownloadItemView() {
215 StopDownloadProgress(); 215 StopDownloadProgress();
216 download()->RemoveObserver(this); 216 download()->RemoveObserver(this);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } else { 260 } else {
261 string16 status_text = model_.GetStatusText(); 261 string16 status_text = model_.GetStatusText();
262 switch (download()->GetState()) { 262 switch (download()->GetState()) {
263 case DownloadItem::IN_PROGRESS: 263 case DownloadItem::IN_PROGRESS:
264 download()->IsPaused() ? 264 download()->IsPaused() ?
265 StopDownloadProgress() : StartDownloadProgress(); 265 StopDownloadProgress() : StartDownloadProgress();
266 LoadIconIfItemPathChanged(); 266 LoadIconIfItemPathChanged();
267 break; 267 break;
268 case DownloadItem::INTERRUPTED: 268 case DownloadItem::INTERRUPTED:
269 StopDownloadProgress(); 269 StopDownloadProgress();
270 complete_animation_.reset(new ui::SlideAnimation(this)); 270 complete_animation_.reset(new gfx::SlideAnimation(this));
271 complete_animation_->SetSlideDuration(kInterruptedAnimationDurationMs); 271 complete_animation_->SetSlideDuration(kInterruptedAnimationDurationMs);
272 complete_animation_->SetTweenType(ui::Tween::LINEAR); 272 complete_animation_->SetTweenType(gfx::Tween::LINEAR);
273 complete_animation_->Show(); 273 complete_animation_->Show();
274 SchedulePaint(); 274 SchedulePaint();
275 LoadIcon(); 275 LoadIcon();
276 break; 276 break;
277 case DownloadItem::COMPLETE: 277 case DownloadItem::COMPLETE:
278 if (model_.ShouldRemoveFromShelfWhenComplete()) { 278 if (model_.ShouldRemoveFromShelfWhenComplete()) {
279 shelf_->RemoveDownloadView(this); // This will delete us! 279 shelf_->RemoveDownloadView(this); // This will delete us!
280 return; 280 return;
281 } 281 }
282 StopDownloadProgress(); 282 StopDownloadProgress();
283 complete_animation_.reset(new ui::SlideAnimation(this)); 283 complete_animation_.reset(new gfx::SlideAnimation(this));
284 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs); 284 complete_animation_->SetSlideDuration(kCompleteAnimationDurationMs);
285 complete_animation_->SetTweenType(ui::Tween::LINEAR); 285 complete_animation_->SetTweenType(gfx::Tween::LINEAR);
286 complete_animation_->Show(); 286 complete_animation_->Show();
287 SchedulePaint(); 287 SchedulePaint();
288 LoadIcon(); 288 LoadIcon();
289 break; 289 break;
290 case DownloadItem::CANCELLED: 290 case DownloadItem::CANCELLED:
291 StopDownloadProgress(); 291 StopDownloadProgress();
292 if (complete_animation_) 292 if (complete_animation_)
293 complete_animation_->Stop(); 293 complete_animation_->Stop();
294 LoadIcon(); 294 LoadIcon();
295 break; 295 break;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 } else if (save_button_ && sender == save_button_) { 538 } else if (save_button_ && sender == save_button_) {
539 // The user has confirmed a dangerous download. We'd record how quickly the 539 // The user has confirmed a dangerous download. We'd record how quickly the
540 // user did this to detect whether we're being clickjacked. 540 // user did this to detect whether we're being clickjacked.
541 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", 541 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download",
542 base::Time::Now() - creation_time_); 542 base::Time::Now() - creation_time_);
543 // This will change the state and notify us. 543 // This will change the state and notify us.
544 download()->ValidateDangerousDownload(); 544 download()->ValidateDangerousDownload();
545 } 545 }
546 } 546 }
547 547
548 void DownloadItemView::AnimationProgressed(const ui::Animation* animation) { 548 void DownloadItemView::AnimationProgressed(const gfx::Animation* animation) {
549 // We don't care if what animation (body button/drop button/complete), 549 // We don't care if what animation (body button/drop button/complete),
550 // is calling back, as they all have to go through the same paint call. 550 // is calling back, as they all have to go through the same paint call.
551 SchedulePaint(); 551 SchedulePaint();
552 } 552 }
553 553
554 // The DownloadItemView can be in three major modes (NORMAL_MODE, DANGEROUS_MODE 554 // The DownloadItemView can be in three major modes (NORMAL_MODE, DANGEROUS_MODE
555 // and MALICIOUS_MODE). 555 // and MALICIOUS_MODE).
556 // 556 //
557 // NORMAL_MODE: We are displaying an in-progress or completed download. 557 // NORMAL_MODE: We are displaying an in-progress or completed download.
558 // .-------------------------------+-. 558 // .-------------------------------+-.
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 drop_down_x_right_ = normal_drop_down_image_set_.top->width(); 1257 drop_down_x_right_ = normal_drop_down_image_set_.top->width();
1258 } else { 1258 } else {
1259 // Drop down button is glued to the right of the download shelf. 1259 // Drop down button is glued to the right of the download shelf.
1260 drop_down_x_left_ = 1260 drop_down_x_left_ =
1261 size.width() - normal_drop_down_image_set_.top->width(); 1261 size.width() - normal_drop_down_image_set_.top->width();
1262 drop_down_x_right_ = size.width(); 1262 drop_down_x_right_ = size.width();
1263 } 1263 }
1264 } 1264 }
1265 1265
1266 void DownloadItemView::AnimateStateTransition(State from, State to, 1266 void DownloadItemView::AnimateStateTransition(State from, State to,
1267 ui::SlideAnimation* animation) { 1267 gfx::SlideAnimation* animation) {
1268 if (from == NORMAL && to == HOT) { 1268 if (from == NORMAL && to == HOT) {
1269 animation->Show(); 1269 animation->Show();
1270 } else if (from == HOT && to == NORMAL) { 1270 } else if (from == HOT && to == NORMAL) {
1271 animation->Hide(); 1271 animation->Hide();
1272 } else if (from != to) { 1272 } else if (from != to) {
1273 animation->Reset((to == HOT) ? 1.0 : 0.0); 1273 animation->Reset((to == HOT) ? 1.0 : 0.0);
1274 } 1274 }
1275 } 1275 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/download/download_item_view.h ('k') | chrome/browser/ui/views/download/download_shelf_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698