Commit 4717933a authored by avi's avatar avi Committed by Commit bot

Eliminate redundancy in the parameters to NotifyEntryChanged.

BUG=369661
TEST=none

Review URL: https://codereview.chromium.org/1143333003

Cr-Commit-Position: refs/heads/master@{#330800}
parent aa9abe76
...@@ -1114,8 +1114,7 @@ void Browser::TabReplacedAt(TabStripModel* tab_strip_model, ...@@ -1114,8 +1114,7 @@ void Browser::TabReplacedAt(TabStripModel* tab_strip_model,
if (entry_count > 0) { if (entry_count > 0) {
// Send out notification so that observers are updated appropriately. // Send out notification so that observers are updated appropriately.
new_contents->GetController().NotifyEntryChanged( new_contents->GetController().NotifyEntryChanged(
new_contents->GetController().GetEntryAtIndex(entry_count - 1), new_contents->GetController().GetEntryAtIndex(entry_count - 1));
entry_count - 1);
} }
if (session_service) { if (session_service) {
......
...@@ -1910,11 +1910,12 @@ void NavigationControllerImpl::LoadIfNecessary() { ...@@ -1910,11 +1910,12 @@ void NavigationControllerImpl::LoadIfNecessary() {
NavigateToPendingEntry(NO_RELOAD); NavigateToPendingEntry(NO_RELOAD);
} }
void NavigationControllerImpl::NotifyEntryChanged(const NavigationEntry* entry, void NavigationControllerImpl::NotifyEntryChanged(
int index) { const NavigationEntry* entry) {
EntryChangedDetails det; EntryChangedDetails det;
det.changed_entry = entry; det.changed_entry = entry;
det.index = index; det.index = GetIndexOfEntry(
NavigationEntryImpl::FromNavigationEntry(entry));
NotificationService::current()->Notify( NotificationService::current()->Notify(
NOTIFICATION_NAV_ENTRY_CHANGED, NOTIFICATION_NAV_ENTRY_CHANGED,
Source<NavigationController>(this), Source<NavigationController>(this),
......
...@@ -81,7 +81,7 @@ class CONTENT_EXPORT NavigationControllerImpl ...@@ -81,7 +81,7 @@ class CONTENT_EXPORT NavigationControllerImpl
void Reload(bool check_for_repost) override; void Reload(bool check_for_repost) override;
void ReloadIgnoringCache(bool check_for_repost) override; void ReloadIgnoringCache(bool check_for_repost) override;
void ReloadOriginalRequestURL(bool check_for_repost) override; void ReloadOriginalRequestURL(bool check_for_repost) override;
void NotifyEntryChanged(const NavigationEntry* entry, int index) override; void NotifyEntryChanged(const NavigationEntry* entry) override;
void CopyStateFrom(const NavigationController& source) override; void CopyStateFrom(const NavigationController& source) override;
void CopyStateFromAndPrune(NavigationController* source, void CopyStateFromAndPrune(NavigationController* source,
bool replace_entry) override; bool replace_entry) override;
......
...@@ -51,6 +51,11 @@ NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry( ...@@ -51,6 +51,11 @@ NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry(
return static_cast<NavigationEntryImpl*>(entry); return static_cast<NavigationEntryImpl*>(entry);
} }
const NavigationEntryImpl* NavigationEntryImpl::FromNavigationEntry(
const NavigationEntry* entry) {
return static_cast<const NavigationEntryImpl*>(entry);
}
NavigationEntryImpl::NavigationEntryImpl() NavigationEntryImpl::NavigationEntryImpl()
: NavigationEntryImpl(nullptr, -1, GURL(), Referrer(), base::string16(), : NavigationEntryImpl(nullptr, -1, GURL(), Referrer(), base::string16(),
ui::PAGE_TRANSITION_LINK, false) { ui::PAGE_TRANSITION_LINK, false) {
......
...@@ -50,6 +50,8 @@ class CONTENT_EXPORT NavigationEntryImpl ...@@ -50,6 +50,8 @@ class CONTENT_EXPORT NavigationEntryImpl
}; };
static NavigationEntryImpl* FromNavigationEntry(NavigationEntry* entry); static NavigationEntryImpl* FromNavigationEntry(NavigationEntry* entry);
static const NavigationEntryImpl* FromNavigationEntry(
const NavigationEntry* entry);
// The value of bindings() before it is set during commit. // The value of bindings() before it is set during commit.
static int kInvalidBindings; static int kInvalidBindings;
......
...@@ -3634,17 +3634,16 @@ void WebContentsImpl::UpdateState(RenderViewHost* rvh, ...@@ -3634,17 +3634,16 @@ void WebContentsImpl::UpdateState(RenderViewHost* rvh,
// leaving a page, in which case our state may have already been moved to // leaving a page, in which case our state may have already been moved to
// the next page. The navigation controller will look up the appropriate // the next page. The navigation controller will look up the appropriate
// NavigationEntry and update it when it is notified via the delegate. // NavigationEntry and update it when it is notified via the delegate.
NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
int entry_index = controller_.GetEntryIndexWithPageID(
rvh->GetSiteInstance(), page_id); rvh->GetSiteInstance(), page_id);
if (entry_index < 0)
if (!entry)
return; return;
NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index);
if (page_state == entry->GetPageState()) if (page_state == entry->GetPageState())
return; // Nothing to update. return; // Nothing to update.
entry->SetPageState(page_state); entry->SetPageState(page_state);
controller_.NotifyEntryChanged(entry, entry_index); controller_.NotifyEntryChanged(entry);
} }
void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host, void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host,
......
...@@ -410,9 +410,8 @@ class NavigationController { ...@@ -410,9 +410,8 @@ class NavigationController {
virtual bool IsInitialNavigation() const = 0; virtual bool IsInitialNavigation() const = 0;
// Broadcasts the NOTIFICATION_NAV_ENTRY_CHANGED notification for the given // Broadcasts the NOTIFICATION_NAV_ENTRY_CHANGED notification for the given
// entry (which must be at the given index). This will keep things in sync // entry. This will keep things in sync like the saved session.
// like the saved session. virtual void NotifyEntryChanged(const NavigationEntry* entry) = 0;
virtual void NotifyEntryChanged(const NavigationEntry* entry, int index) = 0;
// Copies the navigation state from the given controller to this one. This // Copies the navigation state from the given controller to this one. This
// one should be empty (just created). // one should be empty (just created).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment