OLD | NEW |
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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
6 | 6 |
7 #include "chrome/browser/download/download_shelf.h" | 7 #include "chrome/browser/download/download_shelf.h" |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "cc/paint/paint_flags.h" |
18 #include "chrome/browser/download/download_item_model.h" | 19 #include "chrome/browser/download/download_item_model.h" |
19 #include "chrome/browser/download/download_service.h" | 20 #include "chrome/browser/download/download_service.h" |
20 #include "chrome/browser/download/download_service_factory.h" | 21 #include "chrome/browser/download/download_service_factory.h" |
21 #include "chrome/browser/download/download_started_animation.h" | 22 #include "chrome/browser/download/download_started_animation.h" |
22 #include "chrome/browser/platform_util.h" | 23 #include "chrome/browser/platform_util.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/themes/theme_properties.h" | 25 #include "chrome/browser/themes/theme_properties.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
27 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 68 |
68 // Download progress painting -------------------------------------------------- | 69 // Download progress painting -------------------------------------------------- |
69 | 70 |
70 // static | 71 // static |
71 void DownloadShelf::PaintDownloadProgress( | 72 void DownloadShelf::PaintDownloadProgress( |
72 gfx::Canvas* canvas, | 73 gfx::Canvas* canvas, |
73 const ui::ThemeProvider& theme_provider, | 74 const ui::ThemeProvider& theme_provider, |
74 const base::TimeDelta& progress_time, | 75 const base::TimeDelta& progress_time, |
75 int percent_done) { | 76 int percent_done) { |
76 // Draw background (light blue circle). | 77 // Draw background (light blue circle). |
77 SkPaint bg_paint; | 78 cc::PaintFlags bg_paint; |
78 bg_paint.setStyle(SkPaint::kFill_Style); | 79 bg_paint.setStyle(cc::PaintFlags::kFill_Style); |
79 SkColor indicator_color = | 80 SkColor indicator_color = |
80 theme_provider.GetColor(ThemeProperties::COLOR_TAB_THROBBER_SPINNING); | 81 theme_provider.GetColor(ThemeProperties::COLOR_TAB_THROBBER_SPINNING); |
81 bg_paint.setColor(SkColorSetA(indicator_color, 0x33)); | 82 bg_paint.setColor(SkColorSetA(indicator_color, 0x33)); |
82 bg_paint.setAntiAlias(true); | 83 bg_paint.setAntiAlias(true); |
83 const SkScalar kCenterPoint = kProgressIndicatorSize / 2.f; | 84 const SkScalar kCenterPoint = kProgressIndicatorSize / 2.f; |
84 SkPath bg; | 85 SkPath bg; |
85 bg.addCircle(kCenterPoint, kCenterPoint, kCenterPoint); | 86 bg.addCircle(kCenterPoint, kCenterPoint, kCenterPoint); |
86 canvas->DrawPath(bg, bg_paint); | 87 canvas->DrawPath(bg, bg_paint); |
87 | 88 |
88 // Calculate progress. | 89 // Calculate progress. |
89 SkScalar sweep_angle = 0.f; | 90 SkScalar sweep_angle = 0.f; |
90 // Start at 12 o'clock. | 91 // Start at 12 o'clock. |
91 SkScalar start_pos = SkIntToScalar(270); | 92 SkScalar start_pos = SkIntToScalar(270); |
92 if (percent_done < 0) { | 93 if (percent_done < 0) { |
93 // For unknown size downloads, draw a 50 degree sweep that moves at | 94 // For unknown size downloads, draw a 50 degree sweep that moves at |
94 // 0.08 degrees per millisecond. | 95 // 0.08 degrees per millisecond. |
95 sweep_angle = 50.f; | 96 sweep_angle = 50.f; |
96 start_pos += static_cast<SkScalar>(progress_time.InMilliseconds() * 0.08); | 97 start_pos += static_cast<SkScalar>(progress_time.InMilliseconds() * 0.08); |
97 } else if (percent_done > 0) { | 98 } else if (percent_done > 0) { |
98 sweep_angle = static_cast<SkScalar>(360 * percent_done / 100.0); | 99 sweep_angle = static_cast<SkScalar>(360 * percent_done / 100.0); |
99 } | 100 } |
100 | 101 |
101 // Draw progress. | 102 // Draw progress. |
102 SkPath progress; | 103 SkPath progress; |
103 progress.addArc( | 104 progress.addArc( |
104 SkRect::MakeLTRB(0, 0, kProgressIndicatorSize, kProgressIndicatorSize), | 105 SkRect::MakeLTRB(0, 0, kProgressIndicatorSize, kProgressIndicatorSize), |
105 start_pos, sweep_angle); | 106 start_pos, sweep_angle); |
106 SkPaint progress_paint; | 107 cc::PaintFlags progress_paint; |
107 progress_paint.setColor(indicator_color); | 108 progress_paint.setColor(indicator_color); |
108 progress_paint.setStyle(SkPaint::kStroke_Style); | 109 progress_paint.setStyle(cc::PaintFlags::kStroke_Style); |
109 progress_paint.setStrokeWidth(1.7f); | 110 progress_paint.setStrokeWidth(1.7f); |
110 progress_paint.setAntiAlias(true); | 111 progress_paint.setAntiAlias(true); |
111 canvas->DrawPath(progress, progress_paint); | 112 canvas->DrawPath(progress, progress_paint); |
112 } | 113 } |
113 | 114 |
114 // static | 115 // static |
115 void DownloadShelf::PaintDownloadComplete( | 116 void DownloadShelf::PaintDownloadComplete( |
116 gfx::Canvas* canvas, | 117 gfx::Canvas* canvas, |
117 const ui::ThemeProvider& theme_provider, | 118 const ui::ThemeProvider& theme_provider, |
118 double animation_progress) { | 119 double animation_progress) { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 content::DownloadManager* download_manager = GetDownloadManager(); | 231 content::DownloadManager* download_manager = GetDownloadManager(); |
231 if (!download_manager) | 232 if (!download_manager) |
232 return; | 233 return; |
233 | 234 |
234 DownloadItem* download = download_manager->GetDownload(download_id); | 235 DownloadItem* download = download_manager->GetDownload(download_id); |
235 if (!download) | 236 if (!download) |
236 return; | 237 return; |
237 | 238 |
238 ShowDownload(download); | 239 ShowDownload(download); |
239 } | 240 } |
OLD | NEW |