| 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/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "chrome/browser/download/download_item_model.h" | 15 #include "chrome/browser/download/download_item_model.h" |
| 16 #include "chrome/browser/download/download_service.h" | 16 #include "chrome/browser/download/download_service.h" |
| 17 #include "chrome/browser/download/download_service_factory.h" | 17 #include "chrome/browser/download/download_service_factory.h" |
| 18 #include "chrome/browser/download/download_started_animation.h" | 18 #include "chrome/browser/download/download_started_animation.h" |
| 19 #include "chrome/browser/platform_util.h" | 19 #include "chrome/browser/platform_util.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 23 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
| 24 #include "content/public/browser/download_item.h" | 24 #include "content/public/browser/download_item.h" |
| 25 #include "content/public/browser/download_manager.h" | 25 #include "content/public/browser/download_manager.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_contents_view.h" | 27 #include "content/public/browser/web_contents_view.h" |
| 28 #include "grit/locale_settings.h" | 28 #include "grit/locale_settings.h" |
| 29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 30 #include "ui/base/animation/animation.h" | |
| 31 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/gfx/animation/animation.h" |
| 33 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
| 34 #include "ui/gfx/image/image_skia.h" | 34 #include "ui/gfx/image/image_skia.h" |
| 35 | 35 |
| 36 #if defined(TOOLKIT_VIEWS) | 36 #if defined(TOOLKIT_VIEWS) |
| 37 #include "ui/views/view.h" | 37 #include "ui/views/view.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 using content::DownloadItem; | 40 using content::DownloadItem; |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 // - Download started animation is enabled for this download. It is disabled | 354 // - Download started animation is enabled for this download. It is disabled |
| 355 // for "Save As" downloads and extension installs, for example. | 355 // for "Save As" downloads and extension installs, for example. |
| 356 // - The browser has an active visible WebContents. (browser isn't minimized, | 356 // - The browser has an active visible WebContents. (browser isn't minimized, |
| 357 // or running under a test etc.) | 357 // or running under a test etc.) |
| 358 // - Rich animations are enabled. | 358 // - Rich animations are enabled. |
| 359 content::WebContents* shelf_tab = | 359 content::WebContents* shelf_tab = |
| 360 browser()->tab_strip_model()->GetActiveWebContents(); | 360 browser()->tab_strip_model()->GetActiveWebContents(); |
| 361 if (DownloadItemModel(download).ShouldShowDownloadStartedAnimation() && | 361 if (DownloadItemModel(download).ShouldShowDownloadStartedAnimation() && |
| 362 shelf_tab && | 362 shelf_tab && |
| 363 platform_util::IsVisible(shelf_tab->GetView()->GetNativeView()) && | 363 platform_util::IsVisible(shelf_tab->GetView()->GetNativeView()) && |
| 364 ui::Animation::ShouldRenderRichAnimation()) { | 364 gfx::Animation::ShouldRenderRichAnimation()) { |
| 365 DownloadStartedAnimation::Show(shelf_tab); | 365 DownloadStartedAnimation::Show(shelf_tab); |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 | 368 |
| 369 void DownloadShelf::ShowDownloadById(int32 download_id) { | 369 void DownloadShelf::ShowDownloadById(int32 download_id) { |
| 370 content::DownloadManager* download_manager = GetDownloadManager(); | 370 content::DownloadManager* download_manager = GetDownloadManager(); |
| 371 if (!download_manager) | 371 if (!download_manager) |
| 372 return; | 372 return; |
| 373 | 373 |
| 374 DownloadItem* download = download_manager->GetDownload(download_id); | 374 DownloadItem* download = download_manager->GetDownload(download_id); |
| 375 if (!download) | 375 if (!download) |
| 376 return; | 376 return; |
| 377 | 377 |
| 378 ShowDownload(download); | 378 ShowDownload(download); |
| 379 } | 379 } |
| OLD | NEW |