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

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: nits 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
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 3343 matching lines...) Expand 10 before | Expand all | Expand 10 after
3354 } 3354 }
3355 3355
3356 void Browser::RenderWidgetShowing() { 3356 void Browser::RenderWidgetShowing() {
3357 window_->DisableInactiveFrame(); 3357 window_->DisableInactiveFrame();
3358 } 3358 }
3359 3359
3360 int Browser::GetExtraRenderViewHeight() const { 3360 int Browser::GetExtraRenderViewHeight() const {
3361 return window_->GetExtraRenderViewHeight(); 3361 return window_->GetExtraRenderViewHeight();
3362 } 3362 }
3363 3363
3364 namespace {
3365 bool DisplayOldDownloadsUI() {
cbentzel 2011/08/15 18:28:26 Nit: extra newlines here.
benjhayden 2011/08/15 19:15:36 Done.
3366 return !CommandLine::ForCurrentProcess()->HasSwitch(
3367 switches::kDownloadsNewUI);
3368 }
3369 } // anonymous namespace
3370
3364 void Browser::OnStartDownload(TabContents* source, DownloadItem* download) { 3371 void Browser::OnStartDownload(TabContents* source, DownloadItem* download) {
3365 TabContentsWrapper* wrapper = 3372 TabContentsWrapper* wrapper =
3366 TabContentsWrapper::GetCurrentWrapperForContents(source); 3373 TabContentsWrapper::GetCurrentWrapperForContents(source);
3367 TabContentsWrapper* constrained = GetConstrainingContentsWrapper(wrapper); 3374 TabContentsWrapper* constrained = GetConstrainingContentsWrapper(wrapper);
3368 if (constrained != wrapper) { 3375 if (constrained != wrapper) {
3369 // Download in a constrained popup is shown in the tab that opened it. 3376 // Download in a constrained popup is shown in the tab that opened it.
3370 TabContents* constrained_tab = constrained->tab_contents(); 3377 TabContents* constrained_tab = constrained->tab_contents();
3371 constrained_tab->delegate()->OnStartDownload(constrained_tab, download); 3378 constrained_tab->delegate()->OnStartDownload(constrained_tab, download);
3372 return; 3379 return;
3373 } 3380 }
3374 3381
3375 if (!window()) 3382 if (!window())
3376 return; 3383 return;
3377 3384
3385 if (DisplayOldDownloadsUI()) {
3378 #if defined(OS_CHROMEOS) 3386 #if defined(OS_CHROMEOS)
3379 // Don't show content browser for extension/theme downloads from gallery. 3387 // Don't show content browser for extension/theme downloads from gallery.
3380 if (download->is_extension_install()) {
3381 ExtensionService* service = profile_->GetExtensionService(); 3388 ExtensionService* service = profile_->GetExtensionService();
3382 if (service && service->IsDownloadFromGallery(download->GetURL(), 3389 if (!download->is_extension_install() ||
3383 download->referrer_url())) { 3390 (service == NULL) ||
3384 return; 3391 !service->IsDownloadFromGallery(download->GetURL(),
3392 download->referrer_url())) {
3393 // Open the Active Downloads ui for chromeos.
3394 ActiveDownloadsUI::OpenPopup(profile_);
3385 } 3395 }
3396 #else
3397 // GetDownloadShelf creates the download shelf if it was not yet created.
cbentzel 2011/08/15 18:28:26 I haven't looked at what happens if there isn't a
benjhayden 2011/08/15 19:15:36 Downloads still proceed. I haven't run all the tes
3398 DownloadShelf* shelf = window()->GetDownloadShelf();
3399 shelf->AddDownload(new DownloadItemModel(download));
3400
3401 // Don't show the animation for "Save file" downloads.
3402 if (download->total_bytes() > 0) {
Peter Kasting 2011/08/15 18:34:02 Nit: If you're going to change the early-return st
benjhayden 2011/08/15 19:15:36 Unfortunately, I can't merge these conditionals wi
Peter Kasting 2011/08/15 19:19:13 You misunderstand me. I don't mean to merge the C
benjhayden 2011/08/15 19:51:42 Done.
3403 // For non-theme extensions, we don't show the download animation.
3404 if (!download->is_extension_install() ||
3405 ExtensionService::IsDownloadFromMiniGallery(download->GetURL())) {
3406 // Show animation in same window as the download shelf. Download shelf
3407 // may not be in the same window that initiated the download, e.g.
3408 // Panels.
3409 TabContents* shelf_tab = shelf->browser()->GetSelectedTabContents();
3410
3411 // We make this check for the case of minimized windows, unit tests,
3412 // etc.
3413 if (platform_util::IsVisible(shelf_tab->GetNativeView()) &&
3414 ui::Animation::ShouldRenderRichAnimation()) {
3415 DownloadStartedAnimation::Show(shelf_tab);
3416 }
3417 }
3418 }
3419 #endif
3386 } 3420 }
3387 // Open the Active Downloads ui for chromeos.
3388 ActiveDownloadsUI::OpenPopup(profile_);
3389 #else
3390 // GetDownloadShelf creates the download shelf if it was not yet created.
3391 DownloadShelf* shelf = window()->GetDownloadShelf();
3392 shelf->AddDownload(new DownloadItemModel(download));
3393
3394 // Don't show the animation for "Save file" downloads.
3395 if (download->total_bytes() <= 0)
3396 return;
3397
3398 // For non-theme extensions, we don't show the download animation.
3399 if (download->is_extension_install() &&
3400 !ExtensionService::IsDownloadFromMiniGallery(download->GetURL()))
3401 return;
3402
3403 // Show animation in same window as the download shelf. Download shelf
3404 // may not be in the same window that initiated the download, e.g. Panels.
3405 TabContents* shelf_tab = shelf->browser()->GetSelectedTabContents();
3406
3407 // We make this check for the case of minimized windows, unit tests, etc.
3408 if (platform_util::IsVisible(shelf_tab->GetNativeView()) &&
3409 ui::Animation::ShouldRenderRichAnimation()) {
3410 DownloadStartedAnimation::Show(shelf_tab);
3411 }
3412 #endif
3413 3421
3414 // If the download occurs in a new tab, close it. 3422 // If the download occurs in a new tab, close it.
3415 if (source->controller().IsInitialNavigation() && tab_count() > 1) 3423 if (source->controller().IsInitialNavigation() && tab_count() > 1)
3416 CloseContents(source); 3424 CloseContents(source);
3417 } 3425 }
3418 3426
3419 void Browser::ShowPageInfo(content::BrowserContext* browser_context, 3427 void Browser::ShowPageInfo(content::BrowserContext* browser_context,
3420 const GURL& url, 3428 const GURL& url,
3421 const NavigationEntry::SSLStatus& ssl, 3429 const NavigationEntry::SSLStatus& ssl,
3422 bool show_history) { 3430 bool show_history) {
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
4836 } 4844 }
4837 4845
4838 void Browser::ShowSyncSetup() { 4846 void Browser::ShowSyncSetup() {
4839 ProfileSyncService* service = 4847 ProfileSyncService* service =
4840 profile()->GetOriginalProfile()->GetProfileSyncService(); 4848 profile()->GetOriginalProfile()->GetProfileSyncService();
4841 if (service->HasSyncSetupCompleted()) 4849 if (service->HasSyncSetupCompleted())
4842 ShowOptionsTab(chrome::kSyncSetupSubPage); 4850 ShowOptionsTab(chrome::kSyncSetupSubPage);
4843 else 4851 else
4844 service->ShowLoginDialog(); 4852 service->ShowLoginDialog();
4845 } 4853 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698