summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroysteine@chromium.org <oysteine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-31 01:29:00 +0000
committeroysteine@chromium.org <oysteine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-31 01:29:00 +0000
commit0c3c54fb6d8883fa0856c8707c7c8f8c5fb98255 (patch)
tree423ad037c02f956c63de100bc79c7ed1bcb229bf
parentece26abba4b45cfbc13ffef8735b5f3bb2f08ce2 (diff)
downloadchromium_src-0c3c54fb6d8883fa0856c8707c7c8f8c5fb98255.zip
chromium_src-0c3c54fb6d8883fa0856c8707c7c8f8c5fb98255.tar.gz
chromium_src-0c3c54fb6d8883fa0856c8707c7c8f8c5fb98255.tar.bz2
Navigation transitions: Initiate transition navigations.
A is_transition_navigation flag now gets passed up from Blink (through decidePolicyForNavigation and OpenURL) to the navigator, which then calls didStartNavigationTransitionForFrame on the ContentViewCore of the embedder if it's set. R=nasko,jam BUG=370696 Review URL: https://codereview.chromium.org/358973005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286672 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/android/content_view_core_impl.cc9
-rw-r--r--content/browser/android/content_view_core_impl.h3
-rw-r--r--content/browser/frame_host/navigation_controller_impl_unittest.cc12
-rw-r--r--content/browser/frame_host/navigator.h3
-rw-r--r--content/browser/frame_host/navigator_delegate.h4
-rw-r--r--content/browser/frame_host/navigator_impl.cc6
-rw-r--r--content/browser/frame_host/navigator_impl.h3
-rw-r--r--content/browser/frame_host/render_frame_host_impl.cc6
-rw-r--r--content/browser/frame_host/render_frame_host_impl.h3
-rw-r--r--content/browser/web_contents/web_contents_impl.cc9
-rw-r--r--content/browser/web_contents/web_contents_impl.h2
-rw-r--r--content/common/frame_messages.h8
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java13
-rw-r--r--content/public/android/javatests/src/org/chromium/content/browser/TransitionTest.java4
-rw-r--r--content/renderer/render_frame_impl.cc109
-rw-r--r--content/renderer/render_frame_impl.h17
-rw-r--r--content/renderer/render_view_browsertest.cc104
-rw-r--r--content/shell/renderer/test_runner/web_frame_test_proxy.h17
-rw-r--r--content/shell/renderer/test_runner/web_test_proxy.cc13
-rw-r--r--content/shell/renderer/test_runner/web_test_proxy.h8
-rw-r--r--content/test/test_render_frame_host.cc4
21 files changed, 192 insertions, 165 deletions
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index fe02f84..1698bf9 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -1583,6 +1583,15 @@ bool ContentViewCoreImpl::WillHandleDeferAfterResponseStarted() {
obj.obj());
}
+void ContentViewCoreImpl::DidStartNavigationTransitionForFrame(int64 frame_id) {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj(java_ref_.get(env));
+ if (obj.is_null())
+ return;
+ Java_ContentViewCore_didStartNavigationTransitionForFrame(
+ env, obj.obj(), frame_id);
+}
+
void ContentViewCoreImpl::OnSmartClipDataExtracted(
const base::string16& text,
const base::string16& html,
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h
index a033f21..7624c74 100644
--- a/content/browser/android/content_view_core_impl.h
+++ b/content/browser/android/content_view_core_impl.h
@@ -231,6 +231,9 @@ class ContentViewCoreImpl : public ContentViewCore,
// determine if the embedder intends to handle it.
bool WillHandleDeferAfterResponseStarted();
+ // This method is invoked when a navigation transition has started.
+ void DidStartNavigationTransitionForFrame(int64 frame_id);
+
void OnSmartClipDataExtracted(const base::string16& text,
const base::string16& html,
const gfx::Rect& clip_rect);
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index d03a550..119c112 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -2801,7 +2801,7 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
// We create pending entries for renderer-initiated navigations so that we
// can show them in new tabs when it is safe.
- navigator->DidStartProvisionalLoad(main_test_rfh(), url1);
+ navigator->DidStartProvisionalLoad(main_test_rfh(), url1, false);
// Simulate what happens if a BrowserURLHandler rewrites the URL, causing
// the virtual URL to differ from the URL.
@@ -2815,7 +2815,7 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
is_renderer_initiated());
// If the user clicks another link, we should replace the pending entry.
- navigator->DidStartProvisionalLoad(main_test_rfh(), url2);
+ navigator->DidStartProvisionalLoad(main_test_rfh(), url2, false);
EXPECT_EQ(url2, controller.GetPendingEntry()->GetURL());
EXPECT_EQ(url2, controller.GetPendingEntry()->GetVirtualURL());
@@ -2825,18 +2825,18 @@ TEST_F(NavigationControllerTest, RendererInitiatedPendingEntries) {
EXPECT_EQ(url2, controller.GetLastCommittedEntry()->GetVirtualURL());
// We should not replace the pending entry for an error URL.
- navigator->DidStartProvisionalLoad(main_test_rfh(), url1);
+ navigator->DidStartProvisionalLoad(main_test_rfh(), url1, false);
EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL());
navigator->DidStartProvisionalLoad(main_test_rfh(),
- GURL(kUnreachableWebDataURL));
+ GURL(kUnreachableWebDataURL), false);
EXPECT_EQ(url1, controller.GetPendingEntry()->GetURL());
// We should remember if the pending entry will replace the current one.
// http://crbug.com/308444.
- navigator->DidStartProvisionalLoad(main_test_rfh(), url1);
+ navigator->DidStartProvisionalLoad(main_test_rfh(), url1, false);
NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())->
set_should_replace_entry(true);
- navigator->DidStartProvisionalLoad(main_test_rfh(), url2);
+ navigator->DidStartProvisionalLoad(main_test_rfh(), url2, false);
EXPECT_TRUE(
NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())->
should_replace_entry());
diff --git a/content/browser/frame_host/navigator.h b/content/browser/frame_host/navigator.h
index 595329d..39345f4 100644
--- a/content/browser/frame_host/navigator.h
+++ b/content/browser/frame_host/navigator.h
@@ -42,7 +42,8 @@ class CONTENT_EXPORT Navigator : public base::RefCounted<Navigator> {
// The RenderFrameHostImpl started a provisional load.
virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
- const GURL& url) {};
+ const GURL& url,
+ bool is_transition_navigation) {};
// The RenderFrameHostImpl has failed a provisional load.
virtual void DidFailProvisionalLoadWithError(
diff --git a/content/browser/frame_host/navigator_delegate.h b/content/browser/frame_host/navigator_delegate.h
index 56f10d7..718c3b8 100644
--- a/content/browser/frame_host/navigator_delegate.h
+++ b/content/browser/frame_host/navigator_delegate.h
@@ -33,6 +33,10 @@ class CONTENT_EXPORT NavigatorDelegate {
bool is_error_page,
bool is_iframe_srcdoc) {}
+ // The |render_frame_host| started a transition-flagged navigation.
+ virtual void DidStartNavigationTransition(
+ RenderFrameHostImpl* render_frame_host) {}
+
// A provisional load in |render_frame_host| failed.
virtual void DidFailProvisionalLoadWithError(
RenderFrameHostImpl* render_frame_host,
diff --git a/content/browser/frame_host/navigator_impl.cc b/content/browser/frame_host/navigator_impl.cc
index 82ea518..020404f 100644
--- a/content/browser/frame_host/navigator_impl.cc
+++ b/content/browser/frame_host/navigator_impl.cc
@@ -149,7 +149,8 @@ NavigationController* NavigatorImpl::GetController() {
void NavigatorImpl::DidStartProvisionalLoad(
RenderFrameHostImpl* render_frame_host,
- const GURL& url) {
+ const GURL& url,
+ bool is_transition_navigation) {
bool is_error_page = (url.spec() == kUnreachableWebDataURL);
bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL);
GURL validated_url(url);
@@ -190,6 +191,9 @@ void NavigatorImpl::DidStartProvisionalLoad(
if (delegate_)
delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL);
}
+
+ if (delegate_ && is_transition_navigation)
+ delegate_->DidStartNavigationTransition(render_frame_host);
}
if (delegate_) {
diff --git a/content/browser/frame_host/navigator_impl.h b/content/browser/frame_host/navigator_impl.h
index ceb22e2..4b66876 100644
--- a/content/browser/frame_host/navigator_impl.h
+++ b/content/browser/frame_host/navigator_impl.h
@@ -26,7 +26,8 @@ class CONTENT_EXPORT NavigatorImpl : public Navigator {
// Navigator implementation.
virtual NavigationController* GetController() OVERRIDE;
virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
- const GURL& url) OVERRIDE;
+ const GURL& url,
+ bool is_transition_navigation) OVERRIDE;
virtual void DidFailProvisionalLoadWithError(
RenderFrameHostImpl* render_frame_host,
const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index b483c33..eb459ed 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -504,8 +504,10 @@ void RenderFrameHostImpl::OnDocumentOnLoadCompleted() {
}
void RenderFrameHostImpl::OnDidStartProvisionalLoadForFrame(
- const GURL& url) {
- frame_tree_node_->navigator()->DidStartProvisionalLoad(this, url);
+ const GURL& url,
+ bool is_transition_navigation) {
+ frame_tree_node_->navigator()->DidStartProvisionalLoad(
+ this, url, is_transition_navigation);
}
void RenderFrameHostImpl::OnDidFailProvisionalLoadWithError(
diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h
index c90c775..1b1095d 100644
--- a/content/browser/frame_host/render_frame_host_impl.h
+++ b/content/browser/frame_host/render_frame_host_impl.h
@@ -268,7 +268,8 @@ class CONTENT_EXPORT RenderFrameHostImpl
void OnFrameFocused();
void OnOpenURL(const FrameHostMsg_OpenURL_Params& params);
void OnDocumentOnLoadCompleted();
- void OnDidStartProvisionalLoadForFrame(const GURL& url);
+ void OnDidStartProvisionalLoadForFrame(const GURL& url,
+ bool is_transition_navigation);
void OnDidFailProvisionalLoadWithError(
const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params);
void OnDidFailLoadWithError(
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index b7634a4..a0bf9b3 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2432,6 +2432,15 @@ void WebContentsImpl::DidStartProvisionalLoad(
}
}
+void WebContentsImpl::DidStartNavigationTransition(
+ RenderFrameHostImpl* render_frame_host) {
+#if defined(OS_ANDROID)
+ int render_frame_id = render_frame_host->GetRoutingID();
+ ContentViewCoreImpl::FromWebContents(this)->
+ DidStartNavigationTransitionForFrame(render_frame_id);
+#endif
+}
+
void WebContentsImpl::DidFailProvisionalLoadWithError(
RenderFrameHostImpl* render_frame_host,
const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
index a8455ef..fd69e98 100644
--- a/content/browser/web_contents/web_contents_impl.h
+++ b/content/browser/web_contents/web_contents_impl.h
@@ -479,6 +479,8 @@ class CONTENT_EXPORT WebContentsImpl
const GURL& validated_url,
bool is_error_page,
bool is_iframe_srcdoc) OVERRIDE;
+ virtual void DidStartNavigationTransition(
+ RenderFrameHostImpl* render_frame_host) OVERRIDE;
virtual void DidFailProvisionalLoadWithError(
RenderFrameHostImpl* render_frame_host,
const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
diff --git a/content/common/frame_messages.h b/content/common/frame_messages.h
index 6e53ded..a28b7dd 100644
--- a/content/common/frame_messages.h
+++ b/content/common/frame_messages.h
@@ -438,8 +438,12 @@ IPC_MESSAGE_ROUTED0(FrameHostMsg_Detach)
IPC_MESSAGE_ROUTED0(FrameHostMsg_FrameFocused)
// Sent when the renderer starts a provisional load for a frame.
-IPC_MESSAGE_ROUTED1(FrameHostMsg_DidStartProvisionalLoadForFrame,
- GURL /* url */)
+// |is_transition_navigation| signals that the frame has defined transition
+// elements which can be animated by the navigation destination to provide
+// a transition effect during load.
+IPC_MESSAGE_ROUTED2(FrameHostMsg_DidStartProvisionalLoadForFrame,
+ GURL /* url */,
+ bool /* is_transition_navigation */)
// Sent when the renderer fails a provisional load with an error.
IPC_MESSAGE_ROUTED1(FrameHostMsg_DidFailProvisionalLoadWithError,
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 655be6a..34844c6 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -248,6 +248,12 @@ public class ContentViewCore
* started.
*/
public void addEnteringStylesheetToTransition(String stylesheet);
+
+ /**
+ * Notifies that a navigation transition is started for a given frame.
+ * @param frameId A positive, non-zero integer identifying the navigating frame.
+ */
+ public void didStartNavigationTransitionForFrame(long frameId);
}
private final Context mContext;
@@ -3057,6 +3063,13 @@ public class ContentViewCore
}
@CalledByNative
+ public void didStartNavigationTransitionForFrame(long frameId) {
+ if (mNavigationTransitionDelegate != null ) {
+ mNavigationTransitionDelegate.didStartNavigationTransitionForFrame(frameId);
+ }
+ }
+
+ @CalledByNative
private boolean willHandleDeferAfterResponseStarted() {
if (mNavigationTransitionDelegate == null) return false;
return mNavigationTransitionDelegate.willHandleDeferAfterResponseStarted();
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/TransitionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/TransitionTest.java
index 384d1b1..55afbbe 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/TransitionTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/TransitionTest.java
@@ -60,6 +60,10 @@ public class TransitionTest extends ContentShellTestBase {
mTransitionStylesheets.add(stylesheet);
}
+ @Override
+ public void didStartNavigationTransitionForFrame(long frameId) {
+ }
+
public boolean getDidCallDefer() {
return mDidCallDefer;
}
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index d547262..9b67655 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -1720,15 +1720,9 @@ void RenderFrameImpl::loadURLExternally(
}
blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
- blink::WebLocalFrame* frame,
- blink::WebDataSource::ExtraData* extra_data,
- const blink::WebURLRequest& request,
- blink::WebNavigationType type,
- blink::WebNavigationPolicy default_policy,
- bool is_redirect) {
- DCHECK(!frame_ || frame_ == frame);
- return DecidePolicyForNavigation(
- this, frame, extra_data, request, type, default_policy, is_redirect);
+ const NavigationPolicyInfo& info) {
+ DCHECK(!frame_ || frame_ == info.frame);
+ return DecidePolicyForNavigation(this, info);
}
blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame(
@@ -1789,7 +1783,8 @@ void RenderFrameImpl::didCreateDataSource(blink::WebLocalFrame* frame,
network_provider.Pass());
}
-void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame) {
+void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame,
+ bool is_transition_navigation) {
DCHECK(!frame_ || frame_ == frame);
WebDataSource* ds = frame->provisionalDataSource();
@@ -1833,8 +1828,8 @@ void RenderFrameImpl::didStartProvisionalLoad(blink::WebLocalFrame* frame) {
DidStartProvisionalLoad(frame));
FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
- Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(routing_id_,
- ds->request().url()));
+ Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
+ routing_id_, ds->request().url(), is_transition_navigation));
}
void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
@@ -3209,33 +3204,29 @@ void RenderFrameImpl::FocusedNodeChanged(const WebNode& node) {
WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
RenderFrame* render_frame,
- WebFrame* frame,
- WebDataSource::ExtraData* extraData,
- const WebURLRequest& request,
- WebNavigationType type,
- WebNavigationPolicy default_policy,
- bool is_redirect) {
+ const NavigationPolicyInfo& info) {
#ifdef OS_ANDROID
// The handlenavigation API is deprecated and will be removed once
// crbug.com/325351 is resolved.
- if (request.url() != GURL(kSwappedOutURL) &&
+ if (info.urlRequest.url() != GURL(kSwappedOutURL) &&
GetContentClient()->renderer()->HandleNavigation(
render_frame,
- static_cast<DocumentState*>(extraData),
+ static_cast<DocumentState*>(info.extraData),
render_view_->opener_id_,
- frame,
- request,
- type,
- default_policy,
- is_redirect)) {
+ info.frame,
+ info.urlRequest,
+ info.navigationType,
+ info.defaultPolicy,
+ info.isRedirect)) {
return blink::WebNavigationPolicyIgnore;
}
#endif
- Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
+ Referrer referrer(RenderViewImpl::GetReferrerFromRequest(info.frame,
+ info.urlRequest));
if (is_swapped_out_ || render_view_->is_swapped_out()) {
- if (request.url() != GURL(kSwappedOutURL)) {
+ if (info.urlRequest.url() != GURL(kSwappedOutURL)) {
// Targeted links may try to navigate a swapped out frame. Allow the
// browser process to navigate the tab instead. Note that it is also
// possible for non-targeted navigations (from this view) to arrive
@@ -3243,8 +3234,9 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
// browser, as long as they're for the top level frame.
// TODO(creis): Ensure this supports targeted form submissions when
// fixing http://crbug.com/101395.
- if (frame->parent() == NULL) {
- OpenURL(frame, request.url(), referrer, default_policy);
+ if (info.frame->parent() == NULL) {
+ OpenURL(info.frame, info.urlRequest.url(), referrer,
+ info.defaultPolicy);
return blink::WebNavigationPolicyIgnore; // Suppress the load here.
}
@@ -3254,17 +3246,17 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
}
// Allow kSwappedOutURL to complete.
- return default_policy;
+ return info.defaultPolicy;
}
// Webkit is asking whether to navigate to a new URL.
// This is fine normally, except if we're showing UI from one security
// context and they're trying to navigate to a different context.
- const GURL& url = request.url();
+ const GURL& url = info.urlRequest.url();
// A content initiated navigation may have originated from a link-click,
// script, drag-n-drop operation, etc.
- bool is_content_initiated = static_cast<DocumentState*>(extraData)->
+ bool is_content_initiated = static_cast<DocumentState*>(info.extraData)->
navigation_state()->is_content_initiated();
// Experimental:
@@ -3277,8 +3269,8 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
command_line.HasSwitch(switches::kSitePerProcess);
if (force_swap_due_to_flag &&
- !frame->parent() && (is_content_initiated || is_redirect)) {
- WebString origin_str = frame->document().securityOrigin().toString();
+ !info.frame->parent() && (is_content_initiated || info.isRedirect)) {
+ WebString origin_str = info.frame->document().securityOrigin().toString();
GURL frame_url(origin_str.utf8().data());
// TODO(cevans): revisit whether this site check is still necessary once
// crbug.com/101395 is fixed.
@@ -3288,22 +3280,24 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
url,
net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
if (!same_domain_or_host || frame_url.scheme() != url.scheme()) {
- OpenURL(frame, url, referrer, default_policy);
+ OpenURL(info.frame, url, referrer, info.defaultPolicy);
return blink::WebNavigationPolicyIgnore;
}
}
// If the browser is interested, then give it a chance to look at the request.
if (is_content_initiated) {
- bool is_form_post = ((type == blink::WebNavigationTypeFormSubmitted) ||
- (type == blink::WebNavigationTypeFormResubmitted)) &&
- EqualsASCII(request.httpMethod(), "POST");
+ bool is_form_post =
+ ((info.navigationType == blink::WebNavigationTypeFormSubmitted) ||
+ (info.navigationType == blink::WebNavigationTypeFormResubmitted)) &&
+ EqualsASCII(info.urlRequest.httpMethod(), "POST");
bool browser_handles_request =
render_view_->renderer_preferences_
.browser_handles_non_local_top_level_requests
- && IsNonLocalTopLevelNavigation(url, frame, type, is_form_post);
+ && IsNonLocalTopLevelNavigation(url, info.frame, info.navigationType,
+ is_form_post);
if (!browser_handles_request) {
- browser_handles_request = IsTopLevelNavigation(frame) &&
+ browser_handles_request = IsTopLevelNavigation(info.frame) &&
render_view_->renderer_preferences_
.browser_handles_all_top_level_requests;
}
@@ -3313,7 +3307,7 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
// navigation.
render_view_->page_id_ = -1;
render_view_->last_page_id_sent_to_browser_ = -1;
- OpenURL(frame, url, referrer, default_policy);
+ OpenURL(info.frame, url, referrer, info.defaultPolicy);
return blink::WebNavigationPolicyIgnore; // Suppress the load here.
}
}
@@ -3322,7 +3316,7 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
// subsequent checks. For a popup, the document's URL may become the opener
// window's URL if the opener has called document.write().
// See http://crbug.com/93517.
- GURL old_url(frame->dataSource()->request().url());
+ GURL old_url(info.frame->dataSource()->request().url());
// Detect when we're crossing a permission-based boundary (e.g. into or out of
// an extension or app origin, leaving a WebUI page, etc). We only care about
@@ -3337,7 +3331,7 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
// browser process, and issue a special POST navigation in WebKit (via
// FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl
// for examples of how to send the httpBody data.
- if (!frame->parent() && is_content_initiated &&
+ if (!info.frame->parent() && is_content_initiated &&
!url.SchemeIs(url::kAboutScheme)) {
bool send_referrer = false;
@@ -3355,15 +3349,16 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) ||
(cumulative_bindings & BINDINGS_POLICY_WEB_UI) ||
url.SchemeIs(kViewSourceScheme) ||
- (frame->isViewSourceModeEnabled() &&
- type != blink::WebNavigationTypeReload);
+ (info.frame->isViewSourceModeEnabled() &&
+ info.navigationType != blink::WebNavigationTypeReload);
if (!should_fork && url.SchemeIs(url::kFileScheme)) {
// Fork non-file to file opens. Check the opener URL if this is the
// initial navigation in a newly opened window.
GURL source_url(old_url);
- if (is_initial_navigation && source_url.is_empty() && frame->opener())
- source_url = frame->opener()->top()->document().url();
+ if (is_initial_navigation && source_url.is_empty() &&
+ info.frame->opener())
+ source_url = info.frame->opener()->top()->document().url();
DCHECK(!source_url.is_empty());
should_fork = !source_url.SchemeIs(url::kFileScheme);
}
@@ -3371,13 +3366,13 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
if (!should_fork) {
// Give the embedder a chance.
should_fork = GetContentClient()->renderer()->ShouldFork(
- frame, url, request.httpMethod().utf8(), is_initial_navigation,
- is_redirect, &send_referrer);
+ info.frame, url, info.urlRequest.httpMethod().utf8(),
+ is_initial_navigation, info.isRedirect, &send_referrer);
}
if (should_fork) {
- OpenURL(
- frame, url, send_referrer ? referrer : Referrer(), default_policy);
+ OpenURL(info.frame, url, send_referrer ? referrer : Referrer(),
+ info.defaultPolicy);
return blink::WebNavigationPolicyIgnore; // Suppress the load here.
}
}
@@ -3404,23 +3399,23 @@ WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
render_view_->historyForwardListCount() < 1 &&
// The parent page must have set the child's window.opener to null before
// redirecting to the desired URL.
- frame->opener() == NULL &&
+ info.frame->opener() == NULL &&
// Must be a top-level frame.
- frame->parent() == NULL &&
+ info.frame->parent() == NULL &&
// Must not have issued the request from this page.
is_content_initiated &&
// Must be targeted at the current tab.
- default_policy == blink::WebNavigationPolicyCurrentTab &&
+ info.defaultPolicy == blink::WebNavigationPolicyCurrentTab &&
// Must be a JavaScript navigation, which appears as "other".
- type == blink::WebNavigationTypeOther;
+ info.navigationType == blink::WebNavigationTypeOther;
if (is_fork) {
// Open the URL via the browser, not via WebKit.
- OpenURL(frame, url, Referrer(), default_policy);
+ OpenURL(info.frame, url, Referrer(), info.defaultPolicy);
return blink::WebNavigationPolicyIgnore;
}
- return default_policy;
+ return info.defaultPolicy;
}
void RenderFrameImpl::OpenURL(WebFrame* frame,
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h
index 554799d..10adcda 100644
--- a/content/renderer/render_frame_impl.h
+++ b/content/renderer/render_frame_impl.h
@@ -298,12 +298,7 @@ class CONTENT_EXPORT RenderFrameImpl
const blink::WebString& suggested_name);
// The WebDataSource::ExtraData* is assumed to be a DocumentState* subclass.
virtual blink::WebNavigationPolicy decidePolicyForNavigation(
- blink::WebLocalFrame* frame,
- blink::WebDataSource::ExtraData* extra_data,
- const blink::WebURLRequest& request,
- blink::WebNavigationType type,
- blink::WebNavigationPolicy default_policy,
- bool is_redirect);
+ const NavigationPolicyInfo& info);
virtual blink::WebHistoryItem historyItemForNewChildFrame(
blink::WebFrame* frame);
virtual void willSendSubmitEvent(blink::WebLocalFrame* frame,
@@ -312,7 +307,8 @@ class CONTENT_EXPORT RenderFrameImpl
const blink::WebFormElement& form);
virtual void didCreateDataSource(blink::WebLocalFrame* frame,
blink::WebDataSource* datasource);
- virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame);
+ virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame,
+ bool is_transition_navigation);
virtual void didReceiveServerRedirectForProvisionalLoad(
blink::WebLocalFrame* frame);
virtual void didFailProvisionalLoad(
@@ -511,12 +507,7 @@ class CONTENT_EXPORT RenderFrameImpl
// Virtual since overridden by WebTestProxy for layout tests.
virtual blink::WebNavigationPolicy DecidePolicyForNavigation(
RenderFrame* render_frame,
- blink::WebFrame* frame,
- blink::WebDataSource::ExtraData* extraData,
- const blink::WebURLRequest& request,
- blink::WebNavigationType type,
- blink::WebNavigationPolicy default_policy,
- bool is_redirect);
+ const NavigationPolicyInfo& info);
void OpenURL(blink::WebFrame* frame,
const GURL& url,
const Referrer& referrer,
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index 3811cd6..7b57cf7 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -366,36 +366,34 @@ TEST_F(RenderViewImplTest, DecideNavigationPolicy) {
// Navigations to normal HTTP URLs can be handled locally.
blink::WebURLRequest request(GURL("http://foo.com"));
+ blink::WebFrameClient::NavigationPolicyInfo policy_info(request);
+ policy_info.frame = GetMainFrame();
+ policy_info.extraData = &state;
+ policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy_info);
EXPECT_EQ(blink::WebNavigationPolicyCurrentTab, policy);
// Verify that form posts to WebUI URLs will be sent to the browser process.
blink::WebURLRequest form_request(GURL("chrome://foo"));
+ blink::WebFrameClient::NavigationPolicyInfo form_policy_info(form_request);
+ form_policy_info.frame = GetMainFrame();
+ form_policy_info.extraData = &state;
+ form_policy_info.navigationType = blink::WebNavigationTypeFormSubmitted;
+ form_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
form_request.setHTTPMethod("POST");
- policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- form_request,
- blink::WebNavigationTypeFormSubmitted,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy = frame()->decidePolicyForNavigation(form_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Verify that popup links to WebUI URLs also are sent to browser.
blink::WebURLRequest popup_request(GURL("chrome://foo"));
- policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- popup_request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyNewForegroundTab,
- false);
+ blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request);
+ popup_policy_info.frame = GetMainFrame();
+ popup_policy_info.extraData = &state;
+ popup_policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab;
+ policy = frame()->decidePolicyForNavigation(popup_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
}
@@ -417,14 +415,16 @@ TEST_F(RenderViewImplTest, DecideNavigationPolicyHandlesAllTopLevel) {
};
blink::WebURLRequest request(GURL("http://foo.com"));
+ blink::WebFrameClient::NavigationPolicyInfo policy_info(request);
+ policy_info.frame = GetMainFrame();
+ policy_info.extraData = &state;
+ policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
+
for (size_t i = 0; i < arraysize(kNavTypes); ++i) {
+ policy_info.navigationType = kNavTypes[i];
+
blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- request,
- kNavTypes[i],
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
}
}
@@ -438,36 +438,35 @@ TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) {
// Navigations to normal HTTP URLs will be sent to browser process.
blink::WebURLRequest request(GURL("http://foo.com"));
+ blink::WebFrameClient::NavigationPolicyInfo policy_info(request);
+ policy_info.frame = GetMainFrame();
+ policy_info.extraData = &state;
+ policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
+
blink::WebNavigationPolicy policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Navigations to WebUI URLs will also be sent to browser process.
blink::WebURLRequest webui_request(GURL("chrome://foo"));
- policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- webui_request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ blink::WebFrameClient::NavigationPolicyInfo webui_policy_info(webui_request);
+ webui_policy_info.frame = GetMainFrame();
+ webui_policy_info.extraData = &state;
+ webui_policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ webui_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
+ policy = frame()->decidePolicyForNavigation(webui_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Verify that form posts to data URLs will be sent to the browser process.
blink::WebURLRequest data_request(GURL("data:text/html,foo"));
+ blink::WebFrameClient::NavigationPolicyInfo data_policy_info(data_request);
+ data_policy_info.frame = GetMainFrame();
+ data_policy_info.extraData = &state;
+ data_policy_info.navigationType = blink::WebNavigationTypeFormSubmitted;
+ data_policy_info.defaultPolicy = blink::WebNavigationPolicyCurrentTab;
data_request.setHTTPMethod("POST");
- policy = frame()->decidePolicyForNavigation(
- GetMainFrame(),
- &state,
- data_request,
- blink::WebNavigationTypeFormSubmitted,
- blink::WebNavigationPolicyCurrentTab,
- false);
+ policy = frame()->decidePolicyForNavigation(data_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Verify that a popup that creates a view first and then navigates to a
@@ -478,14 +477,13 @@ TEST_F(RenderViewImplTest, DecideNavigationPolicyForWebUI) {
GetMainFrame(), popup_request, blink::WebWindowFeatures(), "foo",
blink::WebNavigationPolicyNewForegroundTab, false);
RenderViewImpl* new_view = RenderViewImpl::FromWebView(new_web_view);
+ blink::WebFrameClient::NavigationPolicyInfo popup_policy_info(popup_request);
+ popup_policy_info.frame = new_web_view->mainFrame()->toWebLocalFrame();
+ popup_policy_info.extraData = &state;
+ popup_policy_info.navigationType = blink::WebNavigationTypeLinkClicked;
+ popup_policy_info.defaultPolicy = blink::WebNavigationPolicyNewForegroundTab;
policy = static_cast<RenderFrameImpl*>(new_view->GetMainRenderFrame())->
- decidePolicyForNavigation(
- new_web_view->mainFrame()->toWebLocalFrame(),
- &state,
- popup_request,
- blink::WebNavigationTypeLinkClicked,
- blink::WebNavigationPolicyNewForegroundTab,
- false);
+ decidePolicyForNavigation(popup_policy_info);
EXPECT_EQ(blink::WebNavigationPolicyIgnore, policy);
// Clean up after the new view so we don't leak it.
diff --git a/content/shell/renderer/test_runner/web_frame_test_proxy.h b/content/shell/renderer/test_runner/web_frame_test_proxy.h
index 9d355f2..a280199 100644
--- a/content/shell/renderer/test_runner/web_frame_test_proxy.h
+++ b/content/shell/renderer/test_runner/web_frame_test_proxy.h
@@ -66,9 +66,10 @@ class WebFrameTestProxy : public Base {
Base::loadURLExternally(frame, request, policy, suggested_name);
}
- virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame) {
+ virtual void didStartProvisionalLoad(blink::WebLocalFrame* frame,
+ bool isTransitionNavigation) {
base_proxy_->DidStartProvisionalLoad(frame);
- Base::didStartProvisionalLoad(frame);
+ Base::didStartProvisionalLoad(frame, isTransitionNavigation);
}
virtual void didReceiveServerRedirectForProvisionalLoad(
@@ -244,19 +245,13 @@ class WebFrameTestProxy : public Base {
}
virtual blink::WebNavigationPolicy decidePolicyForNavigation(
- blink::WebLocalFrame* frame,
- blink::WebDataSource::ExtraData* extra_data,
- const blink::WebURLRequest& request,
- blink::WebNavigationType type,
- blink::WebNavigationPolicy default_policy,
- bool is_redirect) {
+ const blink::WebFrameClient::NavigationPolicyInfo& info) {
blink::WebNavigationPolicy policy = base_proxy_->DecidePolicyForNavigation(
- frame, extra_data, request, type, default_policy, is_redirect);
+ info);
if (policy == blink::WebNavigationPolicyIgnore)
return policy;
- return Base::decidePolicyForNavigation(
- frame, extra_data, request, type, default_policy, is_redirect);
+ return Base::decidePolicyForNavigation(info);
}
virtual void willStartUsingPeerConnectionHandler(
diff --git a/content/shell/renderer/test_runner/web_test_proxy.cc b/content/shell/renderer/test_runner/web_test_proxy.cc
index 989502b..3b6cf1b 100644
--- a/content/shell/renderer/test_runner/web_test_proxy.cc
+++ b/content/shell/renderer/test_runner/web_test_proxy.cc
@@ -1198,20 +1198,15 @@ void WebTestProxyBase::LocationChangeDone(blink::WebFrame* frame) {
}
blink::WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation(
- blink::WebLocalFrame* frame,
- blink::WebDataSource::ExtraData* data,
- const blink::WebURLRequest& request,
- blink::WebNavigationType type,
- blink::WebNavigationPolicy default_policy,
- bool is_redirect) {
+ const blink::WebFrameClient::NavigationPolicyInfo& info) {
blink::WebNavigationPolicy result;
if (!test_interfaces_->testRunner()->policyDelegateEnabled())
- return default_policy;
+ return info.defaultPolicy;
delegate_->printMessage(std::string("Policy delegate: attempt to load ") +
- URLDescription(request.url()) +
+ URLDescription(info.urlRequest.url()) +
" with navigation type '" +
- WebNavigationTypeToString(type) + "'\n");
+ WebNavigationTypeToString(info.navigationType) + "'\n");
if (test_interfaces_->testRunner()->policyDelegateIsPermissive())
result = blink::WebNavigationPolicyCurrentTab;
else
diff --git a/content/shell/renderer/test_runner/web_test_proxy.h b/content/shell/renderer/test_runner/web_test_proxy.h
index 7a1c6d4..2ead703 100644
--- a/content/shell/renderer/test_runner/web_test_proxy.h
+++ b/content/shell/renderer/test_runner/web_test_proxy.h
@@ -23,6 +23,7 @@
#include "third_party/WebKit/public/web/WebDataSource.h"
#include "third_party/WebKit/public/web/WebDragOperation.h"
#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebFrameClient.h"
#include "third_party/WebKit/public/web/WebHistoryCommitType.h"
#include "third_party/WebKit/public/web/WebIconURL.h"
#include "third_party/WebKit/public/web/WebNavigationPolicy.h"
@@ -230,12 +231,7 @@ class WebTestProxyBase : public blink::WebCompositeAndReadbackAsyncCallback {
int intra_priority_value);
void DidFinishResourceLoad(blink::WebLocalFrame* frame, unsigned identifier);
blink::WebNavigationPolicy DecidePolicyForNavigation(
- blink::WebLocalFrame* frame,
- blink::WebDataSource::ExtraData* data,
- const blink::WebURLRequest& request,
- blink::WebNavigationType navigation_type,
- blink::WebNavigationPolicy default_policy,
- bool is_redirect);
+ const blink::WebFrameClient::NavigationPolicyInfo& info);
bool WillCheckAndDispatchMessageEvent(blink::WebLocalFrame* source_frame,
blink::WebFrame* target_frame,
blink::WebSecurityOrigin target,
diff --git a/content/test/test_render_frame_host.cc b/content/test/test_render_frame_host.cc
index 4af9084..f5c656f 100644
--- a/content/test/test_render_frame_host.cc
+++ b/content/test/test_render_frame_host.cc
@@ -80,7 +80,7 @@ void TestRenderFrameHost::SendNavigateWithTransitionAndResponseCode(
// DidStartProvisionalLoad may delete the pending entry that holds |url|,
// so we keep a copy of it to use in SendNavigateWithParameters.
GURL url_copy(url);
- OnDidStartProvisionalLoadForFrame(url_copy);
+ OnDidStartProvisionalLoadForFrame(url_copy, false);
SendNavigateWithParameters(page_id, url_copy, transition, url_copy,
response_code, 0, std::vector<GURL>());
}
@@ -89,7 +89,7 @@ void TestRenderFrameHost::SendNavigateWithOriginalRequestURL(
int page_id,
const GURL& url,
const GURL& original_request_url) {
- OnDidStartProvisionalLoadForFrame(url);
+ OnDidStartProvisionalLoadForFrame(url, false);
SendNavigateWithParameters(page_id, url, PAGE_TRANSITION_LINK,
original_request_url, 200, 0, std::vector<GURL>());
}