diff options
34 files changed, 56 insertions, 322 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index d87171b..99f1d3f 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1750,41 +1750,14 @@ void Browser::NavigationStateChanged(const TabContents* source, UpdateCommandsForTabState(); } -void Browser::ReplaceContents(TabContents* source, TabContents* new_contents) { - source->set_delegate(NULL); - new_contents->set_delegate(this); - - RemoveScheduledUpdatesFor(source); - - int index = tabstrip_model_.GetIndexOfTabContents(source); - tabstrip_model_.ReplaceTabContentsAt(index, new_contents); - - if (is_attempting_to_close_browser_) { - // Need to do this asynchronously as it will close the tab, which is - // currently on the call stack above us. - MessageLoop::current()->PostTask(FROM_HERE, - method_factory_.NewRunnableMethod(&Browser::ClearUnloadState, - Source<TabContents>(source).ptr())); - } - // Need to remove ourselves as an observer for disconnection on the replaced - // TabContents, since we only care to fire onbeforeunload handlers on active - // Tabs. Make sure an observer is added for the replacement TabContents. - NotificationService::current()->RemoveObserver( - this, - NotificationType::WEB_CONTENTS_DISCONNECTED, - Source<TabContents>(source)); - NotificationService::current()->AddObserver( - this, - NotificationType::WEB_CONTENTS_DISCONNECTED, - Source<TabContents>(new_contents)); -} - void Browser::AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture) { DCHECK(disposition != SAVE_TO_DISK); // No code for this yet + DCHECK(disposition != CURRENT_TAB); // Can't create a new contents for the + // current tab. // If this is an application we can only have one tab so we need to process // this in tabbed browser window. @@ -1813,8 +1786,6 @@ void Browser::AddNewContents(TabContents* source, browser->AddNewContents(source, new_contents, NEW_FOREGROUND_TAB, initial_pos, user_gesture); browser->window()->Show(); - } else if (disposition == CURRENT_TAB) { - ReplaceContents(source, new_contents); } else if (disposition != SUPPRESS_OPEN) { tabstrip_model_.AddTabContents(new_contents, -1, PageTransition::LINK, disposition == NEW_FOREGROUND_TAB); @@ -2368,7 +2339,6 @@ void Browser::ProcessPendingUIUpdates() { if (contents == GetSelectedTabContents()) { TabContents* current_tab = GetSelectedTabContents(); command_updater_.UpdateCommandEnabled(IDC_CREATE_SHORTCUTS, - current_tab->type() == TAB_CONTENTS_WEB && !current_tab->GetFavIcon().isNull()); } } diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index 7956413..147731c 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -419,7 +419,6 @@ class Browser : public TabStripModelDelegate, PageTransition::Type transition); virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags); - virtual void ReplaceContents(TabContents* source, TabContents* new_contents); virtual void AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index 4b16b72..4b74265 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -2298,10 +2298,6 @@ > </File> <File - RelativePath=".\tab_contents\tab_contents_type.h" - > - </File> - <File RelativePath=".\tab_contents\tab_util.cc" > </File> diff --git a/chrome/browser/browser_about_handler.h b/chrome/browser/browser_about_handler.h index b1cb3ac..3a46bb0 100644 --- a/chrome/browser/browser_about_handler.h +++ b/chrome/browser/browser_about_handler.h @@ -7,8 +7,6 @@ #ifndef CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ #define CHROME_BROWSER_BROWSER_ABOUT_HANDLER_H_ -#include "chrome/browser/tab_contents/tab_contents_type.h" - class GURL; // Decides whether the given URL will be handled by the browser about handler diff --git a/chrome/browser/debugger/debugger_view.h b/chrome/browser/debugger/debugger_view.h index be2350c..1ebf014 100644 --- a/chrome/browser/debugger/debugger_view.h +++ b/chrome/browser/debugger/debugger_view.h @@ -62,8 +62,6 @@ class DebuggerView : public views::View, // Overridden from TabContentsDelegate: virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags) {} - virtual void ReplaceContents(TabContents* source, - TabContents* new_contents) {} virtual void AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/debugger/devtools_view.h b/chrome/browser/debugger/devtools_view.h index 873f7e0..0836ccc 100644 --- a/chrome/browser/debugger/devtools_view.h +++ b/chrome/browser/debugger/devtools_view.h @@ -35,8 +35,6 @@ class DevToolsView : public views::View, // Overridden from TabContentsDelegate: virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags) {} - virtual void ReplaceContents(TabContents* source, - TabContents* new_contents) {} virtual void AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 92d20db..4e133e9 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -1447,12 +1447,10 @@ void DownloadManager::OnCreateDownloadEntryComplete(DownloadCreateInfo info, TabContents* contents = tab_util::GetWebContentsByID(info.render_process_id, info.render_view_id); - // If the contents no longer exists or is no longer active, we start the - // download in the last active browser. This is not ideal but better than - // fully hiding the download from the user. Note: non active means that the - // user navigated away from the tab contents. This has nothing to do with - // tab selection. - if (!contents || !contents->is_active()) { + // If the contents no longer exists, we start the download in the last active + // browser. This is not ideal but better than fully hiding the download from + // the user. + if (!contents) { Browser* last_active = BrowserList::GetLastActive(); if (last_active) contents = last_active->GetSelectedTabContents(); diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index 821bdd2..3f79072 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -205,10 +205,6 @@ void ExternalTabContainer::NavigationStateChanged(const TabContents* source, } } -void ExternalTabContainer::ReplaceContents(TabContents* source, - TabContents* new_contents) { -} - void ExternalTabContainer::AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index 2c69beb..c9d8f34 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -68,7 +68,6 @@ class ExternalTabContainer : public TabContentsDelegate, PageTransition::Type transition); virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags); - virtual void ReplaceContents(TabContents* source, TabContents* new_contents); virtual void AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index 8fc4ee0b..06ecf00 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -146,7 +146,6 @@ void RegisterForAllNavNotifications(TestNotificationTracker* tracker, // ----------------------------------------------------------------------------- TEST_F(NavigationControllerTest, Defaults) { - EXPECT_TRUE(contents()->is_active()); EXPECT_TRUE(controller()); EXPECT_FALSE(controller()->pending_entry()); EXPECT_FALSE(controller()->GetLastCommittedEntry()); @@ -1189,7 +1188,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { notifications.Reset(); // Adding a transient with no pending entry. - NavigationEntry* transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); + NavigationEntry* transient_entry = new NavigationEntry; transient_entry->set_url(transient_url); controller()->AddTransientEntry(transient_entry); @@ -1216,7 +1215,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { EXPECT_EQ(controller()->entry_count(), 3); // Add a transient again, then navigate with no pending entry this time. - transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); + transient_entry = new NavigationEntry; transient_entry->set_url(transient_url); controller()->AddTransientEntry(transient_entry); EXPECT_EQ(transient_url, controller()->GetActiveEntry()->url()); @@ -1227,7 +1226,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { // Initiate a navigation, add a transient then commit navigation. controller()->LoadURL(url4, GURL(), PageTransition::TYPED); - transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); + transient_entry = new NavigationEntry; transient_entry->set_url(transient_url); controller()->AddTransientEntry(transient_entry); EXPECT_EQ(transient_url, controller()->GetActiveEntry()->url()); @@ -1236,7 +1235,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { EXPECT_EQ(controller()->entry_count(), 5); // Add a transient and go back. This should simply remove the transient. - transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); + transient_entry = new NavigationEntry; transient_entry->set_url(transient_url); controller()->AddTransientEntry(transient_entry); EXPECT_EQ(transient_url, controller()->GetActiveEntry()->url()); @@ -1249,7 +1248,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { rvh()->SendNavigate(3, url3); // Add a transient and go to an entry before the current one. - transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); + transient_entry = new NavigationEntry; transient_entry->set_url(transient_url); controller()->AddTransientEntry(transient_entry); EXPECT_EQ(transient_url, controller()->GetActiveEntry()->url()); @@ -1259,7 +1258,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { rvh()->SendNavigate(1, url1); // Add a transient and go to an entry after the current one. - transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); + transient_entry = new NavigationEntry; transient_entry->set_url(transient_url); controller()->AddTransientEntry(transient_entry); EXPECT_EQ(transient_url, controller()->GetActiveEntry()->url()); @@ -1271,7 +1270,7 @@ TEST_F(NavigationControllerTest, TransientEntry) { rvh()->SendNavigate(2, url2); // Add a transient and go forward. - transient_entry = new NavigationEntry(TAB_CONTENTS_WEB); + transient_entry = new NavigationEntry; transient_entry->set_url(transient_url); controller()->AddTransientEntry(transient_entry); EXPECT_EQ(transient_url, controller()->GetActiveEntry()->url()); diff --git a/chrome/browser/navigation_entry_unittest.cc b/chrome/browser/navigation_entry_unittest.cc index d1a64bf..0a9f814 100644 --- a/chrome/browser/navigation_entry_unittest.cc +++ b/chrome/browser/navigation_entry_unittest.cc @@ -15,7 +15,7 @@ class NavigationEntryTest : public testing::Test { entry1_.reset(new NavigationEntry); instance_ = SiteInstance::CreateSiteInstance(NULL); - entry2_.reset(new NavigationEntry(TAB_CONTENTS_WEB, instance_, 3, + entry2_.reset(new NavigationEntry(instance_, 3, GURL("test:url"), GURL("from"), ASCIIToUTF16("title"), diff --git a/chrome/browser/sessions/session_service_unittest.cc b/chrome/browser/sessions/session_service_unittest.cc index 1493864..82558c3 100644 --- a/chrome/browser/sessions/session_service_unittest.cc +++ b/chrome/browser/sessions/session_service_unittest.cc @@ -46,7 +46,7 @@ class SessionServiceTest : public testing::Test { const TabNavigation& navigation, int index, bool select) { - NavigationEntry entry(TAB_CONTENTS_UNKNOWN_TYPE); + NavigationEntry entry; entry.set_url(navigation.url()); entry.set_referrer(navigation.referrer()); entry.set_title(navigation.title()); diff --git a/chrome/browser/sessions/session_types.cc b/chrome/browser/sessions/session_types.cc index b6372ad..3483228 100644 --- a/chrome/browser/sessions/session_types.cc +++ b/chrome/browser/sessions/session_types.cc @@ -12,7 +12,6 @@ // static NavigationEntry* TabNavigation::ToNavigationEntry(int page_id) const { NavigationEntry* entry = new NavigationEntry( - TAB_CONTENTS_WEB, NULL, // The site instance for restored tabs is sent on navigation // (WebContents::GetSiteInstanceForEntry). page_id, diff --git a/chrome/browser/site_instance_unittest.cc b/chrome/browser/site_instance_unittest.cc index 2e8a3a1..83e3baf 100644 --- a/chrome/browser/site_instance_unittest.cc +++ b/chrome/browser/site_instance_unittest.cc @@ -78,8 +78,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) { &browsingDeleteCounter); EXPECT_EQ(0, siteDeleteCounter); - NavigationEntry* e1 = new NavigationEntry(TAB_CONTENTS_WEB, instance, 0, url, - GURL(), + NavigationEntry* e1 = new NavigationEntry(instance, 0, url, GURL(), string16(), PageTransition::LINK); @@ -88,7 +87,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) { EXPECT_EQ(0, siteDeleteCounter); // Add a second reference - NavigationEntry* e2 = new NavigationEntry(TAB_CONTENTS_WEB, instance, 0, url, + NavigationEntry* e2 = new NavigationEntry(instance, 0, url, GURL(), string16(), PageTransition::LINK); @@ -139,8 +138,7 @@ TEST_F(SiteInstanceTest, CloneNavigationEntry) { TestSiteInstance::CreateTestSiteInstance(NULL, &siteDeleteCounter2, &browsingDeleteCounter); - NavigationEntry* e1 = new NavigationEntry(TAB_CONTENTS_WEB, instance1, 0, - url, GURL(), + NavigationEntry* e1 = new NavigationEntry(instance1, 0, url, GURL(), string16(), PageTransition::LINK); // Clone the entry diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index ff39c7d..77cf714 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -373,8 +373,7 @@ NavigationEntry* NavigationController::CreateNavigationEntry( GURL loaded_url(url); BrowserURLHandler::RewriteURLIfNecessary(&loaded_url); - NavigationEntry* entry = new NavigationEntry(TAB_CONTENTS_WEB, NULL, -1, - loaded_url, referrer, + NavigationEntry* entry = new NavigationEntry(NULL, -1, loaded_url, referrer, string16(), transition); entry->set_display_url(url); entry->set_user_typed_url(url); @@ -621,7 +620,7 @@ void NavigationController::RendererDidNavigateToNewPage( // type must always be normal. new_entry->set_page_type(NavigationEntry::NORMAL_PAGE); } else { - new_entry = new NavigationEntry(tab_contents_->type()); + new_entry = new NavigationEntry; } new_entry->set_url(params.url); @@ -862,27 +861,16 @@ void NavigationController::SetWindowID(const SessionID& id) { } void NavigationController::NavigateToPendingEntry(bool reload) { - TabContents* from_contents = tab_contents_; - // For session history navigations only the pending_entry_index_ is set. if (!pending_entry_) { DCHECK(pending_entry_index_ != -1); pending_entry_ = entries_[pending_entry_index_].get(); } - if (from_contents && from_contents->type() != pending_entry_->tab_type()) - from_contents->set_is_active(false); - - TabContents* contents = GetTabContentsCreateIfNecessary(*pending_entry_); - - contents->set_is_active(true); - tab_contents_ = contents; - - if (from_contents && from_contents != contents && from_contents->delegate()) - from_contents->delegate()->ReplaceContents(from_contents, contents); + tab_contents_ = GetTabContentsCreateIfNecessary(*pending_entry_); NavigationEntry temp_entry(*pending_entry_); - if (!contents->NavigateToPendingEntry(reload)) + if (!tab_contents_->NavigateToPendingEntry(reload)) DiscardNonCommittedEntries(); } diff --git a/chrome/browser/tab_contents/navigation_entry.cc b/chrome/browser/tab_contents/navigation_entry.cc index c07c08e..7633ac6 100644 --- a/chrome/browser/tab_contents/navigation_entry.cc +++ b/chrome/browser/tab_contents/navigation_entry.cc @@ -34,7 +34,6 @@ NavigationEntry::FaviconStatus::FaviconStatus() : valid_(false) { NavigationEntry::NavigationEntry() : unique_id_(GetUniqueID()), - tab_type_(TAB_CONTENTS_WEB), site_instance_(NULL), page_type_(NORMAL_PAGE), page_id_(-1), @@ -43,26 +42,13 @@ NavigationEntry::NavigationEntry() restored_(false) { } -NavigationEntry::NavigationEntry(TabContentsType type) - : unique_id_(GetUniqueID()), - tab_type_(type), - site_instance_(NULL), - page_type_(NORMAL_PAGE), - page_id_(-1), - transition_type_(PageTransition::LINK), - has_post_data_(false), - restored_(false) { -} - -NavigationEntry::NavigationEntry(TabContentsType type, - SiteInstance* instance, +NavigationEntry::NavigationEntry(SiteInstance* instance, int page_id, const GURL& url, const GURL& referrer, const string16& title, PageTransition::Type transition_type) : unique_id_(GetUniqueID()), - tab_type_(type), site_instance_(instance), page_type_(NORMAL_PAGE), url_(url), diff --git a/chrome/browser/tab_contents/navigation_entry.h b/chrome/browser/tab_contents/navigation_entry.h index 9a39d14..677e633 100644 --- a/chrome/browser/tab_contents/navigation_entry.h +++ b/chrome/browser/tab_contents/navigation_entry.h @@ -10,7 +10,6 @@ #include "base/string_util.h" #include "chrome/browser/tab_contents/security_style.h" #include "chrome/browser/tab_contents/site_instance.h" -#include "chrome/browser/tab_contents/tab_contents_type.h" #include "chrome/common/page_transition_types.h" #include "googleurl/src/gurl.h" #include "grit/theme_resources.h" @@ -175,9 +174,7 @@ class NavigationEntry { // --------------------------------------------------------------------------- NavigationEntry(); - explicit NavigationEntry(TabContentsType type); - NavigationEntry(TabContentsType type, - SiteInstance* instance, + NavigationEntry(SiteInstance* instance, int page_id, const GURL& url, const GURL& referrer, @@ -199,12 +196,6 @@ class NavigationEntry { return unique_id_; } - // Return the TabContents type required to display this entry. Immutable - // because a tab can never change its type. - TabContentsType tab_type() const { - return tab_type_; - } - // The SiteInstance tells us how to share sub-processes when the tab type is // TAB_CONTENTS_WEB. This will be NULL otherwise. This is a reference counted // pointer to a shared site instance. @@ -399,7 +390,6 @@ class NavigationEntry { // See the accessors above for descriptions. int unique_id_; - TabContentsType tab_type_; scoped_refptr<SiteInstance> site_instance_; PageType page_type_; GURL url_; diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc index b9fa344..be813aa 100644 --- a/chrome/browser/tab_contents/render_view_host_manager.cc +++ b/chrome/browser/tab_contents/render_view_host_manager.cc @@ -391,9 +391,8 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( bool RenderViewHostManager::CreatePendingRenderView(SiteInstance* instance) { NavigationEntry* curr_entry = delegate_->GetControllerForRenderManager()->GetLastCommittedEntry(); - if (curr_entry && curr_entry->tab_type() == TAB_CONTENTS_WEB) { + if (curr_entry) { DCHECK(!curr_entry->content_state().empty()); - // TODO(creis): Should send a message to the RenderView to let it know // we're about to switch away, so that it sends an UpdateState message. } diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index b866589..1c7e08f 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -37,12 +37,10 @@ BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { } // namespace #endif -TabContents::TabContents(TabContentsType type) - : type_(type), - delegate_(NULL), +TabContents::TabContents() + : delegate_(NULL), controller_(NULL), is_loading_(false), - is_active_(true), is_crashed_(false), waiting_for_response_(false), shelf_visible_(false), @@ -498,10 +496,6 @@ void TabContents::SetIsLoading(bool is_loading, is_loading_ = is_loading; waiting_for_response_ = is_loading; - // Suppress notifications for this TabContents if we are not active. - if (!is_active_) - return; - if (delegate_) delegate_->LoadingStateChanged(this); diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index 7ccc275..c93ff4c 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -18,7 +18,6 @@ #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/page_navigator.h" -#include "chrome/browser/tab_contents/tab_contents_type.h" #include "chrome/common/navigation_types.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/property_bag.h" @@ -97,9 +96,6 @@ class TabContents : public PageNavigator, // Intrinsic tab state ------------------------------------------------------- - // Returns the type of tab this is. See also the As* functions following. - TabContentsType type() const { return type_; } - // Returns the property bag for this tab contents, where callers can add // extra data they may wish to associate with the tab. Returns a pointer // rather than a reference since the PropertyAccessors expect this. @@ -224,12 +220,6 @@ class TabContents : public PageNavigator, bool is_crashed() const { return is_crashed_; } void SetIsCrashed(bool state); - // Set whether this tab contents is active. A tab content is active for a - // given tab if it is currently being used to display some contents. Note that - // this is different from whether a tab is selected. - bool is_active() const { return is_active_; } - void set_is_active(bool active) { is_active_ = active; } - // Whether the tab is in the process of being destroyed. // Added as a tentative work-around for focus related bug #4633. This allows // us not to store focus when a tab is being closed. @@ -426,10 +416,7 @@ class TabContents : public PageNavigator, // automation purposes. friend class AutomationProvider; - explicit TabContents(TabContentsType type); - - // Some tab contents types need to override the type. - void set_type(TabContentsType type) { type_ = type; } + TabContents(); // NOTE: the TabContents destructor can run after the NavigationController // has gone away, so any complicated unregistering that expects the profile @@ -476,8 +463,6 @@ class TabContents : public PageNavigator, // Data ---------------------------------------------------------------------- - TabContentsType type_; - TabContentsDelegate* delegate_; NavigationController* controller_; @@ -488,9 +473,6 @@ class TabContents : public PageNavigator, // Indicates whether we're currently loading a resource. bool is_loading_; - // See is_active() getter above. - bool is_active_; - bool is_crashed_; // true if the tab is considered crashed. // See waiting_for_response() above. diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h index 152f83d..ac8739c 100644 --- a/chrome/browser/tab_contents/tab_contents_delegate.h +++ b/chrome/browser/tab_contents/tab_contents_delegate.h @@ -45,11 +45,6 @@ class TabContentsDelegate : public PageNavigator { virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags) = 0; - // Called to cause the delegate to replace the source contents with the new - // contents. - virtual void ReplaceContents(TabContents* source, - TabContents* new_contents) = 0; - // Creates a new tab with the already-created TabContents 'new_contents'. // The window for the added contents should be reparented correctly when this // method returns. If |disposition| is NEW_POPUP, |pos| should hold the diff --git a/chrome/browser/tab_contents/tab_contents_type.h b/chrome/browser/tab_contents/tab_contents_type.h deleted file mode 100644 index f918a76..0000000 --- a/chrome/browser/tab_contents/tab_contents_type.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_TYPE_H__ -#define CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_TYPE_H__ - -// The different kinds of tab contents we support. This is declared outside of -// TabContents to eliminate the circular dependency between NavigationEntry -// (which requires a tab type) and TabContents (which requires a -// NavigationEntry). -enum TabContentsType { - TAB_CONTENTS_UNKNOWN_TYPE = 0, - TAB_CONTENTS_WEB, - - // DO NOT EVEN THINK ABOUT ADDING MORE TAB CONTENTS TYPES HERE. SEE brettw. - TAB_CONTENTS_NUM_TYPES -}; - -#endif // CHROME_BROWSER_TAB_CONTENTS_TAB_CONTENTS_TYPE_H__ diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index e35f941..5077064 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -193,8 +193,7 @@ WebContents::WebContents(Profile* profile, SiteInstance* site_instance, int routing_id, base::WaitableEvent* modal_dialog_event) - : TabContents(TAB_CONTENTS_WEB), - view_(WebContentsView::Create(this)), + : view_(WebContentsView::Create(this)), ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this)), printing_(*this), notify_disconnection_(false), @@ -797,7 +796,7 @@ void WebContents::DidNavigate(RenderViewHost* rvh, render_manager_.DidNavigateMainFrame(rvh); // We can't do anything about navigations when we're inactive. - if (!controller() || !is_active()) + if (!controller()) return; // Update the site of the SiteInstance if it doesn't have one yet. @@ -983,7 +982,7 @@ void WebContents::DidRedirectProvisionalLoad(int32 page_id, entry = controller()->pending_entry(); else entry = controller()->GetEntryWithPageID(GetSiteInstance(), page_id); - if (!entry || entry->tab_type() != type() || entry->url() != source_url) + if (!entry || entry->url() != source_url) return; entry->set_url(target_url); } diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 59665df..c4b5ecd 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -153,23 +153,6 @@ void TabStripModel::SelectTabContentsAt(int index, bool user_gesture) { ChangeSelectedContentsFrom(GetSelectedTabContents(), index, user_gesture); } -void TabStripModel::ReplaceTabContentsAt(int index, - TabContents* replacement_contents) { - DCHECK(ContainsIndex(index)); - TabContents* old_contents = GetContentsAt(index); - contents_data_[index]->contents = replacement_contents; - - FOR_EACH_OBSERVER(TabStripModelObserver, observers_, - TabChangedAt(replacement_contents, index, false)); - - // Re-use the logic for selecting tabs to ensure the replacement contents is - // shown and sized appropriately. - if (index == selected_index_) { - FOR_EACH_OBSERVER(TabStripModelObserver, observers_, - TabSelectedAt(old_contents, replacement_contents, index, false)); - } -} - void TabStripModel::MoveTabContentsAt(int index, int to_position) { DCHECK(ContainsIndex(index)); if (index == to_position) diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 5530f8b..c6b7c76 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -282,11 +282,6 @@ class TabStripModel : public NotificationObserver { // action. void SelectTabContentsAt(int index, bool user_gesture); - // Replace the TabContents at the specified index with another TabContents. - // This is used when a navigation causes a different TabContentsType to be - // required, e.g. the transition from New Tab to a web page. - void ReplaceTabContentsAt(int index, TabContents* replacement_contents); - // Move the TabContents at the specified index to another index. This method // does NOT send Detached/Attached notifications, rather it moves the // TabContents inline and sends a Moved notification instead. diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index 056ff5f..f5b7028 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -288,38 +288,6 @@ TEST_F(TabStripModelTest, TestBasicAPI) { observer.ClearStates(); } - // Test ReplaceTabContentsAt, replacing the selected index - TabContents* replacement_contents3 = CreateTabContents(); - { - tabstrip.ReplaceTabContentsAt(2, replacement_contents3); - // ReplaceTabContentsAt doesn't delete the source. It depends on - // NavigationCollector, which is not part of this test. - contents3->Destroy(); - - EXPECT_EQ(2, observer.GetStateCount()); - State s1(replacement_contents3, 2, MockTabStripModelObserver::CHANGE); - EXPECT_TRUE(observer.StateEquals(0, s1)); - State s2(replacement_contents3, 2, MockTabStripModelObserver::SELECT); - s2.src_contents = contents3; - s2.user_gesture = false; - EXPECT_TRUE(observer.StateEquals(1, s2)); - observer.ClearStates(); - } - - // Test ReplaceTabContentsAt, replacing NOT the selected index - TabContents* replacement_contents2 = CreateTabContents(); - { - tabstrip.ReplaceTabContentsAt(1, replacement_contents2); - // ReplaceTabContentsAt doesn't delete the source. It depends on - // NavigationCollector, which is not part of this test. - contents2->Destroy(); - - EXPECT_EQ(1, observer.GetStateCount()); - State s1(replacement_contents2, 1, MockTabStripModelObserver::CHANGE); - EXPECT_TRUE(observer.StateEquals(0, s1)); - observer.ClearStates(); - } - // Test DetachTabContentsAt { // Detach @@ -329,15 +297,15 @@ TEST_F(TabStripModelTest, TestBasicAPI) { EXPECT_EQ(4, observer.GetStateCount()); State s1(detached, 2, MockTabStripModelObserver::DETACH); EXPECT_TRUE(observer.StateEquals(0, s1)); - State s2(replacement_contents2, 1, MockTabStripModelObserver::SELECT); - s2.src_contents = replacement_contents3; + State s2(contents2, 1, MockTabStripModelObserver::SELECT); + s2.src_contents = contents3; s2.user_gesture = false; EXPECT_TRUE(observer.StateEquals(1, s2)); State s3(detached, 2, MockTabStripModelObserver::INSERT); s3.foreground = true; EXPECT_TRUE(observer.StateEquals(2, s3)); State s4(detached, 2, MockTabStripModelObserver::SELECT); - s4.src_contents = replacement_contents2; + s4.src_contents = contents2; s4.user_gesture = false; EXPECT_TRUE(observer.StateEquals(3, s4)); observer.ClearStates(); @@ -349,12 +317,12 @@ TEST_F(TabStripModelTest, TestBasicAPI) { EXPECT_EQ(2, tabstrip.count()); EXPECT_EQ(3, observer.GetStateCount()); - State s1(replacement_contents3, 2, MockTabStripModelObserver::CLOSE); + State s1(contents3, 2, MockTabStripModelObserver::CLOSE); EXPECT_TRUE(observer.StateEquals(0, s1)); - State s2(replacement_contents3, 2, MockTabStripModelObserver::DETACH); + State s2(contents3, 2, MockTabStripModelObserver::DETACH); EXPECT_TRUE(observer.StateEquals(1, s2)); - State s3(replacement_contents2, 1, MockTabStripModelObserver::SELECT); - s3.src_contents = replacement_contents3; + State s3(contents2, 1, MockTabStripModelObserver::SELECT); + s3.src_contents = contents3; s3.user_gesture = false; EXPECT_TRUE(observer.StateEquals(2, s3)); observer.ClearStates(); @@ -365,7 +333,7 @@ TEST_F(TabStripModelTest, TestBasicAPI) { tabstrip.MoveTabContentsAt(1, 0); EXPECT_EQ(1, observer.GetStateCount()); - State s1(replacement_contents2, 0, MockTabStripModelObserver::MOVE); + State s1(contents2, 0, MockTabStripModelObserver::MOVE); s1.src_index = 1; EXPECT_TRUE(observer.StateEquals(0, s1)); observer.ClearStates(); @@ -373,13 +341,12 @@ TEST_F(TabStripModelTest, TestBasicAPI) { // Test Getters { - EXPECT_EQ(replacement_contents2, tabstrip.GetSelectedTabContents()); - EXPECT_EQ(replacement_contents2, tabstrip.GetTabContentsAt(0)); + EXPECT_EQ(contents2, tabstrip.GetSelectedTabContents()); + EXPECT_EQ(contents2, tabstrip.GetTabContentsAt(0)); EXPECT_EQ(contents1, tabstrip.GetTabContentsAt(1)); - EXPECT_EQ(0, tabstrip.GetIndexOfTabContents(replacement_contents2)); + EXPECT_EQ(0, tabstrip.GetIndexOfTabContents(contents2)); EXPECT_EQ(1, tabstrip.GetIndexOfTabContents(contents1)); - EXPECT_EQ(0, tabstrip.GetIndexOfController( - replacement_contents2->controller())); + EXPECT_EQ(0, tabstrip.GetIndexOfController(contents2->controller())); EXPECT_EQ(1, tabstrip.GetIndexOfController(contents1->controller())); } @@ -387,7 +354,7 @@ TEST_F(TabStripModelTest, TestBasicAPI) { { tabstrip.UpdateTabContentsStateAt(0, false); EXPECT_EQ(1, observer.GetStateCount()); - State s1(replacement_contents2, 0, MockTabStripModelObserver::CHANGE); + State s1(contents2, 0, MockTabStripModelObserver::CHANGE); EXPECT_TRUE(observer.StateEquals(0, s1)); observer.ClearStates(); } diff --git a/chrome/browser/views/blocked_popup_container.cc b/chrome/browser/views/blocked_popup_container.cc index 5a80f03..ca5b996 100644 --- a/chrome/browser/views/blocked_popup_container.cc +++ b/chrome/browser/views/blocked_popup_container.cc @@ -350,28 +350,6 @@ void BlockedPopupContainer::OpenURLFromTab(TabContents* source, owner_->OpenURL(url, referrer, disposition, transition); } -void BlockedPopupContainer::ReplaceContents(TabContents* source, - TabContents* new_contents) { - // Walk the vector to find the correct TabContents and replace it. - bool found = false; - gfx::Rect rect; - for (std::vector<std::pair<TabContents*, gfx::Rect> >::iterator it = - blocked_popups_.begin(); it != blocked_popups_.end(); ++it) { - if (it->first == source) { - it->first->set_delegate(NULL); - rect = it->second; - found = true; - blocked_popups_.erase(it); - break; - } - } - - if (found) { - new_contents->set_delegate(this); - blocked_popups_.push_back(std::make_pair(new_contents, rect)); - } -} - void BlockedPopupContainer::AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/views/blocked_popup_container.h b/chrome/browser/views/blocked_popup_container.h index b853b6d..e469da6 100644 --- a/chrome/browser/views/blocked_popup_container.h +++ b/chrome/browser/views/blocked_popup_container.h @@ -151,11 +151,6 @@ class BlockedPopupContainer : public ConstrainedWindow, virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags) { } - // Replaces |source| with |new_contents| in our list of blocked popups, - // preserving the associated window size. - virtual void ReplaceContents(TabContents* source, - TabContents* new_contents); - // Forwards AddNewContents to our |owner_|. virtual void AddNewContents(TabContents* source, TabContents* new_contents, diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 5bd1fbc..2a00dc3 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -828,11 +828,9 @@ void BrowserView::ShowReportBugDialog() { current_tab); if (current_tab->controller()->GetLastCommittedEntry()) { - if (current_tab->type() == TAB_CONTENTS_WEB) { - // URL for the current page - bug_report_view->SetUrl( - current_tab->controller()->GetActiveEntry()->url()); - } + // URL for the current page + bug_report_view->SetUrl( + current_tab->controller()->GetActiveEntry()->url()); } // retrieve the application version info diff --git a/chrome/browser/views/html_dialog_view.cc b/chrome/browser/views/html_dialog_view.cc index ecb459c..2cdbfda2 100644 --- a/chrome/browser/views/html_dialog_view.cc +++ b/chrome/browser/views/html_dialog_view.cc @@ -118,10 +118,6 @@ void HtmlDialogView::NavigationStateChanged(const TabContents* source, // one, which we ignore because we're a dialog box. } -void HtmlDialogView::ReplaceContents(TabContents* source, - TabContents* new_contents) { -} - void HtmlDialogView::AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/views/html_dialog_view.h b/chrome/browser/views/html_dialog_view.h index bdff126..2f3eb58 100644 --- a/chrome/browser/views/html_dialog_view.h +++ b/chrome/browser/views/html_dialog_view.h @@ -68,8 +68,6 @@ class HtmlDialogView PageTransition::Type transition); virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags); - virtual void ReplaceContents(TabContents* source, - TabContents* new_contents); virtual void AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index b4d9f15..fc5d0e1 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -261,7 +261,7 @@ DraggedTabController::DraggedTabController(Tab* source_tab, old_focused_view_(NULL), in_destructor_(false), last_move_screen_x_(0) { - ChangeDraggedContents( + SetDraggedContents( source_tabstrip_->model()->GetTabContentsAt(source_model_index_)); // Listen for Esc key presses. MessageLoopForUI::current()->AddObserver(this); @@ -276,7 +276,7 @@ DraggedTabController::~DraggedTabController() { // bounds, it won't be able to clean up properly since its cleanup routine // uses GetIndexForDraggedContents, which will be invalid. view_.reset(NULL); - ChangeDraggedContents(NULL); // This removes our observer. + SetDraggedContents(NULL); // This removes our observer. } void DraggedTabController::CaptureDragInfo(const gfx::Point& mouse_offset) { @@ -339,45 +339,16 @@ void DraggedTabController::NavigationStateChanged(const TabContents* source, view_->Update(); } -void DraggedTabController::ReplaceContents(TabContents* source, - TabContents* new_contents) { - DCHECK(dragged_contents_ == source); - - // If we're attached to a TabStrip, we need to tell the TabStrip that this - // TabContents was replaced. - if (attached_tabstrip_ && dragged_contents_) { - if (original_delegate_) { - original_delegate_->ReplaceContents(source, new_contents); - // ReplaceContents on the original delegate is going to reset the delegate - // for us. We need to unset original_delegate_ here so that - // ChangeDraggedContents doesn't attempt to restore the delegate to the - // wrong value. - original_delegate_ = NULL; - } else if (attached_tabstrip_->model()) { - int index = - attached_tabstrip_->model()->GetIndexOfTabContents(dragged_contents_); - if (index != TabStripModel::kNoTab) - attached_tabstrip_->model()->ReplaceTabContentsAt(index, new_contents); - } - } - - // Update our internal state. - ChangeDraggedContents(new_contents); - - if (view_.get()) - view_->Update(); -} - void DraggedTabController::AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture) { + DCHECK(disposition != CURRENT_TAB); + // Theoretically could be called while dragging if the page tries to // spawn a window. Route this message back to the browser in most cases. - if (disposition == CURRENT_TAB) { - ReplaceContents(source, new_contents); - } else if (original_delegate_) { + if (original_delegate_) { original_delegate_->AddNewContents(source, new_contents, disposition, initial_pos, user_gesture); } @@ -501,7 +472,7 @@ void DraggedTabController::UpdateDockInfo(const gfx::Point& screen_point) { } } -void DraggedTabController::ChangeDraggedContents(TabContents* new_contents) { +void DraggedTabController::SetDraggedContents(TabContents* new_contents) { if (dragged_contents_) { NotificationService::current()->RemoveObserver( this, diff --git a/chrome/browser/views/tabs/dragged_tab_controller.h b/chrome/browser/views/tabs/dragged_tab_controller.h index b03b0cb..00b715b 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.h +++ b/chrome/browser/views/tabs/dragged_tab_controller.h @@ -92,8 +92,6 @@ class DraggedTabController : public TabContentsDelegate, PageTransition::Type transition); virtual void NavigationStateChanged(const TabContents* source, unsigned changed_flags); - virtual void ReplaceContents(TabContents* source, - TabContents* new_contents); virtual void AddNewContents(TabContents* source, TabContents* new_contents, WindowOpenDisposition disposition, @@ -127,11 +125,8 @@ class DraggedTabController : public TabContentsDelegate, void UpdateDockInfo(const gfx::Point& screen_point); - // Replaces the TabContents being dragged with the specified |new_contents|. - // This can occur if the active TabContents for the tab being dragged is - // replaced, e.g. if a transition from one TabContentsType to another occurs - // during the drag. - void ChangeDraggedContents(TabContents* new_contents); + // Sets the TabContents being dragged with the specified |new_contents|. + void SetDraggedContents(TabContents* new_contents); // Saves focus in the window that the drag initiated from. Focus will be // restored appropriately if the drag ends within this same window. @@ -228,9 +223,7 @@ class DraggedTabController : public TabContentsDelegate, void BringWindowUnderMouseToFront(); - // The TabContents being dragged. This can get replaced during the drag if - // the associated NavigationController is navigated to a different - // TabContentsType. + // The TabContents being dragged. TabContents* dragged_contents_; // The original TabContentsDelegate of |dragged_contents_|, before it was diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 24d9112..dc23b07 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -1080,7 +1080,6 @@ 'browser/tab_contents/tab_contents.cc', 'browser/tab_contents/tab_contents.h', 'browser/tab_contents/tab_contents_delegate.h', - 'browser/tab_contents/tab_contents_type.h', 'browser/tab_contents/tab_util.cc', 'browser/tab_contents/tab_util.h', 'browser/tab_contents/web_contents.cc', |