summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/tab_contents/web_contents_unittest.cc4
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_tab_helper.cc24
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_tab_helper.h3
-rw-r--r--chrome/browser/ui/browser.cc37
-rw-r--r--chrome/browser/ui/browser.h11
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.mm7
-rw-r--r--chrome/browser/ui/cocoa/tabpose_window.mm5
-rw-r--r--chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc12
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc23
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.h5
-rw-r--r--chrome/browser/ui/gtk/tab_contents_container_gtk.cc6
-rw-r--r--chrome/browser/ui/gtk/tab_contents_container_gtk.h5
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc7
-rw-r--r--chrome/browser/ui/webui/web_ui_unittest.cc21
-rw-r--r--content/browser/tab_contents/interstitial_page.cc9
-rw-r--r--content/browser/tab_contents/navigation_controller.cc20
-rw-r--r--content/browser/tab_contents/navigation_controller.h10
-rw-r--r--content/browser/tab_contents/navigation_controller_unittest.cc46
-rw-r--r--content/browser/tab_contents/tab_contents.cc39
-rw-r--r--content/browser/tab_contents/tab_contents.h11
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.cc10
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.h19
22 files changed, 201 insertions, 133 deletions
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index 4830397..56468c7 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -218,7 +218,7 @@ TEST_F(TabContentsTest, UpdateTitle) {
PageTransition::TYPED);
content::LoadCommittedDetails details;
- controller().RendererDidNavigate(params, 0, &details);
+ controller().RendererDidNavigate(params, &details);
contents()->UpdateTitle(rvh(), 0, L" Lots O' Whitespace\n");
EXPECT_EQ(ASCIIToUTF16("Lots O' Whitespace"), contents()->GetTitle());
@@ -240,7 +240,7 @@ TEST_F(TabContentsTest, NTPViewSource) {
ViewHostMsg_FrameNavigate_Params params;
InitNavigateParams(&params, 0, kGURL, PageTransition::TYPED);
content::LoadCommittedDetails details;
- controller().RendererDidNavigate(params, 0, &details);
+ controller().RendererDidNavigate(params, &details);
// Also check title and url.
EXPECT_EQ(ASCIIToUTF16(kUrl), contents()->GetTitle());
EXPECT_TRUE(contents()->ShouldDisplayURL());
diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
index 01582b0..ffe23cf 100644
--- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
@@ -8,6 +8,9 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "content/browser/tab_contents/navigation_controller.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/webui/web_ui.h"
#include "content/common/notification_service.h"
BookmarkTabHelper::BookmarkTabHelper(TabContentsWrapper* tab_contents)
@@ -27,6 +30,27 @@ BookmarkTabHelper::~BookmarkTabHelper() {
registrar_.RemoveAll();
}
+bool BookmarkTabHelper::ShouldShowBookmarkBar() {
+ if (tab_contents()->showing_interstitial_page())
+ return false;
+
+ // See TabContents::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 (tab_contents()->controller().GetLastCommittedEntry()) {
+ // Not the first load, always use the committed Web UI.
+ return tab_contents()->committed_web_ui() &&
+ tab_contents()->committed_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.
+ return tab_contents()->web_ui() &&
+ tab_contents()->web_ui()->force_bookmark_bar_visible();
+}
+
void BookmarkTabHelper::DidNavigateMainFramePostCommit(
const content::LoadCommittedDetails& /*details*/,
const ViewHostMsg_FrameNavigate_Params& /*params*/) {
diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.h b/chrome/browser/ui/bookmarks/bookmark_tab_helper.h
index a39e493..7be376b 100644
--- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.h
+++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.h
@@ -25,6 +25,9 @@ class BookmarkTabHelper : public NotificationObserver,
BookmarkTabHelperDelegate* delegate() const { return delegate_; }
void set_delegate(BookmarkTabHelperDelegate* d) { delegate_ = d; }
+ // Returns true if the bookmark bar should be shown detached.
+ bool ShouldShowBookmarkBar();
+
// TabContentsObserver overrides:
virtual void DidNavigateMainFramePostCommit(
const content::LoadCommittedDetails& details,
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index c9a268a..3530eb8 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -2862,6 +2862,9 @@ void Browser::TabInsertedAt(TabContentsWrapper* contents,
// able to ack. But we know we can close it.
registrar_.Add(this, NotificationType::TAB_CONTENTS_DISCONNECTED,
Source<TabContents>(contents->tab_contents()));
+
+ registrar_.Add(this, NotificationType::INTERSTITIAL_ATTACHED,
+ Source<TabContents>(contents->tab_contents()));
}
void Browser::TabClosingAt(TabStripModel* tab_strip_model,
@@ -3388,6 +3391,29 @@ void Browser::WorkerCrashed() {
l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), true));
}
+TabContentsDelegate::MainFrameCommitDetails*
+ Browser::CreateMainFrameCommitDetails(TabContents* tab) {
+ if (tab != GetSelectedTabContents())
+ return NULL;
+
+ BrowserMainFrameCommitDetails* details = new BrowserMainFrameCommitDetails;
+ details->bookmark_bar_visible = GetSelectedTabContentsWrapper()->
+ bookmark_tab_helper()->ShouldShowBookmarkBar();
+ return details; // Caller takes ownership.
+}
+
+void Browser::DidNavigateMainFramePostCommit(
+ TabContents* tab,
+ const MainFrameCommitDetails& details) {
+ bool visible = static_cast<const BrowserMainFrameCommitDetails&>(details).
+ bookmark_bar_visible;
+ if (tab == GetSelectedTabContents() && visible !=
+ GetSelectedTabContentsWrapper()->bookmark_tab_helper()->
+ ShouldShowBookmarkBar()) {
+ window()->ShelfVisibilityChanged();
+ }
+}
+
///////////////////////////////////////////////////////////////////////////////
// Browser, TabContentsWrapperDelegate implementation:
@@ -3657,6 +3683,10 @@ void Browser::Observe(NotificationType type,
break;
}
+ case NotificationType::INTERSTITIAL_ATTACHED:
+ window()->ShelfVisibilityChanged();
+ break;
+
default:
NOTREACHED() << "Got a notification we didn't register for.";
}
@@ -4073,11 +4103,6 @@ void Browser::ScheduleUIUpdate(const TabContents* source,
TabStripModelObserver::TITLE_NOT_LOADING);
}
- if (changed_flags & TabContents::INVALIDATE_BOOKMARK_BAR) {
- window()->ShelfVisibilityChanged();
- changed_flags &= ~TabContents::INVALIDATE_BOOKMARK_BAR;
- }
-
// If the only updates were synchronously handled above, we're done.
if (changed_flags == 0)
return;
@@ -4485,6 +4510,8 @@ void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index,
ClearUnloadState(contents->tab_contents(), false);
}
+ registrar_.Remove(this, NotificationType::INTERSTITIAL_ATTACHED,
+ Source<TabContents>(contents->tab_contents()));
registrar_.Remove(this, NotificationType::TAB_CONTENTS_DISCONNECTED,
Source<TabContents>(contents->tab_contents()));
}
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 2425b26..9ab8305 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -784,6 +784,12 @@ class Browser : public TabHandlerDelegate,
DETACH_TYPE_EMPTY
};
+ struct BrowserMainFrameCommitDetails : public MainFrameCommitDetails {
+ virtual ~BrowserMainFrameCommitDetails() {}
+
+ bool bookmark_bar_visible;
+ };
+
// Overridden from TabContentsDelegate:
virtual void OpenURLFromTab(TabContents* source,
const GURL& url,
@@ -838,6 +844,11 @@ class Browser : public TabHandlerDelegate,
NavigationType::Type navigation_type);
virtual void ContentRestrictionsChanged(TabContents* source);
virtual void WorkerCrashed();
+ virtual MainFrameCommitDetails* CreateMainFrameCommitDetails(
+ TabContents* tab);
+ virtual void DidNavigateMainFramePostCommit(
+ TabContents* tab,
+ const MainFrameCommitDetails& details);
// Overridden from TabContentsWrapperDelegate:
virtual void OnDidGetApplicationInfo(TabContentsWrapper* source,
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index 2eac331..7e334d5 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -10,6 +10,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/browser_list.h"
#import "chrome/browser/ui/cocoa/fast_resize_view.h"
#import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
@@ -22,6 +23,7 @@
#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
@@ -480,9 +482,8 @@ willPositionSheet:(NSWindow*)sheet
return NO;
DCHECK(browser_.get());
- TabContents* contents = browser_->GetSelectedTabContents();
- return (contents &&
- contents->ShouldShowBookmarkBar() &&
+ TabContentsWrapper* tab = browser_->GetSelectedTabContentsWrapper();
+ return (tab && tab->bookmark_tab_helper()->ShouldShowBookmarkBar() &&
![previewableContentsController_ isShowingPreview]);
}
diff --git a/chrome/browser/ui/cocoa/tabpose_window.mm b/chrome/browser/ui/cocoa/tabpose_window.mm
index a8ba03e1..0ea879e 100644
--- a/chrome/browser/ui/cocoa/tabpose_window.mm
+++ b/chrome/browser/ui/cocoa/tabpose_window.mm
@@ -21,6 +21,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
#include "chrome/browser/tab_contents/thumbnail_generator.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h"
@@ -237,8 +238,8 @@ void ThumbnailLoader::LoadThumbnail() {
bool always_show_bookmark_bar =
contents_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
bool has_detached_bookmark_bar =
- contents_->tab_contents()->ShouldShowBookmarkBar() &&
- !always_show_bookmark_bar;
+ contents_->bookmark_tab_helper()->ShouldShowBookmarkBar() &&
+ !always_show_bookmark_bar;
if (has_detached_bookmark_bar)
topOffset += bookmarks::kNTPBookmarkBarHeight;
diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
index 280fd3f..b3bb748 100644
--- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
+++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.cc
@@ -17,6 +17,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/sync_ui_util.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/gtk/bookmarks/bookmark_menu_controller_gtk.h"
#include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h"
@@ -33,6 +34,7 @@
#include "chrome/browser/ui/gtk/tabs/tab_strip_gtk.h"
#include "chrome/browser/ui/gtk/tabstrip_origin_provider.h"
#include "chrome/browser/ui/gtk/view_id_util.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
@@ -398,8 +400,9 @@ bool BookmarkBarGtk::IsAnimating() {
}
bool BookmarkBarGtk::OnNewTabPage() {
- return (browser_ && browser_->GetSelectedTabContents() &&
- browser_->GetSelectedTabContents()->ShouldShowBookmarkBar());
+ return (browser_ && browser_->GetSelectedTabContentsWrapper() &&
+ browser_->GetSelectedTabContentsWrapper()->bookmark_tab_helper()->
+ ShouldShowBookmarkBar());
}
void BookmarkBarGtk::Loaded(BookmarkModel* model) {
@@ -631,8 +634,9 @@ bool BookmarkBarGtk::ShouldBeFloating() {
return false;
return (!IsAlwaysShown() || (window_ && window_->IsFullscreen())) &&
- window_ && window_->GetDisplayedTabContents() &&
- window_->GetDisplayedTabContents()->ShouldShowBookmarkBar();
+ window_ && window_->GetDisplayedTab() &&
+ window_->GetDisplayedTab()->bookmark_tab_helper()->
+ ShouldShowBookmarkBar();
}
void BookmarkBarGtk::UpdateFloatingState() {
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index c521ff9..f3b9706 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -35,6 +35,7 @@
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_list.h"
@@ -1252,17 +1253,17 @@ void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) {
if (!IsBookmarkBarSupported())
return;
- TabContents* contents = GetDisplayedTabContents();
+ TabContentsWrapper* tab = GetDisplayedTab();
bool show_bar = false;
- if (contents) {
- bookmark_bar_->SetProfile(contents->profile());
- bookmark_bar_->SetPageNavigator(contents);
+ if (tab) {
+ bookmark_bar_->SetProfile(tab->profile());
+ bookmark_bar_->SetPageNavigator(tab->tab_contents());
show_bar = true;
}
- if (show_bar && contents && !contents->ShouldShowBookmarkBar()) {
- PrefService* prefs = contents->profile()->GetPrefs();
+ if (show_bar && tab && !tab->bookmark_tab_helper()->ShouldShowBookmarkBar()) {
+ PrefService* prefs = tab->profile()->GetPrefs();
show_bar = prefs->GetBoolean(prefs::kShowBookmarkBar) &&
prefs->GetBoolean(prefs::kEnableBookmarkBar) &&
!IsFullscreen();
@@ -1325,9 +1326,9 @@ gboolean BrowserWindowGtk::OnConfigure(GtkWidget* widget,
GetLocationBar()->location_entry()->ClosePopup();
- TabContents* tab_contents = GetDisplayedTabContents();
- if (tab_contents) {
- RenderViewHost* rvh = tab_contents->render_view_host();
+ TabContentsWrapper* tab = GetDisplayedTab();
+ if (tab) {
+ RenderViewHost* rvh = tab->tab_contents()->render_view_host();
rvh->Send(new ViewMsg_MoveOrResizeStarted(rvh->routing_id()));
}
@@ -1536,8 +1537,8 @@ void BrowserWindowGtk::BookmarkBarIsFloating(bool is_floating) {
PlaceBookmarkBar(is_floating);
}
-TabContents* BrowserWindowGtk::GetDisplayedTabContents() {
- return contents_container_->GetVisibleTabContents();
+TabContentsWrapper* BrowserWindowGtk::GetDisplayedTab() {
+ return contents_container_->GetVisibleTab();
}
void BrowserWindowGtk::QueueToolbarRedraw() {
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h
index fd82a64..b8ecda9 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.h
+++ b/chrome/browser/ui/gtk/browser_window_gtk.h
@@ -206,9 +206,8 @@ class BrowserWindowGtk : public BrowserWindow,
// This should only be called by the bookmark bar itself.
void BookmarkBarIsFloating(bool is_floating);
- // Returns the tab contents we're currently displaying in the tab contents
- // container.
- TabContents* GetDisplayedTabContents();
+ // Returns the tab we're currently displaying in the tab contents container.
+ TabContentsWrapper* GetDisplayedTab();
static void RegisterUserPrefs(PrefService* prefs);
diff --git a/chrome/browser/ui/gtk/tab_contents_container_gtk.cc b/chrome/browser/ui/gtk/tab_contents_container_gtk.cc
index 3f44c01..64ea11f 100644
--- a/chrome/browser/ui/gtk/tab_contents_container_gtk.cc
+++ b/chrome/browser/ui/gtk/tab_contents_container_gtk.cc
@@ -82,10 +82,8 @@ void TabContentsContainerGtk::SetTab(TabContentsWrapper* tab) {
}
}
-TabContents* TabContentsContainerGtk::GetVisibleTabContents() {
- if (preview_)
- return preview_->tab_contents();
- return tab_ ? tab_->tab_contents() : NULL;
+TabContentsWrapper* TabContentsContainerGtk::GetVisibleTab() {
+ return preview_ ? preview_ : tab_;
}
void TabContentsContainerGtk::SetPreview(TabContentsWrapper* preview) {
diff --git a/chrome/browser/ui/gtk/tab_contents_container_gtk.h b/chrome/browser/ui/gtk/tab_contents_container_gtk.h
index 4adcd04..0bcc19a 100644
--- a/chrome/browser/ui/gtk/tab_contents_container_gtk.h
+++ b/chrome/browser/ui/gtk/tab_contents_container_gtk.h
@@ -34,9 +34,8 @@ class TabContentsContainerGtk : public NotificationObserver,
void SetTab(TabContentsWrapper* tab);
TabContentsWrapper* tab() const { return tab_; }
- // Gets the tab contents currently being displayed (either |tab_contents_| or
- // |preview_contents_|).
- TabContents* GetVisibleTabContents();
+ // Returns the TabContentsWrapper currently displayed.
+ TabContentsWrapper* GetVisibleTab();
void SetPreview(TabContentsWrapper* preview);
void PopPreview();
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
index 3d418ca6..569af2a 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -21,7 +21,9 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h"
#include "chrome/browser/ui/views/event_utils.h"
@@ -437,8 +439,9 @@ bool BookmarkBarView::IsAlwaysShown() const {
}
bool BookmarkBarView::OnNewTabPage() const {
- return (browser_ && browser_->GetSelectedTabContents() &&
- browser_->GetSelectedTabContents()->ShouldShowBookmarkBar());
+ return (browser_ && browser_->GetSelectedTabContentsWrapper() &&
+ browser_->GetSelectedTabContentsWrapper()->bookmark_tab_helper()->
+ ShouldShowBookmarkBar());
}
int BookmarkBarView::GetToolbarOverlap(bool return_max) const {
diff --git a/chrome/browser/ui/webui/web_ui_unittest.cc b/chrome/browser/ui/webui/web_ui_unittest.cc
index a37b5cf..93578fc 100644
--- a/chrome/browser/ui/webui/web_ui_unittest.cc
+++ b/chrome/browser/ui/webui/web_ui_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/browser/favicon/favicon_tab_helper.h"
+#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
#include "chrome/common/url_constants.h"
@@ -36,7 +37,7 @@ class WebUITest : public TabContentsWrapperTestHarness {
// Check the things the pending Web UI should have set.
EXPECT_FALSE(contents->ShouldDisplayURL());
EXPECT_FALSE(wrapper->favicon_tab_helper()->ShouldDisplayFavicon());
- EXPECT_TRUE(contents->ShouldShowBookmarkBar());
+ EXPECT_TRUE(wrapper->bookmark_tab_helper()->ShouldShowBookmarkBar());
EXPECT_TRUE(contents->FocusLocationBarByDefault());
// Now commit the load.
@@ -46,7 +47,7 @@ class WebUITest : public TabContentsWrapperTestHarness {
// The same flags should be set as before now that the load has committed.
EXPECT_FALSE(contents->ShouldDisplayURL());
EXPECT_FALSE(wrapper->favicon_tab_helper()->ShouldDisplayFavicon());
- EXPECT_TRUE(contents->ShouldShowBookmarkBar());
+ EXPECT_TRUE(wrapper->bookmark_tab_helper()->ShouldShowBookmarkBar());
EXPECT_TRUE(contents->FocusLocationBarByDefault());
// Start a pending navigation to a regular page.
@@ -57,7 +58,7 @@ class WebUITest : public TabContentsWrapperTestHarness {
// should reflect the old one (bookmark bar) until it has committed.
EXPECT_TRUE(contents->ShouldDisplayURL());
EXPECT_TRUE(wrapper->favicon_tab_helper()->ShouldDisplayFavicon());
- EXPECT_TRUE(contents->ShouldShowBookmarkBar());
+ EXPECT_TRUE(wrapper->bookmark_tab_helper()->ShouldShowBookmarkBar());
EXPECT_FALSE(contents->FocusLocationBarByDefault());
// Commit the regular page load. Note that we must send it to the "pending"
@@ -77,7 +78,7 @@ class WebUITest : public TabContentsWrapperTestHarness {
// The state should now reflect a regular page.
EXPECT_TRUE(contents->ShouldDisplayURL());
EXPECT_TRUE(wrapper->favicon_tab_helper()->ShouldDisplayFavicon());
- EXPECT_FALSE(contents->ShouldShowBookmarkBar());
+ EXPECT_FALSE(wrapper->bookmark_tab_helper()->ShouldShowBookmarkBar());
EXPECT_FALSE(contents->FocusLocationBarByDefault());
}
@@ -117,7 +118,8 @@ TEST_F(WebUITest, WebUIToWebUI) {
EXPECT_FALSE(contents()->ShouldDisplayURL());
EXPECT_FALSE(
contents_wrapper()->favicon_tab_helper()->ShouldDisplayFavicon());
- EXPECT_TRUE(contents()->ShouldShowBookmarkBar());
+ EXPECT_TRUE(
+ contents_wrapper()->bookmark_tab_helper()->ShouldShowBookmarkBar());
EXPECT_TRUE(contents()->FocusLocationBarByDefault());
}
@@ -130,14 +132,16 @@ TEST_F(WebUITest, StandardToWebUI) {
// The state should now reflect the default.
EXPECT_TRUE(contents()->ShouldDisplayURL());
EXPECT_TRUE(contents_wrapper()->favicon_tab_helper()->ShouldDisplayFavicon());
- EXPECT_FALSE(contents()->ShouldShowBookmarkBar());
+ EXPECT_FALSE(
+ contents_wrapper()->bookmark_tab_helper()->ShouldShowBookmarkBar());
EXPECT_FALSE(contents()->FocusLocationBarByDefault());
// Commit the load, the state should be the same.
rvh()->SendNavigate(1, std_url);
EXPECT_TRUE(contents()->ShouldDisplayURL());
EXPECT_TRUE(contents_wrapper()->favicon_tab_helper()->ShouldDisplayFavicon());
- EXPECT_FALSE(contents()->ShouldShowBookmarkBar());
+ EXPECT_FALSE(
+ contents_wrapper()->bookmark_tab_helper()->ShouldShowBookmarkBar());
EXPECT_FALSE(contents()->FocusLocationBarByDefault());
// Start a pending load for a WebUI.
@@ -145,7 +149,8 @@ TEST_F(WebUITest, StandardToWebUI) {
controller().LoadURL(new_tab_url, GURL(), PageTransition::LINK);
EXPECT_FALSE(contents()->ShouldDisplayURL());
EXPECT_TRUE(contents_wrapper()->favicon_tab_helper()->ShouldDisplayFavicon());
- EXPECT_FALSE(contents()->ShouldShowBookmarkBar());
+ EXPECT_FALSE(
+ contents_wrapper()->bookmark_tab_helper()->ShouldShowBookmarkBar());
EXPECT_TRUE(contents()->FocusLocationBarByDefault());
// Committing Web UI is tested above.
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();
};