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

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

Issue 7374008: Move download stuff from download helper back to TabContents. This is basically a revert of r8576... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 5 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/ui/browser.h ('k') | chrome/browser/ui/download/download_tab_helper.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 3296 matching lines...) Expand 10 before | Expand all | Expand 10 after
3307 } 3307 }
3308 3308
3309 void Browser::RenderWidgetShowing() { 3309 void Browser::RenderWidgetShowing() {
3310 window_->DisableInactiveFrame(); 3310 window_->DisableInactiveFrame();
3311 } 3311 }
3312 3312
3313 int Browser::GetExtraRenderViewHeight() const { 3313 int Browser::GetExtraRenderViewHeight() const {
3314 return window_->GetExtraRenderViewHeight(); 3314 return window_->GetExtraRenderViewHeight();
3315 } 3315 }
3316 3316
3317 void Browser::OnStartDownload(DownloadItem* download, TabContents* tab) {
3318 TabContentsWrapper* wrapper =
3319 TabContentsWrapper::GetCurrentWrapperForContents(tab);
3320 TabContentsWrapper* constrained = GetConstrainingContentsWrapper(wrapper);
3321 if (constrained != wrapper) {
3322 // Download in a constrained popup is shown in the tab that opened it.
3323 TabContents* constrained_tab = constrained->tab_contents();
3324 constrained_tab->delegate()->OnStartDownload(download, constrained_tab);
3325 return;
3326 }
3327
3328 if (!window())
3329 return;
3330
3331 #if defined(OS_CHROMEOS)
3332 // Don't show content browser for extension/theme downloads from gallery.
3333 if (download->is_extension_install()) {
3334 ExtensionService* service = profile_->GetExtensionService();
3335 if (service && service->IsDownloadFromGallery(download->url(),
3336 download->referrer_url())) {
3337 return;
3338 }
3339 }
3340 // Open the Active Downloads ui for chromeos.
3341 ActiveDownloadsUI::OpenPopup(profile_);
3342 #else
3343 // GetDownloadShelf creates the download shelf if it was not yet created.
3344 window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download));
3345
3346 // Don't show the animation for "Save file" downloads.
3347 if (download->total_bytes() <= 0)
3348 return;
3349
3350 // For non-theme extensions, we don't show the download animation.
3351 if (download->is_extension_install() &&
3352 !ExtensionService::IsDownloadFromMiniGallery(download->url()))
3353 return;
3354
3355 TabContents* current_tab = GetSelectedTabContents();
3356 // We make this check for the case of minimized windows, unit tests, etc.
3357 if (platform_util::IsVisible(current_tab->GetNativeView()) &&
3358 ui::Animation::ShouldRenderRichAnimation()) {
3359 DownloadStartedAnimation::Show(current_tab);
3360 }
3361 #endif
3362
3363 // If the download occurs in a new tab, close it.
3364 TabContentsWrapper* wrapper =
3365 TabContentsWrapper::GetCurrentWrapperForContents(tab);
3366 if (tab->controller().IsInitialNavigation() &&
3367 GetConstrainingContentsWrapper(wrapper) == wrapper && tab_count() > 1) {
3368 CloseContents(tab);
3369 }
3370 }
3371
3317 void Browser::ShowPageInfo(Profile* profile, 3372 void Browser::ShowPageInfo(Profile* profile,
3318 const GURL& url, 3373 const GURL& url,
3319 const NavigationEntry::SSLStatus& ssl, 3374 const NavigationEntry::SSLStatus& ssl,
3320 bool show_history) { 3375 bool show_history) {
3321 window()->ShowPageInfo(profile, url, ssl, show_history); 3376 window()->ShowPageInfo(profile, url, ssl, show_history);
3322 } 3377 }
3323 3378
3324 void Browser::ViewSourceForTab(TabContents* source, const GURL& page_url) { 3379 void Browser::ViewSourceForTab(TabContents* source, const GURL& page_url) {
3325 DCHECK(source); 3380 DCHECK(source);
3326 int index = tabstrip_model()->GetWrapperIndex(source); 3381 int index = tabstrip_model()->GetWrapperIndex(source);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
3468 3523
3469 /////////////////////////////////////////////////////////////////////////////// 3524 ///////////////////////////////////////////////////////////////////////////////
3470 // Browser, BookmarkTabHelperDelegate implementation: 3525 // Browser, BookmarkTabHelperDelegate implementation:
3471 3526
3472 void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) { 3527 void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) {
3473 if (source == GetSelectedTabContentsWrapper()) 3528 if (source == GetSelectedTabContentsWrapper())
3474 window_->SetStarredState(starred); 3529 window_->SetStarredState(starred);
3475 } 3530 }
3476 3531
3477 /////////////////////////////////////////////////////////////////////////////// 3532 ///////////////////////////////////////////////////////////////////////////////
3478 // Browser, DownloadTabHelperDelegate implementation:
3479
3480 bool Browser::CanDownload(int request_id) {
3481 return true;
3482 }
3483
3484 void Browser::OnStartDownload(DownloadItem* download, TabContentsWrapper* tab) {
3485 if (!window())
3486 return;
3487
3488 #if defined(OS_CHROMEOS)
3489 // Don't show content browser for extension/theme downloads from gallery.
3490 if (download->is_extension_install()) {
3491 ExtensionService* service = profile_->GetExtensionService();
3492 if (service && service->IsDownloadFromGallery(download->GetURL(),
3493 download->referrer_url())) {
3494 return;
3495 }
3496 }
3497 // Open the Active Downloads ui for chromeos.
3498 ActiveDownloadsUI::OpenPopup(profile_);
3499 #else
3500 // GetDownloadShelf creates the download shelf if it was not yet created.
3501 window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download));
3502
3503 // Don't show the animation for "Save file" downloads.
3504 if (download->total_bytes() <= 0)
3505 return;
3506
3507 // For non-theme extensions, we don't show the download animation.
3508 if (download->is_extension_install() &&
3509 !ExtensionService::IsDownloadFromMiniGallery(download->GetURL()))
3510 return;
3511
3512 TabContents* current_tab = GetSelectedTabContents();
3513 // We make this check for the case of minimized windows, unit tests, etc.
3514 if (platform_util::IsVisible(current_tab->GetNativeView()) &&
3515 ui::Animation::ShouldRenderRichAnimation()) {
3516 DownloadStartedAnimation::Show(current_tab);
3517 }
3518 #endif
3519
3520 // If the download occurs in a new tab, close it.
3521 if (tab->tab_contents()->controller().IsInitialNavigation() &&
3522 GetConstrainingContentsWrapper(tab) == tab && tab_count() > 1) {
jam 2011/07/15 00:53:26 btw I took out the "GetConstrainingContentsWrapper
3523 CloseContents(tab->tab_contents());
3524 }
3525 }
3526
3527 ///////////////////////////////////////////////////////////////////////////////
3528 // Browser, SelectFileDialog::Listener implementation: 3533 // Browser, SelectFileDialog::Listener implementation:
3529 3534
3530 void Browser::FileSelected(const FilePath& path, int index, void* params) { 3535 void Browser::FileSelected(const FilePath& path, int index, void* params) {
3531 profile_->set_last_selected_directory(path.DirName()); 3536 profile_->set_last_selected_directory(path.DirName());
3532 GURL file_url = net::FilePathToFileURL(path); 3537 GURL file_url = net::FilePathToFileURL(path);
3533 if (!file_url.is_empty()) 3538 if (!file_url.is_empty())
3534 OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); 3539 OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
3535 } 3540 }
3536 3541
3537 /////////////////////////////////////////////////////////////////////////////// 3542 ///////////////////////////////////////////////////////////////////////////////
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
4487 } 4492 }
4488 4493
4489 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { 4494 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) {
4490 // TabContents... 4495 // TabContents...
4491 tab->tab_contents()->set_delegate(delegate); 4496 tab->tab_contents()->set_delegate(delegate);
4492 tab->set_delegate(delegate); 4497 tab->set_delegate(delegate);
4493 4498
4494 // ...and all the helpers. 4499 // ...and all the helpers.
4495 tab->blocked_content_tab_helper()->set_delegate(delegate); 4500 tab->blocked_content_tab_helper()->set_delegate(delegate);
4496 tab->bookmark_tab_helper()->set_delegate(delegate); 4501 tab->bookmark_tab_helper()->set_delegate(delegate);
4497 tab->download_tab_helper()->set_delegate(delegate);
4498 tab->search_engine_tab_helper()->set_delegate(delegate); 4502 tab->search_engine_tab_helper()->set_delegate(delegate);
4499 } 4503 }
4500 4504
4501 void Browser::FindInPage(bool find_next, bool forward_direction) { 4505 void Browser::FindInPage(bool find_next, bool forward_direction) {
4502 ShowFindBar(); 4506 ShowFindBar();
4503 if (find_next) { 4507 if (find_next) {
4504 string16 find_text; 4508 string16 find_text;
4505 #if defined(OS_MACOSX) 4509 #if defined(OS_MACOSX)
4506 // We always want to search for the contents of the find pasteboard on OS X. 4510 // We always want to search for the contents of the find pasteboard on OS X.
4507 find_text = GetFindPboardText(); 4511 find_text = GetFindPboardText();
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 window_->BookmarkBarStateChanged(animate_type); 4761 window_->BookmarkBarStateChanged(animate_type);
4758 } 4762 }
4759 4763
4760 void Browser::ShowSyncSetup() { 4764 void Browser::ShowSyncSetup() {
4761 ProfileSyncService* service = profile()->GetProfileSyncService(); 4765 ProfileSyncService* service = profile()->GetProfileSyncService();
4762 if (service->HasSyncSetupCompleted()) 4766 if (service->HasSyncSetupCompleted())
4763 ShowOptionsTab(chrome::kSyncSetupSubPage); 4767 ShowOptionsTab(chrome::kSyncSetupSubPage);
4764 else 4768 else
4765 profile()->GetProfileSyncService()->ShowLoginDialog(); 4769 profile()->GetProfileSyncService()->ShowLoginDialog();
4766 } 4770 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.h ('k') | chrome/browser/ui/download/download_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698