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 #include "chrome/browser/download/download_shelf.h" | 5 #include "chrome/browser/download/download_shelf.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
11 #include "chrome/browser/download/download_started_animation.h" | 11 #include "chrome/browser/download/download_started_animation.h" |
12 #include "chrome/browser/platform_util.h" | 12 #include "chrome/browser/platform_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
17 #include "content/public/browser/download_item.h" | 17 #include "content/public/browser/download_item.h" |
18 #include "content/public/browser/download_manager.h" | 18 #include "content/public/browser/download_manager.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_view.h" |
20 #include "ui/base/animation/animation.h" | 21 #include "ui/base/animation/animation.h" |
21 | 22 |
22 using content::DownloadItem; | 23 using content::DownloadItem; |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 // Delay before we show a transient download. | 27 // Delay before we show a transient download. |
27 const int64 kDownloadShowDelayInSeconds = 2; | 28 const int64 kDownloadShowDelayInSeconds = 2; |
28 | 29 |
29 } // namespace | 30 } // namespace |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // Show the download started animation if: | 118 // Show the download started animation if: |
118 // - Download started animation is enabled for this download. It is disabled | 119 // - Download started animation is enabled for this download. It is disabled |
119 // for "Save As" downloads and extension installs, for example. | 120 // for "Save As" downloads and extension installs, for example. |
120 // - The browser has an active visible WebContents. (browser isn't minimized, | 121 // - The browser has an active visible WebContents. (browser isn't minimized, |
121 // or running under a test etc.) | 122 // or running under a test etc.) |
122 // - Rich animations are enabled. | 123 // - Rich animations are enabled. |
123 content::WebContents* shelf_tab = | 124 content::WebContents* shelf_tab = |
124 browser()->tab_strip_model()->GetActiveWebContents(); | 125 browser()->tab_strip_model()->GetActiveWebContents(); |
125 if (DownloadItemModel(download).ShouldShowDownloadStartedAnimation() && | 126 if (DownloadItemModel(download).ShouldShowDownloadStartedAnimation() && |
126 shelf_tab && | 127 shelf_tab && |
127 platform_util::IsVisible(shelf_tab->GetNativeView()) && | 128 platform_util::IsVisible(shelf_tab->GetView()->GetNativeView()) && |
128 ui::Animation::ShouldRenderRichAnimation()) { | 129 ui::Animation::ShouldRenderRichAnimation()) { |
129 DownloadStartedAnimation::Show(shelf_tab); | 130 DownloadStartedAnimation::Show(shelf_tab); |
130 } | 131 } |
131 } | 132 } |
132 | 133 |
133 void DownloadShelf::ShowDownloadById(int32 download_id) { | 134 void DownloadShelf::ShowDownloadById(int32 download_id) { |
134 content::DownloadManager* download_manager = GetDownloadManager(); | 135 content::DownloadManager* download_manager = GetDownloadManager(); |
135 if (!download_manager) | 136 if (!download_manager) |
136 return; | 137 return; |
137 | 138 |
138 DownloadItem* download = download_manager->GetDownload(download_id); | 139 DownloadItem* download = download_manager->GetDownload(download_id); |
139 if (!download) | 140 if (!download) |
140 return; | 141 return; |
141 | 142 |
142 ShowDownload(download); | 143 ShowDownload(download); |
143 } | 144 } |
OLD | NEW |