summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 05:52:50 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-11 05:52:50 +0000
commitd903ef8a4be2bc9ee4b1fb71f6c5b78983f8b8d6 (patch)
treeb13d59e26092548d3f0f3940ce5a1aade67fb290 /chrome/browser/download
parentbfcade631b388e9718d7f48a571eff03d931304e (diff)
downloadchromium_src-d903ef8a4be2bc9ee4b1fb71f6c5b78983f8b8d6.zip
chromium_src-d903ef8a4be2bc9ee4b1fb71f6c5b78983f8b8d6.tar.gz
chromium_src-d903ef8a4be2bc9ee4b1fb71f6c5b78983f8b8d6.tar.bz2
Mac Web Intents Part 11: Progress view
This CL adds a progress view to the web intents picker dialog. The view is used to display the "waiting for chrome web store" and "installing extension" progress. Screenshot: http://i.imgur.com/riMRo.png BUG=152010 Review URL: https://chromiumcodereview.appspot.com/11009017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r--chrome/browser/download/download_util.cc98
-rw-r--r--chrome/browser/download/download_util.h10
2 files changed, 68 insertions, 40 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 3c8b59d..7a01702 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -171,6 +171,61 @@ gfx::ImageSkia* g_background_16 = NULL;
gfx::ImageSkia* g_foreground_32 = NULL;
gfx::ImageSkia* g_background_32 = NULL;
+void PaintCustomDownloadProgress(gfx::Canvas* canvas,
+ const gfx::ImageSkia& background_image,
+ const gfx::ImageSkia& foreground_image,
+ int image_size,
+ const gfx::Rect& bounds,
+ int start_angle,
+ int percent_done) {
+ // Draw the background progress image.
+ canvas->DrawImageInt(background_image,
+ bounds.x(),
+ bounds.y());
+
+ // Layer the foreground progress image in an arc proportional to the download
+ // progress. The arc grows clockwise, starting in the midnight position, as
+ // the download progresses. However, if the download does not have known total
+ // size (the server didn't give us one), then we just spin an arc around until
+ // we're done.
+ float sweep_angle = 0.0;
+ float start_pos = static_cast<float>(kStartAngleDegrees);
+ if (percent_done < 0) {
+ sweep_angle = kUnknownAngleDegrees;
+ start_pos = static_cast<float>(start_angle);
+ } else if (percent_done > 0) {
+ sweep_angle = static_cast<float>(kMaxDegrees / 100.0 * percent_done);
+ }
+
+ // Set up an arc clipping region for the foreground image. Don't bother using
+ // a clipping region if it would round to 360 (really 0) degrees, since that
+ // would eliminate the foreground completely and be quite confusing (it would
+ // look like 0% complete when it should be almost 100%).
+ canvas->Save();
+ if (sweep_angle < static_cast<float>(kMaxDegrees - 1)) {
+ SkRect oval;
+ oval.set(SkIntToScalar(bounds.x()),
+ SkIntToScalar(bounds.y()),
+ SkIntToScalar(bounds.x() + image_size),
+ SkIntToScalar(bounds.y() + image_size));
+ SkPath path;
+ path.arcTo(oval,
+ SkFloatToScalar(start_pos),
+ SkFloatToScalar(sweep_angle), false);
+ path.lineTo(SkIntToScalar(bounds.x() + image_size / 2),
+ SkIntToScalar(bounds.y() + image_size / 2));
+
+ // gfx::Canvas::ClipPath does not provide for anti-aliasing.
+ canvas->sk_canvas()->clipPath(path, SkRegion::kIntersect_Op, true);
+ }
+
+ canvas->DrawImageInt(foreground_image,
+ bounds.x(),
+ bounds.y());
+ canvas->Restore();
+}
+
+
void PaintDownloadProgress(gfx::Canvas* canvas,
#if defined(TOOLKIT_VIEWS)
views::View* containing_view,
@@ -217,46 +272,9 @@ void PaintDownloadProgress(gfx::Canvas* canvas,
bounds.x(),
bounds.y());
- // Layer the foreground progress image in an arc proportional to the download
- // progress. The arc grows clockwise, starting in the midnight position, as
- // the download progresses. However, if the download does not have known total
- // size (the server didn't give us one), then we just spin an arc around until
- // we're done.
- float sweep_angle = 0.0;
- float start_pos = static_cast<float>(kStartAngleDegrees);
- if (percent_done < 0) {
- sweep_angle = kUnknownAngleDegrees;
- start_pos = static_cast<float>(start_angle);
- } else if (percent_done > 0) {
- sweep_angle = static_cast<float>(kMaxDegrees / 100.0 * percent_done);
- }
-
- // Set up an arc clipping region for the foreground image. Don't bother using
- // a clipping region if it would round to 360 (really 0) degrees, since that
- // would eliminate the foreground completely and be quite confusing (it would
- // look like 0% complete when it should be almost 100%).
- canvas->Save();
- if (sweep_angle < static_cast<float>(kMaxDegrees - 1)) {
- SkRect oval;
- oval.set(SkIntToScalar(bounds.x()),
- SkIntToScalar(bounds.y()),
- SkIntToScalar(bounds.x() + kProgressIconSize),
- SkIntToScalar(bounds.y() + kProgressIconSize));
- SkPath path;
- path.arcTo(oval,
- SkFloatToScalar(start_pos),
- SkFloatToScalar(sweep_angle), false);
- path.lineTo(SkIntToScalar(bounds.x() + kProgressIconSize / 2),
- SkIntToScalar(bounds.y() + kProgressIconSize / 2));
-
- // gfx::Canvas::ClipPath does not provide for anti-aliasing.
- canvas->sk_canvas()->clipPath(path, SkRegion::kIntersect_Op, true);
- }
-
- canvas->DrawImageInt(*foreground,
- bounds.x(),
- bounds.y());
- canvas->Restore();
+ PaintCustomDownloadProgress(canvas, *background, *foreground,
+ kProgressIconSize, bounds, start_angle,
+ percent_done);
}
void PaintDownloadComplete(gfx::Canvas* canvas,
diff --git a/chrome/browser/download/download_util.h b/chrome/browser/download/download_util.h
index 6d98314..183626c 100644
--- a/chrome/browser/download/download_util.h
+++ b/chrome/browser/download/download_util.h
@@ -32,6 +32,8 @@ class DownloadItem;
namespace gfx {
class Canvas;
class Image;
+class ImageSkia;
+class Rect;
}
namespace download_util {
@@ -91,6 +93,14 @@ enum PaintDownloadProgressSize {
// require the containing View in addition to the canvas because if we are
// drawing in a right-to-left locale, we need to mirror the position of the
// progress animation within the containing View.
+void PaintCustomDownloadProgress(gfx::Canvas* canvas,
+ const gfx::ImageSkia& background_image,
+ const gfx::ImageSkia& foreground_image,
+ int image_size,
+ const gfx::Rect& bounds,
+ int start_angle,
+ int percent_done);
+
void PaintDownloadProgress(gfx::Canvas* canvas,
#if defined(TOOLKIT_VIEWS)
views::View* containing_view,