diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-11 22:18:19 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-11 22:18:19 +0000 |
commit | 79114c013c0bb312c4efdda33935b2340187e6cf (patch) | |
tree | cd02466045448001b7cff19021e7fd002f841907 /chrome/browser/download | |
parent | 26ebce450f0e708eb8c173ce7b5a303a00b502a9 (diff) | |
download | chromium_src-79114c013c0bb312c4efdda33935b2340187e6cf.zip chromium_src-79114c013c0bb312c4efdda33935b2340187e6cf.tar.gz chromium_src-79114c013c0bb312c4efdda33935b2340187e6cf.tar.bz2 |
Download progress and complete animation on linux.
Review URL: http://codereview.chromium.org/113179
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r-- | chrome/browser/download/download_util.cc | 35 | ||||
-rw-r--r-- | chrome/browser/download/download_util.h | 16 |
2 files changed, 31 insertions, 20 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 6fefb6e..82b01b9 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -8,13 +8,9 @@ #include "chrome/browser/download/download_util.h" -#include "app/gfx/chrome_canvas.h" #include "app/l10n_util.h" -#include "app/os_exchange_data.h" #include "app/resource_bundle.h" -#include "base/base_drag_source.h" #include "base/file_util.h" -#include "base/scoped_clipboard_writer.h" #include "base/string_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/download/download_item_model.h" @@ -25,8 +21,12 @@ #include "skia/ext/image_operations.h" #include "skia/include/SkPath.h" #include "skia/include/SkShader.h" + +#if defined(OS_WIN) +#include "app/os_exchange_data.h" +#include "base/base_drag_source.h" #include "views/drag_utils.h" -#include "views/view.h" +#endif namespace download_util { @@ -66,14 +66,14 @@ SkBitmap* g_foreground_32 = NULL; SkBitmap* g_background_32 = NULL; void PaintDownloadProgress(ChromeCanvas* canvas, +#if defined(OS_WIN) views::View* containing_view, +#endif int origin_x, int origin_y, int start_angle, int percent_done, PaintDownloadProgressSize size) { - DCHECK(containing_view); - // Load up our common bitmaps if (!g_background_16) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -89,8 +89,6 @@ void PaintDownloadProgress(ChromeCanvas* canvas, const int kProgressIconSize = (size == BIG) ? kBigProgressIconSize : kSmallProgressIconSize; - int height = background->height(); - // We start by storing the bounds of the background and foreground bitmaps // so that it is easy to mirror the bounds if the UI layout is RTL. gfx::Rect background_bounds(origin_x, origin_y, @@ -98,11 +96,13 @@ void PaintDownloadProgress(ChromeCanvas* canvas, gfx::Rect foreground_bounds(origin_x, origin_y, foreground->width(), foreground->height()); +#if defined(OS_WIN) // Mirror the positions if necessary. int mirrored_x = containing_view->MirroredLeftPointForRect(background_bounds); background_bounds.set_x(mirrored_x); mirrored_x = containing_view->MirroredLeftPointForRect(foreground_bounds); foreground_bounds.set_x(mirrored_x); +#endif // Draw the background progress image. SkPaint background_paint; @@ -165,13 +165,13 @@ void PaintDownloadProgress(ChromeCanvas* canvas, } void PaintDownloadComplete(ChromeCanvas* canvas, +#if defined(OS_WIN) views::View* containing_view, +#endif int origin_x, int origin_y, double animation_progress, PaintDownloadProgressSize size) { - DCHECK(containing_view); - // Load up our common bitmaps. if (!g_foreground_16) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); @@ -181,11 +181,13 @@ void PaintDownloadComplete(ChromeCanvas* canvas, SkBitmap* complete = (size == BIG) ? g_foreground_32 : g_foreground_16; - // Mirror the positions if necessary. gfx::Rect complete_bounds(origin_x, origin_y, complete->width(), complete->height()); +#if defined(OS_WIN) + // Mirror the positions if necessary. complete_bounds.set_x( containing_view->MirroredLeftPointForRect(complete_bounds)); +#endif // Start at full opacity, then loop back and forth five times before ending // at zero opacity. @@ -211,8 +213,9 @@ void PaintDownloadComplete(ChromeCanvas* canvas, int GetBigProgressIconSize() { static int big_progress_icon_size = 0; if (big_progress_icon_size == 0) { - std::wstring locale_size_str = - l10n_util::GetString(IDS_DOWNLOAD_BIG_PROGRESS_SIZE); + string16 locale_size_str = + WideToUTF16Hack( + l10n_util::GetString(IDS_DOWNLOAD_BIG_PROGRESS_SIZE)); bool rc = StringToInt(locale_size_str, &big_progress_icon_size); if (!rc || big_progress_icon_size < kBigProgressIconSize) { NOTREACHED(); @@ -227,6 +230,7 @@ int GetBigProgressIconOffset() { return (GetBigProgressIconSize() - kBigIconSize) / 2; } +#if defined(OS_WIN) // Download dragging void DragDownload(const DownloadItem* download, SkBitmap* icon) { DCHECK(download); @@ -244,5 +248,6 @@ void DragDownload(const DownloadItem* download, SkBitmap* icon) { DoDragDrop(data.get(), drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK, &effects); } +#endif } // namespace download_util diff --git a/chrome/browser/download/download_util.h b/chrome/browser/download/download_util.h index a8122ce..f3c658f 100644 --- a/chrome/browser/download/download_util.h +++ b/chrome/browser/download/download_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -7,16 +7,16 @@ #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_UTIL_H_ -#include <objidl.h> - #include <set> #include <string> +#include "app/gfx/chrome_canvas.h" #include "base/basictypes.h" #include "base/task.h" -#include "views/controls/menu/menu.h" -#include "views/event.h" + +#if defined(OS_WIN) #include "views/view.h" +#endif class BaseDownloadItemModel; class DownloadItem; @@ -98,7 +98,9 @@ enum PaintDownloadProgressSize { // drawing in a right-to-left locale, we need to mirror the position of the // progress animation within the containing View. void PaintDownloadProgress(ChromeCanvas* canvas, +#if defined(OS_WIN) views::View* containing_view, +#endif int origin_x, int origin_y, int start_angle, @@ -106,12 +108,15 @@ void PaintDownloadProgress(ChromeCanvas* canvas, PaintDownloadProgressSize size); void PaintDownloadComplete(ChromeCanvas* canvas, +#if defined(OS_WIN) views::View* containing_view, +#endif int origin_x, int origin_y, double animation_progress, PaintDownloadProgressSize size); +#if defined(OS_WIN) // Drag support ---------------------------------------------------------------- // Helper function for download views to use when acting as a drag source for a @@ -122,6 +127,7 @@ void DragDownload(const DownloadItem* download, SkBitmap* icon); // Copy all executable file extensions. void InitializeExeTypes(std::set<std::string>* exe_extensions); +#endif } // namespace download_util |