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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 *ret_num1 = num1; | 275 *ret_num1 = num1; |
276 *ret_num2 = num2; | 276 *ret_num2 = num2; |
277 return true; | 277 return true; |
278 } | 278 } |
279 | 279 |
280 bool AllowPanels(const std::string& app_name) { | 280 bool AllowPanels(const std::string& app_name) { |
281 return PanelManager::ShouldUsePanels( | 281 return PanelManager::ShouldUsePanels( |
282 web_app::GetExtensionIdFromApplicationName(app_name)); | 282 web_app::GetExtensionIdFromApplicationName(app_name)); |
283 } | 283 } |
284 | 284 |
285 bool DisplayOldDownloadsUI() { | |
286 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
287 switches::kDownloadsNewUI); | |
288 } | |
289 | |
290 } // namespace | 285 } // namespace |
291 | 286 |
292 //////////////////////////////////////////////////////////////////////////////// | 287 //////////////////////////////////////////////////////////////////////////////// |
293 // Browser, CreateParams: | 288 // Browser, CreateParams: |
294 | 289 |
295 Browser::CreateParams::CreateParams() | 290 Browser::CreateParams::CreateParams() |
296 : type(TYPE_TABBED), | 291 : type(TYPE_TABBED), |
297 profile(NULL), | 292 profile(NULL), |
298 initial_show_state(ui::SHOW_STATE_DEFAULT), | 293 initial_show_state(ui::SHOW_STATE_DEFAULT), |
299 is_session_restore(false) { | 294 is_session_restore(false) { |
(...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3155 if (constrained != tab_contents) { | 3150 if (constrained != tab_contents) { |
3156 // Download in a constrained popup is shown in the tab that opened it. | 3151 // Download in a constrained popup is shown in the tab that opened it. |
3157 WebContents* constrained_tab = constrained->web_contents(); | 3152 WebContents* constrained_tab = constrained->web_contents(); |
3158 constrained_tab->GetDelegate()->OnStartDownload(constrained_tab, download); | 3153 constrained_tab->GetDelegate()->OnStartDownload(constrained_tab, download); |
3159 return; | 3154 return; |
3160 } | 3155 } |
3161 | 3156 |
3162 if (!window()) | 3157 if (!window()) |
3163 return; | 3158 return; |
3164 | 3159 |
3165 if (DisplayOldDownloadsUI()) { | 3160 // GetDownloadShelf creates the download shelf if it was not yet created. |
3166 // GetDownloadShelf creates the download shelf if it was not yet created. | 3161 DownloadShelf* shelf = window()->GetDownloadShelf(); |
3167 DownloadShelf* shelf = window()->GetDownloadShelf(); | 3162 shelf->AddDownload(new DownloadItemModel(download)); |
3168 shelf->AddDownload(new DownloadItemModel(download)); | 3163 // Don't show the animation for "Save file" downloads. |
3169 // Don't show the animation for "Save file" downloads. | 3164 // For non-theme extensions, we don't show the download animation. |
3170 // For non-theme extensions, we don't show the download animation. | 3165 // Show animation in same window as the download shelf. Download shelf |
3171 // Show animation in same window as the download shelf. Download shelf | 3166 // may not be in the same window that initiated the download, e.g. |
3172 // may not be in the same window that initiated the download, e.g. | 3167 // Panels. |
3173 // Panels. | 3168 // Don't show the animation if the selected tab is not visible (i.e. the |
3174 // Don't show the animation if the selected tab is not visible (i.e. the | 3169 // window is minimized, we're in a unit test, etc.). |
3175 // window is minimized, we're in a unit test, etc.). | 3170 WebContents* shelf_tab = shelf->browser()->GetActiveWebContents(); |
3176 WebContents* shelf_tab = shelf->browser()->GetActiveWebContents(); | 3171 if ((download->GetTotalBytes() > 0) && |
3177 if ((download->GetTotalBytes() > 0) && | 3172 !download_crx_util::IsExtensionDownload(*download) && |
3178 !download_crx_util::IsExtensionDownload(*download) && | 3173 platform_util::IsVisible(shelf_tab->GetNativeView()) && |
3179 platform_util::IsVisible(shelf_tab->GetNativeView()) && | 3174 ui::Animation::ShouldRenderRichAnimation()) { |
3180 ui::Animation::ShouldRenderRichAnimation()) { | 3175 DownloadStartedAnimation::Show(shelf_tab); |
3181 DownloadStartedAnimation::Show(shelf_tab); | |
3182 } | |
3183 } | 3176 } |
3184 | 3177 |
3185 // If the download occurs in a new tab, close it. | 3178 // If the download occurs in a new tab, close it. |
3186 if (source->GetController().IsInitialNavigation() && tab_count() > 1) | 3179 if (source->GetController().IsInitialNavigation() && tab_count() > 1) |
3187 CloseContents(source); | 3180 CloseContents(source); |
3188 } | 3181 } |
3189 | 3182 |
3190 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { | 3183 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { |
3191 DCHECK(source); | 3184 DCHECK(source); |
3192 TabContents* tab_contents = GetTabContentsAt( | 3185 TabContents* tab_contents = GetTabContentsAt( |
(...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4941 if (contents && !allow_js_access) { | 4934 if (contents && !allow_js_access) { |
4942 contents->web_contents()->GetController().LoadURL( | 4935 contents->web_contents()->GetController().LoadURL( |
4943 target_url, | 4936 target_url, |
4944 content::Referrer(), | 4937 content::Referrer(), |
4945 content::PAGE_TRANSITION_LINK, | 4938 content::PAGE_TRANSITION_LINK, |
4946 std::string()); // No extra headers. | 4939 std::string()); // No extra headers. |
4947 } | 4940 } |
4948 | 4941 |
4949 return contents != NULL; | 4942 return contents != NULL; |
4950 } | 4943 } |
OLD | NEW |