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/browser_tabstrip.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 "ui/base/animation/animation.h" | 20 #include "ui/base/animation/animation.h" |
21 | 21 |
22 using content::DownloadItem; | 22 using content::DownloadItem; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 Show(); | 110 Show(); |
111 DoAddDownload(download); | 111 DoAddDownload(download); |
112 | 112 |
113 // browser() can be NULL for tests. | 113 // browser() can be NULL for tests. |
114 if (!browser()) | 114 if (!browser()) |
115 return; | 115 return; |
116 | 116 |
117 // Show the download started animation if: | 117 // Show the download started animation if: |
118 // - Download started animation is enabled for this download. It is disabled | 118 // - Download started animation is enabled for this download. It is disabled |
119 // for "Save As" downloads and extension installs, for example. | 119 // for "Save As" downloads and extension installs, for example. |
120 // - The browser has an active visble WebContents. (browser isn't minimized, | 120 // - The browser has an active visible WebContents. (browser isn't minimized, |
121 // or running under a test etc.) | 121 // or running under a test etc.) |
122 // - Rich animations are enabled. | 122 // - Rich animations are enabled. |
123 content::WebContents* shelf_tab = chrome::GetActiveWebContents(browser()); | 123 content::WebContents* shelf_tab = |
| 124 browser()->tab_strip_model()->GetActiveWebContents(); |
124 if (DownloadItemModel(download).ShouldShowDownloadStartedAnimation() && | 125 if (DownloadItemModel(download).ShouldShowDownloadStartedAnimation() && |
125 shelf_tab && | 126 shelf_tab && |
126 platform_util::IsVisible(shelf_tab->GetNativeView()) && | 127 platform_util::IsVisible(shelf_tab->GetNativeView()) && |
127 ui::Animation::ShouldRenderRichAnimation()) { | 128 ui::Animation::ShouldRenderRichAnimation()) { |
128 DownloadStartedAnimation::Show(shelf_tab); | 129 DownloadStartedAnimation::Show(shelf_tab); |
129 } | 130 } |
130 } | 131 } |
131 | 132 |
132 void DownloadShelf::ShowDownloadById(int32 download_id) { | 133 void DownloadShelf::ShowDownloadById(int32 download_id) { |
133 content::DownloadManager* download_manager = GetDownloadManager(); | 134 content::DownloadManager* download_manager = GetDownloadManager(); |
134 if (!download_manager) | 135 if (!download_manager) |
135 return; | 136 return; |
136 | 137 |
137 DownloadItem* download = download_manager->GetDownload(download_id); | 138 DownloadItem* download = download_manager->GetDownload(download_id); |
138 if (!download) | 139 if (!download) |
139 return; | 140 return; |
140 | 141 |
141 ShowDownload(download); | 142 ShowDownload(download); |
142 } | 143 } |
OLD | NEW |