diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 00:35:02 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-28 00:35:02 +0000 |
commit | bcef0dc01dad3fff84f0c64389a0ead525181e55 (patch) | |
tree | 1d08ea6a05a2adbb44050715acde79771e442f88 /chrome/browser/tab_contents | |
parent | df9d0aa2e3feea5b71e1b3979ba6057238591fe3 (diff) | |
download | chromium_src-bcef0dc01dad3fff84f0c64389a0ead525181e55.zip chromium_src-bcef0dc01dad3fff84f0c64389a0ead525181e55.tar.gz chromium_src-bcef0dc01dad3fff84f0c64389a0ead525181e55.tar.bz2 |
Refactor download shelf and prepare for porting.
Side effect of removing some views dependencies from places they don't belong.
Review URL: http://codereview.chromium.org/28252
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10657 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/navigation_controller.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 39 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 18 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents_delegate.h | 5 |
4 files changed, 32 insertions, 32 deletions
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index def6c34..e8ae41f 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -932,7 +932,7 @@ void NavigationController::DiscardNonCommittedEntries() { // If we are transitioning from two types of WebContents, we need to migrate // the download shelf if it is visible. The download shelf may have been // created before the error that caused us to discard the entry. - TabContents::MigrateShelfView(from_contents, active_contents_); + TabContents::MigrateShelf(from_contents, active_contents_); if (from_contents->delegate()) { from_contents->delegate()->ReplaceContents(from_contents, diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 4b008dd..39ea878 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -9,6 +9,8 @@ #endif #include "chrome/browser/cert_store.h" +#include "chrome/browser/download/download_item_model.h" +#include "chrome/browser/download/download_shelf.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents_delegate.h" #include "chrome/browser/tab_contents/web_contents.h" @@ -21,7 +23,6 @@ #if defined(OS_WIN) // TODO(port): some of these headers should be ported. #include "chrome/browser/tab_contents/infobar_delegate.h" -#include "chrome/browser/views/download_shelf_view.h" #include "chrome/browser/views/download_started_animation.h" #include "chrome/browser/views/blocked_popup_container.h" #include "chrome/views/native_scroll_bar.h" @@ -467,8 +468,8 @@ void TabContents::RemoveInfoBar(InfoBarDelegate* delegate) { void TabContents::SetDownloadShelfVisible(bool visible) { if (shelf_visible_ != visible) { if (visible) { - // Invoke GetDownloadShelfView to force the shelf to be created. - GetDownloadShelfView(); + // Invoke GetDownloadShelf to force the shelf to be created. + GetDownloadShelf(); } shelf_visible_ = visible; @@ -497,8 +498,9 @@ void TabContents::OnStartDownload(DownloadItem* download) { if (constraining_tab) tab_contents = constraining_tab; - // GetDownloadShelfView creates the download shelf if it was not yet created. - tab_contents->GetDownloadShelfView()->AddDownload(download); + // GetDownloadShelf creates the download shelf if it was not yet created. + tab_contents->GetDownloadShelf()->AddDownload( + new DownloadItemModel(download)); tab_contents->SetDownloadShelfVisible(true); // This animation will delete itself when it finishes, or if we become hidden @@ -509,19 +511,16 @@ void TabContents::OnStartDownload(DownloadItem* download) { } } -DownloadShelfView* TabContents::GetDownloadShelfView() { - if (!download_shelf_view_.get()) { - download_shelf_view_.reset(new DownloadShelfView(this)); - // The TabContents owns the download-shelf. - download_shelf_view_->SetParentOwned(false); - } - return download_shelf_view_.get(); +DownloadShelf* TabContents::GetDownloadShelf() { + if (!download_shelf_.get()) + download_shelf_.reset(DownloadShelf::Create(this)); + return download_shelf_.get(); } -void TabContents::MigrateShelfViewFrom(TabContents* tab_contents) { - download_shelf_view_.reset(tab_contents->GetDownloadShelfView()); - download_shelf_view_->ChangeTabContents(tab_contents, this); - tab_contents->ReleaseDownloadShelfView(); +void TabContents::MigrateShelfFrom(TabContents* tab_contents) { + download_shelf_.reset(tab_contents->GetDownloadShelf()); + download_shelf_->ChangeTabContents(tab_contents, this); + tab_contents->ReleaseDownloadShelf(); } void TabContents::WillClose(ConstrainedWindow* window) { @@ -557,10 +556,10 @@ void TabContents::Observe(NotificationType type, } // static -void TabContents::MigrateShelfView(TabContents* from, TabContents* to) { +void TabContents::MigrateShelf(TabContents* from, TabContents* to) { bool was_shelf_visible = from->IsDownloadShelfVisible(); if (was_shelf_visible) - to->MigrateShelfViewFrom(from); + to->MigrateShelfFrom(from); to->SetDownloadShelfVisible(was_shelf_visible); } @@ -605,8 +604,8 @@ void TabContents::RepositionSupressedPopupsToFit(const gfx::Size& new_size) { blocked_popups_->RepositionConstrainedWindowTo(anchor_position); } -void TabContents::ReleaseDownloadShelfView() { - download_shelf_view_.release(); +void TabContents::ReleaseDownloadShelf() { + download_shelf_.release(); } bool TabContents::ShowingBlockedPopupNotification() const { diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index bfd4310..41b47bf 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -37,7 +37,7 @@ class WindowDelegate; class BlockedPopupContainer; class DOMUIHost; class DownloadItem; -class DownloadShelfView; +class DownloadShelf; class InfoBarView; class LoadNotificationDetails; class Profile; @@ -427,18 +427,18 @@ class TabContents : public PageNavigator, // Displays the download shelf and animation when a download occurs. void OnStartDownload(DownloadItem* download); - // Returns the DownloadShelfView, creating it if necessary. - DownloadShelfView* GetDownloadShelfView(); + // Returns the DownloadShelf, creating it if necessary. + DownloadShelf* GetDownloadShelf(); // Transfer the shelf view from |tab_contents| to the receiving TabContents. // |tab_contents| no longer owns the shelf after this call. The shelf is owned // by the receiving TabContents. - void MigrateShelfViewFrom(TabContents* tab_contents); + void MigrateShelfFrom(TabContents* tab_contents); // Migrate the shelf view between 2 TabContents. This helper function is // currently called by NavigationController::DiscardPendingEntry. We may // want to generalize this if we need to migrate some other state. - static void MigrateShelfView(TabContents* from, TabContents* to); + static void MigrateShelf(TabContents* from, TabContents* to); // Called when a ConstrainedWindow we own is about to be closed. void WillClose(ConstrainedWindow* window); @@ -486,10 +486,10 @@ class TabContents : public PageNavigator, // if necessary. void RepositionSupressedPopupsToFit(const gfx::Size& new_size); - // Releases the download shelf. This method is used by MigrateShelfViewFrom. + // Releases the download shelf. This method is used by MigrateShelfFrom. // Sub-classes should clear any pointer they might keep to the shelf view and - // invoke TabContents::ReleaseDownloadShelfView(). - virtual void ReleaseDownloadShelfView(); + // invoke TabContents::ReleaseDownloadShelf(). + virtual void ReleaseDownloadShelf(); // Called by derived classes to indicate that we're no longer waiting for a // response. This won't actually update the throbber, but it will get picked @@ -534,7 +534,7 @@ class TabContents : public PageNavigator, bool waiting_for_response_; // The download shelf view (view at the bottom of the page). - scoped_ptr<DownloadShelfView> download_shelf_view_; + scoped_ptr<DownloadShelf> download_shelf_; // Whether the shelf view is visible. bool shelf_visible_; diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h index 6a76c15..a55f0e0 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.h +++ b/chrome/browser/tab_contents/tab_contents_delegate.h @@ -17,8 +17,9 @@ class HtmlDialogContentsDelegate; // TabContents and to provide necessary functionality. class TabContentsDelegate : public PageNavigator { public: - // Opens a new URL inside the passed in TabContents, if source is 0 open - // in the current front-most tab. + // Opens a new URL inside the passed in TabContents (if source is 0 open + // in the current front-most tab), unless |disposition| indicates the url + // should be opened in a new tab or window. virtual void OpenURLFromTab(TabContents* source, const GURL& url, const GURL& referrer, WindowOpenDisposition disposition, |