Chromium Code Reviews| Index: content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
| diff --git a/content/browser/web_contents/aura/overscroll_navigation_overlay.cc b/content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
| index eeb9d49f40303cb45e53e4c60984eb59d09627b1..a99570b528edbae27c454377da06003ccfcccbb0 100644 |
| --- a/content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
| +++ b/content/browser/web_contents/aura/overscroll_navigation_overlay.cc |
| @@ -21,6 +21,23 @@ |
| #include "ui/gfx/image/image_skia.h" |
| namespace content { |
| +namespace { |
| + |
| +// Returns true if any of the URLs in entry's redirect chain match |url|. |
| +// For non-redirecting URLs, this is equivalent to comparing |url| to |
| +// entry->GetURL(). |
| +bool DoesEntryMatchURL(NavigationEntry* entry, const GURL& url) { |
| + const std::vector<GURL>& redirect_chain = entry->GetRedirectChain(); |
| + for (std::vector<GURL>::const_iterator it = redirect_chain.begin(); |
| + it != redirect_chain.end(); |
|
Charlie Reis
2014/09/18 23:03:46
nit: One more space on this line and the line belo
mfomitchev
2014/09/19 20:03:55
Done.
|
| + it++) { |
| + if (*it == url) |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| +} // namespace |
| // A LayerDelegate that paints an image for the layer. |
| class ImageLayerDelegate : public ui::LayerDelegate { |
| @@ -119,7 +136,6 @@ OverscrollNavigationOverlay::OverscrollNavigationOverlay( |
| image_delegate_(NULL), |
| loading_complete_(false), |
| received_paint_update_(false), |
| - pending_entry_id_(0), |
| slide_direction_(SLIDE_UNKNOWN) { |
| } |
| @@ -130,7 +146,6 @@ void OverscrollNavigationOverlay::StartObserving() { |
| loading_complete_ = false; |
| received_paint_update_ = false; |
| overlay_dismiss_layer_.reset(); |
| - pending_entry_id_ = 0; |
| Observe(web_contents_); |
| // Make sure the overlay window is on top. |
| @@ -140,10 +155,10 @@ void OverscrollNavigationOverlay::StartObserving() { |
| // Assumes the navigation has been initiated. |
| NavigationEntry* pending_entry = |
| web_contents_->GetController().GetPendingEntry(); |
| - // Save id of the pending entry to identify when it loads and paints later. |
| + // Save url of the pending entry to identify when it loads and paints later. |
| // Under some circumstances navigation can leave a null pending entry - |
| // see comments in NavigationControllerImpl::NavigateToPendingEntry(). |
| - pending_entry_id_ = pending_entry ? pending_entry->GetUniqueID() : 0; |
| + pending_entry_url_ = pending_entry ? pending_entry->GetURL() : GURL(); |
| } |
| void OverscrollNavigationOverlay::SetOverlayWindow( |
| @@ -282,23 +297,21 @@ void OverscrollNavigationOverlay::OnWindowSliderDestroyed() { |
| } |
| void OverscrollNavigationOverlay::DidFirstVisuallyNonEmptyPaint() { |
| - int visible_entry_id = |
| - web_contents_->GetController().GetVisibleEntry()->GetUniqueID(); |
| - if (visible_entry_id == pending_entry_id_ || !pending_entry_id_) { |
| + NavigationEntry* visible_entry = |
| + web_contents_->GetController().GetVisibleEntry(); |
| + if (pending_entry_url_.is_empty() || |
| + DoesEntryMatchURL(visible_entry, pending_entry_url_)) { |
| received_paint_update_ = true; |
| StopObservingIfDone(); |
| } |
| } |
| void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) { |
| - // Use the last committed entry rather than the active one, in case a |
| - // pending entry has been created. |
| - int committed_entry_id = |
| - web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID(); |
| - if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) { |
| - loading_complete_ = true; |
| - StopObservingIfDone(); |
| - } |
| + // Don't compare URLs in this case - it's possible they won't match if |
| + // a gesture-nav initiated navigation was interrupted by some other in-site |
| + // navigation ((e.g., from a script, or from a bookmark). |
| + loading_complete_ = true; |
| + StopObservingIfDone(); |
| } |
| } // namespace content |