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

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

Issue 11419169: Use DownloadItemModel for storing chrome/ specific UI data for DownloadItems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 years 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 // defined(OS_WIN) 10 #endif // defined(OS_WIN)
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 void Browser::RenderWidgetShowing() { 1472 void Browser::RenderWidgetShowing() {
1473 window_->DisableInactiveFrame(); 1473 window_->DisableInactiveFrame();
1474 } 1474 }
1475 1475
1476 int Browser::GetExtraRenderViewHeight() const { 1476 int Browser::GetExtraRenderViewHeight() const {
1477 return window_->GetExtraRenderViewHeight(); 1477 return window_->GetExtraRenderViewHeight();
1478 } 1478 }
1479 1479
1480 void Browser::OnStartDownload(WebContents* source, 1480 void Browser::OnStartDownload(WebContents* source,
1481 content::DownloadItem* download) { 1481 content::DownloadItem* download) {
1482 if (!download_util::ShouldShowInShelf(download)) 1482 scoped_ptr<DownloadItemModel> download_model(new DownloadItemModel(download));
1483 if (!download_model->ShouldShowInShelf())
1483 return; 1484 return;
1484 1485
1485 WebContents* constrained = GetConstrainingWebContents(source); 1486 WebContents* constrained = GetConstrainingWebContents(source);
1486 if (constrained != source) { 1487 if (constrained != source) {
1487 // Download in a constrained popup is shown in the tab that opened it. 1488 // Download in a constrained popup is shown in the tab that opened it.
1488 constrained->GetDelegate()->OnStartDownload(constrained, download); 1489 constrained->GetDelegate()->OnStartDownload(constrained, download);
1489 return; 1490 return;
1490 } 1491 }
1491 1492
1492 if (!window()) 1493 if (!window())
1493 return; 1494 return;
1494 1495
1495 // GetDownloadShelf creates the download shelf if it was not yet created. 1496 // GetDownloadShelf creates the download shelf if it was not yet created.
1496 DownloadShelf* shelf = window()->GetDownloadShelf(); 1497 DownloadShelf* shelf = window()->GetDownloadShelf();
1497 shelf->AddDownload(new DownloadItemModel(download)); 1498 shelf->AddDownload(download_model.release());
sky 2012/12/10 18:04:52 Would be nice to use download_model.Pass() here. M
asanka 2012/12/10 18:52:14 I'll do this in a follow-up CL next.
1498 // Don't show the animation for "Save file" downloads. 1499 // Don't show the animation for "Save file" downloads.
1499 // For non-theme extensions, we don't show the download animation. 1500 // For non-theme extensions, we don't show the download animation.
1500 // Show animation in same window as the download shelf. Download shelf 1501 // Show animation in same window as the download shelf. Download shelf
1501 // may not be in the same window that initiated the download. 1502 // may not be in the same window that initiated the download.
1502 // Don't show the animation if the selected tab is not visible (i.e. the 1503 // Don't show the animation if the selected tab is not visible (i.e. the
1503 // window is minimized, we're in a unit test, etc.). 1504 // window is minimized, we're in a unit test, etc.).
1504 WebContents* shelf_tab = chrome::GetActiveWebContents(shelf->browser()); 1505 WebContents* shelf_tab = chrome::GetActiveWebContents(shelf->browser());
1505 if ((download->GetTotalBytes() > 0) && 1506 if ((download->GetTotalBytes() > 0) &&
1506 !download_crx_util::IsExtensionDownload(*download) && 1507 !download_crx_util::IsExtensionDownload(*download) &&
1507 platform_util::IsVisible(shelf_tab->GetNativeView()) && 1508 platform_util::IsVisible(shelf_tab->GetNativeView()) &&
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 if (contents && !allow_js_access) { 2406 if (contents && !allow_js_access) {
2406 contents->web_contents()->GetController().LoadURL( 2407 contents->web_contents()->GetController().LoadURL(
2407 target_url, 2408 target_url,
2408 content::Referrer(), 2409 content::Referrer(),
2409 content::PAGE_TRANSITION_LINK, 2410 content::PAGE_TRANSITION_LINK,
2410 std::string()); // No extra headers. 2411 std::string()); // No extra headers.
2411 } 2412 }
2412 2413
2413 return contents != NULL; 2414 return contents != NULL;
2414 } 2415 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698