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

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: Fixed few nits and new line issues. 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/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/android/interstitial_page_delegate_android.h" 10 #include "content/browser/android/interstitial_page_delegate_android.h"
11 #include "content/browser/frame_host/interstitial_page_impl.h" 11 #include "content/browser/frame_host/interstitial_page_impl.h"
12 #include "content/browser/media/media_web_contents_observer.h" 12 #include "content/browser/media/media_web_contents_observer.h"
13 #include "content/browser/renderer_host/render_view_host_impl.h" 13 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/browser/transition_request_manager.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"
19 #include "jni/WebContentsImpl_jni.h" 22 #include "jni/WebContentsImpl_jni.h"
20 23
21 using base::android::AttachCurrentThread; 24 using base::android::AttachCurrentThread;
22 using base::android::ConvertJavaStringToUTF8; 25 using base::android::ConvertJavaStringToUTF8;
26 using base::android::ConvertUTF8ToJavaString;
23 27
24 namespace content { 28 namespace content {
25 29
26 // static 30 // static
27 WebContents* WebContents::FromJavaWebContents( 31 WebContents* WebContents::FromJavaWebContents(
28 jobject jweb_contents_android) { 32 jobject jweb_contents_android) {
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
30 if (!jweb_contents_android) 34 if (!jweb_contents_android)
31 return NULL; 35 return NULL;
32 36
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return static_cast<RenderWidgetHostViewAndroid*>(rwhv); 101 return static_cast<RenderWidgetHostViewAndroid*>(rwhv);
98 } 102 }
99 103
100 jint WebContentsAndroid::GetBackgroundColor(JNIEnv* env, jobject obj) { 104 jint WebContentsAndroid::GetBackgroundColor(JNIEnv* env, jobject obj) {
101 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); 105 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid();
102 if (!rwhva) 106 if (!rwhva)
103 return SK_ColorWHITE; 107 return SK_ColorWHITE;
104 return rwhva->GetCachedBackgroundColor(); 108 return rwhva->GetCachedBackgroundColor();
105 } 109 }
106 110
111 ScopedJavaLocalRef<jstring> WebContentsAndroid::GetURL(
112 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(
122 JNIEnv* env,
123 jobject obj) {
124 static_cast<WebContentsImpl*>(web_contents_)->
125 ResumeResponseDeferredAtStart();
126 }
127
128 void WebContentsAndroid::SetHasPendingNavigationTransitionForTesting(
129 JNIEnv* env,
130 jobject obj) {
131 RenderFrameHost* frame = static_cast<WebContentsImpl*>(web_contents_)->
132 GetMainFrame();
133 BrowserThread::PostTask(
134 BrowserThread::IO,
135 FROM_HERE,
136 base::Bind(
137 &TransitionRequestManager::SetHasPendingTransitionRequest,
138 base::Unretained(TransitionRequestManager::GetInstance()),
139 frame->GetProcess()->GetID(),
140 frame->GetRoutingID(),
141 true));
142 }
143
107 void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) { 144 void WebContentsAndroid::OnHide(JNIEnv* env, jobject obj) {
108 web_contents_->WasHidden(); 145 web_contents_->WasHidden();
109 PauseVideo(); 146 PauseVideo();
110 } 147 }
111 148
112 void WebContentsAndroid::OnShow(JNIEnv* env, jobject obj) { 149 void WebContentsAndroid::OnShow(JNIEnv* env, jobject obj) {
113 web_contents_->WasShown(); 150 web_contents_->WasShown();
114 } 151 }
115 152
116 void WebContentsAndroid::PauseVideo() { 153 void WebContentsAndroid::PauseVideo() {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 232 }
196 233
197 void WebContentsAndroid::SelectWordAroundCaret(JNIEnv* env, jobject obj) { 234 void WebContentsAndroid::SelectWordAroundCaret(JNIEnv* env, jobject obj) {
198 RenderViewHost* host = web_contents_->GetRenderViewHost(); 235 RenderViewHost* host = web_contents_->GetRenderViewHost();
199 if (!host) 236 if (!host)
200 return; 237 return;
201 host->SelectWordAroundCaret(); 238 host->SelectWordAroundCaret();
202 } 239 }
203 240
204 } // namespace content 241 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698