Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: content/browser/web_contents/web_contents_android.cc

Issue 414423002: Removing ContentViewCore dependencies from few functions which acts as direct wrapper to WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed setHasPendingNavigationTransitionForTesting from CVC. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_android.h" 5 #include "content/browser/web_contents/web_contents_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/command_line.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "content/browser/android/interstitial_page_delegate_android.h" 11 #include "content/browser/android/interstitial_page_delegate_android.h"
11 #include "content/browser/frame_host/interstitial_page_impl.h" 12 #include "content/browser/frame_host/interstitial_page_impl.h"
12 #include "content/browser/media/media_web_contents_observer.h" 13 #include "content/browser/media/media_web_contents_observer.h"
13 #include "content/browser/renderer_host/render_view_host_impl.h" 14 #include "content/browser/renderer_host/render_view_host_impl.h"
15 #include "content/browser/web_contents/web_contents_impl.h"
14 #include "content/common/frame_messages.h" 16 #include "content/common/frame_messages.h"
15 #include "content/common/input_messages.h" 17 #include "content/common/input_messages.h"
16 #include "content/common/view_messages.h" 18 #include "content/common/view_messages.h"
19 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/content_switches.h"
19 #include "jni/WebContentsImpl_jni.h" 23 #include "jni/WebContentsImpl_jni.h"
20 24
21 using base::android::AttachCurrentThread; 25 using base::android::AttachCurrentThread;
22 using base::android::ConvertJavaStringToUTF8; 26 using base::android::ConvertJavaStringToUTF8;
27 using base::android::ConvertUTF8ToJavaString;
23 28
24 namespace content { 29 namespace content {
25 30
26 // static 31 // static
27 WebContents* WebContents::FromJavaWebContents( 32 WebContents* WebContents::FromJavaWebContents(
28 jobject jweb_contents_android) { 33 jobject jweb_contents_android) {
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
30 if (!jweb_contents_android) 35 if (!jweb_contents_android)
31 return NULL; 36 return NULL;
32 37
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return static_cast<RenderWidgetHostViewAndroid*>(rwhv); 102 return static_cast<RenderWidgetHostViewAndroid*>(rwhv);
98 } 103 }
99 104
100 jint WebContentsAndroid::GetBackgroundColor(JNIEnv* env, jobject obj) { 105 jint WebContentsAndroid::GetBackgroundColor(JNIEnv* env, jobject obj) {
101 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); 106 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
102 if (!rwhva) 107 if (!rwhva)
103 return SK_ColorWHITE; 108 return SK_ColorWHITE;
104 return rwhva->GetCachedBackgroundColor(); 109 return rwhva->GetCachedBackgroundColor();
105 } 110 }
106 111
112 ScopedJavaLocalRef<jstring> WebContentsAndroid::GetURL(JNIEnv* env,
113 jobject obj) const {
114 return ConvertUTF8ToJavaString(env, web_contents_->GetURL().spec());
115 }
116
117 jboolean WebContentsAndroid::IsIncognito(JNIEnv* env, jobject obj) {
118 return web_contents_->GetBrowserContext()->IsOffTheRecord();
119 }
120
121 void WebContentsAndroid::ResumeResponseDeferredAtStart(JNIEnv* env,
122 jobject obj) {
123 static_cast<WebContentsImpl*>(web_contents_)->ResumeResponseDeferredAtStart();
124 }
125
126 void WebContentsAndroid::SetHasPendingNavigationTransitionForTesting(
127 JNIEnv* env,
128 jobject obj) {
129 CommandLine::ForCurrentProcess()->AppendSwitch(
130 switches::kEnableExperimentalWebPlatformFeatures);
131 RenderFrameHost* frame =
132 static_cast<WebContentsImpl*>(web_contents_)->GetMainFrame();
133 BrowserThread::PostTask(
134 BrowserThread::IO,
135 FROM_HERE,
136 base::Bind(&TransitionRequestManager::AddPendingTransitionRequestData,
137 base::Unretained(TransitionRequestManager::GetInstance()),
138 frame->GetProcess()->GetID(),
139 frame->GetRoutingID(),
140 "*",
141 "",
142 ""));
143 }
144
145 void WebContentsAndroid::SetupTransitionView(JNIEnv* env,
146 jobject jobj,
147 jstring markup) {
148 web_contents_->GetMainFrame()->Send(new FrameMsg_SetupTransitionView(
149 web_contents_->GetMainFrame()->GetRoutingID(),
150 ConvertJavaStringToUTF8(env, markup)));
151 }
152
153 void WebContentsAndroid::BeginExitTransition(JNIEnv* env,
154 jobject jobj,
155 jstring css_selector) {
156 web_contents_->GetMainFrame()->Send(new FrameMsg_BeginExitTransition(
157 web_contents_->GetMainFrame()->GetRoutingID(),
158 ConvertJavaStringToUTF8(env, css_selector)));
159 }
160
107 void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) { 161 void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) {
108 web_contents_->WasHidden(); 162 web_contents_->WasHidden();
109 PauseVideo(); 163 PauseVideo();
110 } 164 }
111 165
112 void WebContentsAndroid::OnShow(JNIEnv* env, jobject obj) { 166 void WebContentsAndroid::OnShow(JNIEnv* env, jobject obj) {
113 web_contents_->WasShown(); 167 web_contents_->WasShown();
114 } 168 }
115 169
116 void WebContentsAndroid::PauseVideo() { 170 void WebContentsAndroid::PauseVideo() {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 host->GetRoutingID(), gfx::Rect())); 248 host->GetRoutingID(), gfx::Rect()));
195 } 249 }
196 250
197 void WebContentsAndroid::SelectWordAroundCaret(JNIEnv* env, jobject obj) { 251 void WebContentsAndroid::SelectWordAroundCaret(JNIEnv* env, jobject obj) {
198 RenderViewHost* host = web_contents_->GetRenderViewHost(); 252 RenderViewHost* host = web_contents_->GetRenderViewHost();
199 if (!host) 253 if (!host)
200 return; 254 return;
201 host->SelectWordAroundCaret(); 255 host->SelectWordAroundCaret();
202 } 256 }
203 257
258 bool WebContentsAndroid::WillHandleDeferAfterResponseStarted() {
259 JNIEnv* env = AttachCurrentThread();
260 return Java_WebContentsImpl_willHandleDeferAfterResponseStarted(env,
261 obj_.obj());
262 }
263
264 void WebContentsAndroid::DidDeferAfterResponseStarted(
265 const TransitionLayerData& transition_data) {
266 JNIEnv* env = AttachCurrentThread();
267 std::vector<GURL> entering_stylesheets;
268 std::string transition_color;
269 if (transition_data.response_headers) {
270 TransitionRequestManager::ParseTransitionStylesheetsFromHeaders(
271 transition_data.response_headers,
272 entering_stylesheets,
273 transition_data.request_url);
274
275 transition_data.response_headers->EnumerateHeader(
276 NULL, "X-Transition-Entering-Color", &transition_color);
277 }
278
279 ScopedJavaLocalRef<jstring> jstring_markup(
280 ConvertUTF8ToJavaString(env, transition_data.markup));
281
282 ScopedJavaLocalRef<jstring> jstring_css_selector(
283 ConvertUTF8ToJavaString(env, transition_data.css_selector));
284
285 ScopedJavaLocalRef<jstring> jstring_transition_color(
286 ConvertUTF8ToJavaString(env, transition_color));
287
288 Java_WebContentsImpl_didDeferAfterResponseStarted(
289 env,
290 obj_.obj(),
291 jstring_markup.obj(),
292 jstring_css_selector.obj(),
293 jstring_transition_color.obj());
294
295 std::vector<GURL>::const_iterator iter = entering_stylesheets.begin();
296 for (; iter != entering_stylesheets.end(); ++iter) {
297 ScopedJavaLocalRef<jstring> jstring_url(
298 ConvertUTF8ToJavaString(env, iter->spec()));
299 Java_WebContentsImpl_addEnteringStylesheetToTransition(
300 env, obj_.obj(), jstring_url.obj());
301 }
302 }
303
304 void WebContentsAndroid::DidStartNavigationTransitionForFrame(int64 frame_id) {
305 JNIEnv* env = AttachCurrentThread();
306 Java_WebContentsImpl_didStartNavigationTransitionForFrame(
307 env, obj_.obj(), frame_id);
308 }
309
204 } // namespace content 310 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_android.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698