Navigation transitions: Added "addStyleSheetByURL" function to insert stylesheet links.

If transition-entering-stylesheet is defined in the response headers for the incoming document, they're parsed out, passed to the TransitionPageHelper in the embedder, and are applied to the page via addStyleSheetByUrl at the appropriate time in the transition. 

This is the chrome side of the CL, blink side here: https://codereview.chromium.org/285623003/ 

Design doc: https://docs.google.com/a/chromium.org/document/d/17jg1RRL3RI969cLwbKBIcoGDsPwqaEdBxafGNYGwiY4/edit# 
Implementation details: https://docs.google.com/a/chromium.org/document/d/1kREPtFJaeLoDKwrfmrYTD7DHCdxX1RzFBga2gNY8lyE/edit#heading=h.bng2kpmyvxq5 
BUG=370696

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278856 0039d316-1c4b-4281-b951-d872f2087c98
parent a93606e6
......@@ -1208,6 +1208,16 @@ void ContentViewCoreImpl::ClearHistory(JNIEnv* env, jobject obj) {
web_contents_->GetController().PruneAllButLastCommitted();
}
void ContentViewCoreImpl::AddStyleSheetByURL(
JNIEnv* env, jobject obj, jstring url) {
if (!web_contents_)
return;
web_contents_->GetMainFrame()->Send(new FrameMsg_AddStyleSheetByURL(
web_contents_->GetMainFrame()->GetRoutingID(),
ConvertJavaStringToUTF8(env, url)));
}
void ContentViewCoreImpl::SetAllowJavascriptInterfacesInspection(
JNIEnv* env,
jobject obj,
......
......@@ -161,6 +161,7 @@ class ContentViewCoreImpl : public ContentViewCore,
void ReloadIgnoringCache(JNIEnv* env, jobject obj, jboolean check_for_repost);
void CancelPendingReload(JNIEnv* env, jobject obj);
void ContinuePendingReload(JNIEnv* env, jobject obj);
void AddStyleSheetByURL(JNIEnv* env, jobject obj, jstring url);
void ClearHistory(JNIEnv* env, jobject obj);
void EvaluateJavaScript(JNIEnv* env,
jobject obj,
......
......@@ -363,6 +363,10 @@ IPC_MESSAGE_ROUTED0(FrameMsg_DeleteProxy)
IPC_MESSAGE_ROUTED1(FrameMsg_TextSurroundingSelectionRequest,
size_t /* max_length */)
// Tells the renderer to insert a link to the specified stylesheet. This is
// needed to support navigation transitions.
IPC_MESSAGE_ROUTED1(FrameMsg_AddStyleSheetByURL, std::string)
// -----------------------------------------------------------------------------
// Messages sent from the renderer to the browser.
......
......@@ -1295,6 +1295,14 @@ public class ContentViewCore
}
}
/**
* Requests the renderer insert a link to the specified stylesheet in the
* main frame's document.
*/
void addStyleSheetByURL(String url) {
nativeAddStyleSheetByURL(mNativeContentViewCore, url);
}
/** Callback interface for evaluateJavaScript(). */
public interface JavaScriptCallback {
void handleJavaScriptResult(String jsonResult);
......@@ -3175,6 +3183,9 @@ public class ContentViewCore
private native void nativeClearHistory(long nativeContentViewCoreImpl);
private native void nativeAddStyleSheetByURL(long nativeContentViewCoreImpl,
String stylesheetUrl);
private native void nativeEvaluateJavaScript(long nativeContentViewCoreImpl,
String script, JavaScriptCallback callback, boolean startRenderer);
......
......@@ -710,6 +710,8 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(FrameMsg_Reload, OnReload)
IPC_MESSAGE_HANDLER(FrameMsg_TextSurroundingSelectionRequest,
OnTextSurroundingSelectionRequest)
IPC_MESSAGE_HANDLER(FrameMsg_AddStyleSheetByURL,
OnAddStyleSheetByURL)
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
#endif
......@@ -1177,6 +1179,10 @@ void RenderFrameImpl::OnTextSurroundingSelectionRequest(size_t max_length) {
surroundingText.endOffsetInTextContent()));
}
void RenderFrameImpl::OnAddStyleSheetByURL(const std::string& url) {
frame_->addStyleSheetByURL(WebString::fromUTF8(url));
}
bool RenderFrameImpl::ShouldUpdateSelectionTextFromContextMenuParams(
const base::string16& selection_text,
size_t selection_text_offset,
......
......@@ -458,6 +458,7 @@ class CONTENT_EXPORT RenderFrameImpl
void OnExtendSelectionAndDelete(int before, int after);
void OnReload(bool ignore_cache);
void OnTextSurroundingSelectionRequest(size_t max_length);
void OnAddStyleSheetByURL(const std::string& url);
#if defined(OS_MACOSX)
void OnCopyToFindPboard();
#endif
......
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