diff options
Diffstat (limited to 'content/browser')
-rw-r--r-- | content/browser/tab_contents/interstitial_page.cc | 9 | ||||
-rw-r--r-- | content/browser/tab_contents/navigation_controller.cc | 20 | ||||
-rw-r--r-- | content/browser/tab_contents/navigation_controller.h | 10 | ||||
-rw-r--r-- | content/browser/tab_contents/navigation_controller_unittest.cc | 46 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 39 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 11 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_delegate.cc | 10 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_delegate.h | 19 |
8 files changed, 78 insertions, 86 deletions
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 4292f15..6b928d3 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -352,11 +352,10 @@ void InterstitialPage::DidNavigate( render_view_host_->view()->Show(); tab_->set_interstitial_page(this); - // Hide the bookmark bar. Note that this has to happen after the interstitial - // page was registered with |tab_|, since there will be a callback to |tab_| - // testing if an interstitial page is showing before hiding the bookmark bar. - tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_BOOKMARK_BAR); - + // This notification hides the bookmark bar. Note that this has to happen + // after the interstitial page was registered with |tab_|, since there will be + // a callback to |tab_| testing if an interstitial page is showing before + // hiding the bookmark bar. NotificationService::current()->Notify( NotificationType::INTERSTITIAL_ATTACHED, Source<TabContents>(tab_), diff --git a/content/browser/tab_contents/navigation_controller.cc b/content/browser/tab_contents/navigation_controller.cc index 0c32761..35b266c 100644 --- a/content/browser/tab_contents/navigation_controller.cc +++ b/content/browser/tab_contents/navigation_controller.cc @@ -33,8 +33,7 @@ namespace { -const int kInvalidateAllButShelves = - 0xFFFFFFFF & ~TabContents::INVALIDATE_BOOKMARK_BAR; +const int kInvalidateAll = 0xFFFFFFFF; // Invoked when entries have been pruned, or removed. For example, if the // current entries are [google, digg, yahoo], with the current entry google, @@ -471,7 +470,7 @@ void NavigationController::AddTransientEntry(NavigationEntry* entry) { DiscardTransientEntry(); entries_.insert(entries_.begin() + index, linked_ptr<NavigationEntry>(entry)); transient_entry_index_ = index; - tab_contents_->NotifyNavigationStateChanged(kInvalidateAllButShelves); + tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); } void NavigationController::LoadURL(const GURL& url, const GURL& referrer, @@ -491,7 +490,6 @@ void NavigationController::DocumentLoadedInFrame() { bool NavigationController::RendererDidNavigate( const ViewHostMsg_FrameNavigate_Params& params, - int extra_invalidate_flags, content::LoadCommittedDetails* details) { // Save the previous state before we clobber it. @@ -546,8 +544,8 @@ bool NavigationController::RendererDidNavigate( // the caller that nothing has happened. if (pending_entry_) { DiscardNonCommittedEntries(); - extra_invalidate_flags |= TabContents::INVALIDATE_URL; - tab_contents_->NotifyNavigationStateChanged(extra_invalidate_flags); + tab_contents_->NotifyNavigationStateChanged( + TabContents::INVALIDATE_URL); } return false; default: @@ -583,7 +581,7 @@ bool NavigationController::RendererDidNavigate( details->is_main_frame = PageTransition::IsMainFrame(params.transition); details->serialized_security_info = params.security_info; details->http_status_code = params.http_status_code; - NotifyNavigationEntryCommitted(details, extra_invalidate_flags); + NotifyNavigationEntryCommitted(details); return true; } @@ -1012,7 +1010,7 @@ void NavigationController::DiscardNonCommittedEntries() { // If there was a transient entry, invalidate everything so the new active // entry state is shown. if (transient) { - tab_contents_->NotifyNavigationStateChanged(kInvalidateAllButShelves); + tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); } } @@ -1083,8 +1081,7 @@ void NavigationController::NavigateToPendingEntry(ReloadType reload_type) { } void NavigationController::NotifyNavigationEntryCommitted( - content::LoadCommittedDetails* details, - int extra_invalidate_flags) { + content::LoadCommittedDetails* details) { details->entry = GetActiveEntry(); NotificationDetails notification_details = Details<content::LoadCommittedDetails>(details); @@ -1097,8 +1094,7 @@ void NavigationController::NotifyNavigationEntryCommitted( // TODO(pkasting): http://b/1113079 Probably these explicit notification paths // should be removed, and interested parties should just listen for the // notification below instead. - tab_contents_->NotifyNavigationStateChanged( - kInvalidateAllButShelves | extra_invalidate_flags); + tab_contents_->NotifyNavigationStateChanged(kInvalidateAll); NotificationService::current()->Notify( NotificationType::NAV_ENTRY_COMMITTED, diff --git a/content/browser/tab_contents/navigation_controller.h b/content/browser/tab_contents/navigation_controller.h index e36a4b0..5994ce2 100644 --- a/content/browser/tab_contents/navigation_controller.h +++ b/content/browser/tab_contents/navigation_controller.h @@ -226,11 +226,7 @@ class NavigationController { // // In the case that nothing has changed, the details structure is undefined // and it will return false. - // - // |extra_invalidate_flags| are an additional set of flags (InvalidateTypes) - // added to the flags sent to the delegate's NotifyNavigationStateChanged. bool RendererDidNavigate(const ViewHostMsg_FrameNavigate_Params& params, - int extra_invalidate_flags, content::LoadCommittedDetails* details); // Notifies us that we just became active. This is used by the TabContents @@ -383,11 +379,7 @@ class NavigationController { // Allows the derived class to issue notifications that a load has been // committed. This will fill in the active entry to the details structure. - // - // |extra_invalidate_flags| are an additional set of flags (InvalidateTypes) - // added to the flags sent to the delegate's NotifyNavigationStateChanged. - void NotifyNavigationEntryCommitted(content::LoadCommittedDetails* details, - int extra_invalidate_flags); + void NotifyNavigationEntryCommitted(content::LoadCommittedDetails* details); // Updates the virtual URL of an entry to match a new URL, for cases where // the real renderer URL is derived from the virtual URL, like view-source: diff --git a/content/browser/tab_contents/navigation_controller_unittest.cc b/content/browser/tab_contents/navigation_controller_unittest.cc index 64052f4..6a5a368 100644 --- a/content/browser/tab_contents/navigation_controller_unittest.cc +++ b/content/browser/tab_contents/navigation_controller_unittest.cc @@ -774,7 +774,7 @@ TEST_F(NavigationControllerTest, Redirect) { content::LoadCommittedDetails details; EXPECT_EQ(0U, notifications.size()); - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); @@ -830,7 +830,7 @@ TEST_F(NavigationControllerTest, PostThenRedirect) { content::LoadCommittedDetails details; EXPECT_EQ(0U, notifications.size()); - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); @@ -876,7 +876,7 @@ TEST_F(NavigationControllerTest, ImmediateRedirect) { content::LoadCommittedDetails details; EXPECT_EQ(0U, notifications.size()); - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); @@ -914,7 +914,7 @@ TEST_F(NavigationControllerTest, NewSubframe) { params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url2)); content::LoadCommittedDetails details; - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); EXPECT_EQ(url1, details.previous_url); @@ -950,7 +950,7 @@ TEST_F(NavigationControllerTest, SubframeOnEmptyPage) { params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); content::LoadCommittedDetails details; - EXPECT_FALSE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_FALSE(controller().RendererDidNavigate(params, &details)); EXPECT_EQ(0U, notifications.size()); } @@ -977,7 +977,7 @@ TEST_F(NavigationControllerTest, AutoSubframe) { // Navigating should do nothing. content::LoadCommittedDetails details; - EXPECT_FALSE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_FALSE(controller().RendererDidNavigate(params, &details)); EXPECT_EQ(0U, notifications.size()); // There should still be only one entry. @@ -1008,7 +1008,7 @@ TEST_F(NavigationControllerTest, BackSubframe) { // This should generate a new entry. content::LoadCommittedDetails details; - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); EXPECT_EQ(2, controller().entry_count()); @@ -1017,7 +1017,7 @@ TEST_F(NavigationControllerTest, BackSubframe) { const GURL url3("http://foo3"); params.page_id = 2; params.url = url3; - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); EXPECT_EQ(3, controller().entry_count()); @@ -1027,7 +1027,7 @@ TEST_F(NavigationControllerTest, BackSubframe) { controller().GoBack(); params.url = url2; params.page_id = 1; - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); EXPECT_EQ(3, controller().entry_count()); @@ -1037,7 +1037,7 @@ TEST_F(NavigationControllerTest, BackSubframe) { controller().GoBack(); params.url = url1; params.page_id = 0; - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); EXPECT_EQ(3, controller().entry_count()); @@ -1092,7 +1092,7 @@ TEST_F(NavigationControllerTest, InPage) { // This should generate a new entry. content::LoadCommittedDetails details; - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); EXPECT_TRUE(details.is_in_page); @@ -1104,7 +1104,7 @@ TEST_F(NavigationControllerTest, InPage) { controller().GoBack(); back_params.url = url1; back_params.page_id = 0; - EXPECT_TRUE(controller().RendererDidNavigate(back_params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(back_params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); // is_in_page is false in that case but should be true. @@ -1119,7 +1119,7 @@ TEST_F(NavigationControllerTest, InPage) { controller().GoForward(); forward_params.url = url2; forward_params.page_id = 1; - EXPECT_TRUE(controller().RendererDidNavigate(forward_params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(forward_params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); EXPECT_TRUE(details.is_in_page); @@ -1133,9 +1133,9 @@ TEST_F(NavigationControllerTest, InPage) { // one identified by an existing page ID. This would result in the second URL // losing the reference fragment when you navigate away from it and then back. controller().GoBack(); - EXPECT_TRUE(controller().RendererDidNavigate(back_params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(back_params, &details)); controller().GoForward(); - EXPECT_TRUE(controller().RendererDidNavigate(forward_params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(forward_params, &details)); EXPECT_EQ(forward_params.url, controller().GetActiveEntry()->url()); @@ -1144,7 +1144,7 @@ TEST_F(NavigationControllerTest, InPage) { params.page_id = 2; params.url = url3; notifications.Reset(); - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); EXPECT_FALSE(details.is_in_page); @@ -1173,7 +1173,7 @@ TEST_F(NavigationControllerTest, InPage_Replace) { // This should NOT generate a new entry. content::LoadCommittedDetails details; - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check2AndReset( NotificationType::NAV_LIST_PRUNED, NotificationType::NAV_ENTRY_COMMITTED)); @@ -1224,7 +1224,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) { // This should NOT generate a new entry. content::LoadCommittedDetails details; - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check2AndReset( NotificationType::NAV_LIST_PRUNED, NotificationType::NAV_ENTRY_COMMITTED)); @@ -1249,7 +1249,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) { // This SHOULD generate a new entry. content::LoadCommittedDetails details; - EXPECT_TRUE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_TRUE(controller().RendererDidNavigate(params, &details)); EXPECT_TRUE(notifications.Check1AndReset( NotificationType::NAV_ENTRY_COMMITTED)); EXPECT_FALSE(details.is_in_page); @@ -1381,7 +1381,7 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { params.is_post = false; params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(url)); content::LoadCommittedDetails details; - our_controller.RendererDidNavigate(params, 0, &details); + our_controller.RendererDidNavigate(params, &details); // There should be no longer any pending entry and one committed one. This // means that we were able to locate the entry, assign its site instance, and @@ -1646,7 +1646,7 @@ TEST_F(NavigationControllerTest, SameSubframe) { params.is_post = false; params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(subframe)); content::LoadCommittedDetails details; - EXPECT_FALSE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_FALSE(controller().RendererDidNavigate(params, &details)); // Nothing should have changed. EXPECT_EQ(controller().entry_count(), 1); @@ -1673,7 +1673,7 @@ TEST_F(NavigationControllerTest, ViewSourceRedirect) { params.content_state = webkit_glue::CreateHistoryStateForURL(GURL(result_url)); content::LoadCommittedDetails details; - controller().RendererDidNavigate(params, 0, &details); + controller().RendererDidNavigate(params, &details); EXPECT_EQ(ASCIIToUTF16(kExpected), contents()->GetTitle()); EXPECT_TRUE(contents()->ShouldDisplayURL()); @@ -1739,7 +1739,7 @@ TEST_F(NavigationControllerTest, SubframeWhilePending) { content::LoadCommittedDetails details; // This should return false meaning that nothing was actually updated. - EXPECT_FALSE(controller().RendererDidNavigate(params, 0, &details)); + EXPECT_FALSE(controller().RendererDidNavigate(params, &details)); // The notification should have updated the last committed one, and not // the pending load. diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 20b0a6c..6c9810e 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -666,28 +666,6 @@ void TabContents::SetFocusToLocationBar(bool select_all) { delegate()->SetFocusToLocationBar(select_all); } -bool TabContents::ShouldShowBookmarkBar() { - if (showing_interstitial_page()) - return false; - - // See GetWebUIForCurrentState() comment for more info. This case is very - // similar, but for non-first loads, we want to use the committed entry. This - // is so the bookmarks bar disappears at the same time the page does. - if (controller_.GetLastCommittedEntry()) { - // Not the first load, always use the committed Web UI. - return (render_manager_.web_ui() == NULL) ? - false : render_manager_.web_ui()->force_bookmark_bar_visible(); - } - - // When it's the first load, we know either the pending one or the committed - // one will have the Web UI in it (see GetWebUIForCurrentState), and only one - // of them will be valid, so we can just check both. - if (render_manager_.pending_web_ui()) - return render_manager_.pending_web_ui()->force_bookmark_bar_visible(); - return (render_manager_.web_ui() == NULL) ? - false : render_manager_.web_ui()->force_bookmark_bar_visible(); -} - void TabContents::WillClose(ConstrainedWindow* window) { ConstrainedWindowList::iterator i( std::find(child_windows_.begin(), child_windows_.end(), window)); @@ -1349,15 +1327,12 @@ void TabContents::RenderViewDeleted(RenderViewHost* rvh) { void TabContents::DidNavigate(RenderViewHost* rvh, const ViewHostMsg_FrameNavigate_Params& params) { - int extra_invalidate_flags = 0; + scoped_ptr<TabContentsDelegate::MainFrameCommitDetails> commit_details; if (PageTransition::IsMainFrame(params.transition)) { - bool was_bookmark_bar_visible = ShouldShowBookmarkBar(); - + if (delegate()) + commit_details.reset(delegate()->CreateMainFrameCommitDetails(this)); render_manager_.DidNavigateMainFrame(rvh); - - if (was_bookmark_bar_visible != ShouldShowBookmarkBar()) - extra_invalidate_flags |= INVALIDATE_BOOKMARK_BAR; } // Update the site of the SiteInstance if it doesn't have one yet. @@ -1376,8 +1351,7 @@ void TabContents::DidNavigate(RenderViewHost* rvh, contents_mime_type_ = params.contents_mime_type; content::LoadCommittedDetails details; - bool did_navigate = controller_.RendererDidNavigate( - params, extra_invalidate_flags, &details); + bool did_navigate = controller_.RendererDidNavigate(params, &details); // Send notification about committed provisional loads. This notification is // different from the NAV_ENTRY_COMMITTED notification which doesn't include @@ -1412,8 +1386,11 @@ void TabContents::DidNavigate(RenderViewHost* rvh, // necessary, please). // Run post-commit tasks. - if (details.is_main_frame) + if (details.is_main_frame) { DidNavigateMainFramePostCommit(details, params); + if (delegate() && commit_details.get()) + delegate()->DidNavigateMainFramePostCommit(this, *commit_details); + } DidNavigateAnyFramePostCommit(rvh, details, params); } diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index b3472af..4220e20 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -72,9 +72,7 @@ class TabContents : public PageNavigator, // state changed. INVALIDATE_LOAD = 1 << 2, // The loading state has changed. INVALIDATE_PAGE_ACTIONS = 1 << 3, // Page action icons have changed. - INVALIDATE_BOOKMARK_BAR = 1 << 4, // State of ShouldShowBookmarkBar - // changed. - INVALIDATE_TITLE = 1 << 5, // The title changed. + INVALIDATE_TITLE = 1 << 4, // The title changed. }; // |base_tab_contents| is used if we want to size the new tab contents view @@ -120,6 +118,10 @@ class TabContents : public PageNavigator, return render_manager_.current_host(); } + WebUI* committed_web_ui() const { + return render_manager_.web_ui(); + } + WebUI* web_ui() const { return render_manager_.web_ui() ? render_manager_.web_ui() : render_manager_.pending_web_ui(); @@ -350,9 +352,6 @@ class TabContents : public PageNavigator, // Toolbars and such --------------------------------------------------------- - // Returns true if a Bookmark Bar should be shown for this tab. - virtual bool ShouldShowBookmarkBar(); - // Called when a ConstrainedWindow we own is about to be closed. void WillClose(ConstrainedWindow* window); diff --git a/content/browser/tab_contents/tab_contents_delegate.cc b/content/browser/tab_contents/tab_contents_delegate.cc index d63c823..2a3a380 100644 --- a/content/browser/tab_contents/tab_contents_delegate.cc +++ b/content/browser/tab_contents/tab_contents_delegate.cc @@ -185,5 +185,15 @@ bool TabContentsDelegate::ShouldShowHungRendererDialog() { void TabContentsDelegate::WorkerCrashed() { } +TabContentsDelegate::MainFrameCommitDetails* +TabContentsDelegate::CreateMainFrameCommitDetails(TabContents* tab) { + return NULL; +} + +void TabContentsDelegate::DidNavigateMainFramePostCommit( + TabContents* tab, + const MainFrameCommitDetails& details) { +} + TabContentsDelegate::~TabContentsDelegate() { } diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h index ca23897..776d905 100644 --- a/content/browser/tab_contents/tab_contents_delegate.h +++ b/content/browser/tab_contents/tab_contents_delegate.h @@ -37,6 +37,15 @@ class TabContents; // TabContents and to provide necessary functionality. class TabContentsDelegate { public: + // When a main frame navigation occurs CreateMainFrameCommitDetails() is + // invoked. The |MainFrameCommitDetails| returned from + // CreateMainFrameCommitDetails() are then passed to + // DidNavigateMainFramePostCommit. This allows the delegate to save state + // before the commit and get that state after the commit. + struct MainFrameCommitDetails { + virtual ~MainFrameCommitDetails() {} + }; + // 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. @@ -277,6 +286,16 @@ class TabContentsDelegate { // Notification that a worker associated with this tab has crashed. virtual void WorkerCrashed(); + // See description above MainFrameCommitDetails for details. Default returns + // NULL. Caller owns return value. + virtual MainFrameCommitDetails* CreateMainFrameCommitDetails( + TabContents* tab); + + // See description above MainFrameCommitDetails for details. + virtual void DidNavigateMainFramePostCommit( + TabContents* tab, + const MainFrameCommitDetails& details); + protected: virtual ~TabContentsDelegate(); }; |