Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 7605003: --downloads-new-ui completely disables the download shelf. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: " Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 3361 matching lines...) Expand 10 before | Expand all | Expand 10 after
3372 } 3372 }
3373 3373
3374 void Browser::RenderWidgetShowing() { 3374 void Browser::RenderWidgetShowing() {
3375 window_->DisableInactiveFrame(); 3375 window_->DisableInactiveFrame();
3376 } 3376 }
3377 3377
3378 int Browser::GetExtraRenderViewHeight() const { 3378 int Browser::GetExtraRenderViewHeight() const {
3379 return window_->GetExtraRenderViewHeight(); 3379 return window_->GetExtraRenderViewHeight();
3380 } 3380 }
3381 3381
3382 namespace {
3383
3384 bool DisplayOldDownloadsUI() {
3385 return !CommandLine::ForCurrentProcess()->HasSwitch(
3386 switches::kDownloadsNewUI);
3387 }
3388
3389 } // anonymous namespace
3390
3382 void Browser::OnStartDownload(TabContents* source, DownloadItem* download) { 3391 void Browser::OnStartDownload(TabContents* source, DownloadItem* download) {
3383 TabContentsWrapper* wrapper = 3392 TabContentsWrapper* wrapper =
3384 TabContentsWrapper::GetCurrentWrapperForContents(source); 3393 TabContentsWrapper::GetCurrentWrapperForContents(source);
3385 TabContentsWrapper* constrained = GetConstrainingContentsWrapper(wrapper); 3394 TabContentsWrapper* constrained = GetConstrainingContentsWrapper(wrapper);
3386 if (constrained != wrapper) { 3395 if (constrained != wrapper) {
3387 // Download in a constrained popup is shown in the tab that opened it. 3396 // Download in a constrained popup is shown in the tab that opened it.
3388 TabContents* constrained_tab = constrained->tab_contents(); 3397 TabContents* constrained_tab = constrained->tab_contents();
3389 constrained_tab->delegate()->OnStartDownload(constrained_tab, download); 3398 constrained_tab->delegate()->OnStartDownload(constrained_tab, download);
3390 return; 3399 return;
3391 } 3400 }
3392 3401
3393 if (!window()) 3402 if (!window())
3394 return; 3403 return;
3395 3404
3405 if (DisplayOldDownloadsUI()) {
3396 #if defined(OS_CHROMEOS) 3406 #if defined(OS_CHROMEOS)
3397 // Don't show content browser for extension/theme downloads from gallery. 3407 // Don't show content browser for extension/theme downloads from gallery.
3398 if (download->is_extension_install()) {
3399 ExtensionService* service = profile_->GetExtensionService(); 3408 ExtensionService* service = profile_->GetExtensionService();
3400 if (service && service->IsDownloadFromGallery(download->GetURL(), 3409 if (!download->is_extension_install() ||
3401 download->referrer_url())) { 3410 (service == NULL) ||
3402 return; 3411 !service->IsDownloadFromGallery(download->GetURL(),
3412 download->referrer_url())) {
3413 // Open the Active Downloads ui for chromeos.
3414 ActiveDownloadsUI::OpenPopup(profile_);
3403 } 3415 }
3416 #else
3417 // GetDownloadShelf creates the download shelf if it was not yet created.
3418 DownloadShelf* shelf = window()->GetDownloadShelf();
3419 shelf->AddDownload(new DownloadItemModel(download));
3420 // Don't show the animation for "Save file" downloads.
3421 // For non-theme extensions, we don't show the download animation.
3422 // Show animation in same window as the download shelf. Download shelf
3423 // may not be in the same window that initiated the download, e.g.
3424 // Panels.
3425 // Don't show the animation if the selected tab is not visible (i.e. the
3426 // window is minimized, we're in a unit test, etc.).
3427 TabContents* shelf_tab = shelf->browser()->GetSelectedTabContents();
3428 if ((download->total_bytes() > 0) &&
3429 (!download->is_extension_install() ||
3430 ExtensionService::IsDownloadFromMiniGallery(download->GetURL())) &&
3431 platform_util::IsVisible(shelf_tab->GetNativeView()) &&
3432 ui::Animation::ShouldRenderRichAnimation()) {
3433 DownloadStartedAnimation::Show(shelf_tab);
3434 }
3435 #endif
3404 } 3436 }
3405 // Open the Active Downloads ui for chromeos.
3406 ActiveDownloadsUI::OpenPopup(profile_);
3407 #else
3408 // GetDownloadShelf creates the download shelf if it was not yet created.
3409 DownloadShelf* shelf = window()->GetDownloadShelf();
3410 shelf->AddDownload(new DownloadItemModel(download));
3411
3412 // Don't show the animation for "Save file" downloads.
3413 if (download->total_bytes() <= 0)
3414 return;
3415
3416 // For non-theme extensions, we don't show the download animation.
3417 if (download->is_extension_install() &&
3418 !ExtensionService::IsDownloadFromMiniGallery(download->GetURL()))
3419 return;
3420
3421 // Show animation in same window as the download shelf. Download shelf
3422 // may not be in the same window that initiated the download, e.g. Panels.
3423 TabContents* shelf_tab = shelf->browser()->GetSelectedTabContents();
3424
3425 // We make this check for the case of minimized windows, unit tests, etc.
3426 if (platform_util::IsVisible(shelf_tab->GetNativeView()) &&
3427 ui::Animation::ShouldRenderRichAnimation()) {
3428 DownloadStartedAnimation::Show(shelf_tab);
3429 }
3430 #endif
3431 3437
3432 // If the download occurs in a new tab, close it. 3438 // If the download occurs in a new tab, close it.
3433 if (source->controller().IsInitialNavigation() && tab_count() > 1) 3439 if (source->controller().IsInitialNavigation() && tab_count() > 1)
3434 CloseContents(source); 3440 CloseContents(source);
3435 } 3441 }
3436 3442
3437 void Browser::ShowPageInfo(content::BrowserContext* browser_context, 3443 void Browser::ShowPageInfo(content::BrowserContext* browser_context,
3438 const GURL& url, 3444 const GURL& url,
3439 const NavigationEntry::SSLStatus& ssl, 3445 const NavigationEntry::SSLStatus& ssl,
3440 bool show_history) { 3446 bool show_history) {
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
4854 } 4860 }
4855 4861
4856 void Browser::ShowSyncSetup() { 4862 void Browser::ShowSyncSetup() {
4857 ProfileSyncService* service = 4863 ProfileSyncService* service =
4858 profile()->GetOriginalProfile()->GetProfileSyncService(); 4864 profile()->GetOriginalProfile()->GetProfileSyncService();
4859 if (service->HasSyncSetupCompleted()) 4865 if (service->HasSyncSetupCompleted())
4860 ShowOptionsTab(chrome::kSyncSetupSubPage); 4866 ShowOptionsTab(chrome::kSyncSetupSubPage);
4861 else 4867 else
4862 service->ShowLoginDialog(); 4868 service->ShowLoginDialog();
4863 } 4869 }
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698