OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 return java_ref_.get(env); | 352 return java_ref_.get(env); |
353 } | 353 } |
354 | 354 |
355 jint ContentViewCoreImpl::GetBackgroundColor(JNIEnv* env, jobject obj) { | 355 jint ContentViewCoreImpl::GetBackgroundColor(JNIEnv* env, jobject obj) { |
356 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); | 356 RenderWidgetHostViewAndroid* rwhva = GetRenderWidgetHostViewAndroid(); |
357 if (!rwhva) | 357 if (!rwhva) |
358 return SK_ColorWHITE; | 358 return SK_ColorWHITE; |
359 return rwhva->GetCachedBackgroundColor(); | 359 return rwhva->GetCachedBackgroundColor(); |
360 } | 360 } |
361 | 361 |
362 void ContentViewCoreImpl::OnHide(JNIEnv* env, jobject obj) { | |
363 Hide(); | |
364 } | |
365 | |
366 void ContentViewCoreImpl::OnShow(JNIEnv* env, jobject obj) { | |
367 Show(); | |
368 } | |
369 | |
370 void ContentViewCoreImpl::Show() { | |
371 GetWebContents()->WasShown(); | |
372 } | |
373 | |
374 void ContentViewCoreImpl::Hide() { | |
375 GetWebContents()->WasHidden(); | |
376 PauseVideo(); | |
377 } | |
378 | |
379 void ContentViewCoreImpl::PauseVideo() { | 362 void ContentViewCoreImpl::PauseVideo() { |
380 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( | 363 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( |
381 web_contents_->GetRenderViewHost()); | 364 web_contents_->GetRenderViewHost()); |
382 if (rvhi) | 365 if (rvhi) |
383 rvhi->media_web_contents_observer()->PauseVideo(); | 366 rvhi->media_web_contents_observer()->PauseVideo(); |
384 } | 367 } |
385 | 368 |
386 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { | 369 void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { |
387 web_contents_->geolocation_dispatcher_host()->PauseOrResume(should_pause); | 370 web_contents_->geolocation_dispatcher_host()->PauseOrResume(should_pause); |
388 } | 371 } |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 if (rwhv) | 1164 if (rwhv) |
1182 rwhv->SetMultiTouchZoomSupportEnabled(enabled); | 1165 rwhv->SetMultiTouchZoomSupportEnabled(enabled); |
1183 } | 1166 } |
1184 | 1167 |
1185 void ContentViewCoreImpl::ClearHistory(JNIEnv* env, jobject obj) { | 1168 void ContentViewCoreImpl::ClearHistory(JNIEnv* env, jobject obj) { |
1186 // TODO(creis): Do callers of this need to know if it fails? | 1169 // TODO(creis): Do callers of this need to know if it fails? |
1187 if (web_contents_->GetController().CanPruneAllButLastCommitted()) | 1170 if (web_contents_->GetController().CanPruneAllButLastCommitted()) |
1188 web_contents_->GetController().PruneAllButLastCommitted(); | 1171 web_contents_->GetController().PruneAllButLastCommitted(); |
1189 } | 1172 } |
1190 | 1173 |
1191 void ContentViewCoreImpl::AddStyleSheetByURL( | |
1192 JNIEnv* env, jobject obj, jstring url) { | |
1193 if (!web_contents_) | |
1194 return; | |
1195 | |
1196 web_contents_->GetMainFrame()->Send(new FrameMsg_AddStyleSheetByURL( | |
1197 web_contents_->GetMainFrame()->GetRoutingID(), | |
1198 ConvertJavaStringToUTF8(env, url))); | |
1199 } | |
1200 | |
1201 void ContentViewCoreImpl::SetAllowJavascriptInterfacesInspection( | 1174 void ContentViewCoreImpl::SetAllowJavascriptInterfacesInspection( |
1202 JNIEnv* env, | 1175 JNIEnv* env, |
1203 jobject obj, | 1176 jobject obj, |
1204 jboolean allow) { | 1177 jboolean allow) { |
1205 java_bridge_dispatcher_host_->SetAllowObjectContentsInspection(allow); | 1178 java_bridge_dispatcher_host_->SetAllowObjectContentsInspection(allow); |
1206 } | 1179 } |
1207 | 1180 |
1208 void ContentViewCoreImpl::AddJavascriptInterface( | 1181 void ContentViewCoreImpl::AddJavascriptInterface( |
1209 JNIEnv* env, | 1182 JNIEnv* env, |
1210 jobject /* obj */, | 1183 jobject /* obj */, |
(...skipping 21 matching lines...) Expand all Loading... |
1232 root_layer_->SetBounds(physical_size); | 1205 root_layer_->SetBounds(physical_size); |
1233 | 1206 |
1234 if (view) { | 1207 if (view) { |
1235 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( | 1208 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( |
1236 view->GetRenderWidgetHost()); | 1209 view->GetRenderWidgetHost()); |
1237 host->SendScreenRects(); | 1210 host->SendScreenRects(); |
1238 view->WasResized(); | 1211 view->WasResized(); |
1239 } | 1212 } |
1240 } | 1213 } |
1241 | 1214 |
1242 void ContentViewCoreImpl::ShowInterstitialPage( | |
1243 JNIEnv* env, jobject obj, jstring jurl, jlong delegate_ptr) { | |
1244 GURL url(base::android::ConvertJavaStringToUTF8(env, jurl)); | |
1245 InterstitialPageDelegateAndroid* delegate = | |
1246 reinterpret_cast<InterstitialPageDelegateAndroid*>(delegate_ptr); | |
1247 InterstitialPage* interstitial = InterstitialPage::Create( | |
1248 web_contents_, false, url, delegate); | |
1249 delegate->set_interstitial_page(interstitial); | |
1250 interstitial->Show(); | |
1251 } | |
1252 | |
1253 jboolean ContentViewCoreImpl::IsShowingInterstitialPage(JNIEnv* env, | |
1254 jobject obj) { | |
1255 return web_contents_->ShowingInterstitialPage(); | |
1256 } | |
1257 | |
1258 jboolean ContentViewCoreImpl::IsRenderWidgetHostViewReady(JNIEnv* env, | |
1259 jobject obj) { | |
1260 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | |
1261 return view && view->HasValidFrame(); | |
1262 } | |
1263 | |
1264 void ContentViewCoreImpl::ExitFullscreen(JNIEnv* env, jobject obj) { | |
1265 RenderViewHost* host = web_contents_->GetRenderViewHost(); | |
1266 if (!host) | |
1267 return; | |
1268 host->ExitFullscreen(); | |
1269 } | |
1270 | |
1271 void ContentViewCoreImpl::UpdateTopControlsState(JNIEnv* env, | |
1272 jobject obj, | |
1273 bool enable_hiding, | |
1274 bool enable_showing, | |
1275 bool animate) { | |
1276 RenderViewHost* host = web_contents_->GetRenderViewHost(); | |
1277 if (!host) | |
1278 return; | |
1279 host->Send(new ViewMsg_UpdateTopControlsState(host->GetRoutingID(), | |
1280 enable_hiding, | |
1281 enable_showing, | |
1282 animate)); | |
1283 } | |
1284 | |
1285 void ContentViewCoreImpl::ShowImeIfNeeded(JNIEnv* env, jobject obj) { | |
1286 RenderViewHost* host = web_contents_->GetRenderViewHost(); | |
1287 host->Send(new ViewMsg_ShowImeIfNeeded(host->GetRoutingID())); | |
1288 } | |
1289 | |
1290 void ContentViewCoreImpl::ScrollFocusedEditableNodeIntoView(JNIEnv* env, | |
1291 jobject obj) { | |
1292 RenderViewHost* host = web_contents_->GetRenderViewHost(); | |
1293 host->Send(new InputMsg_ScrollFocusedEditableNodeIntoRect( | |
1294 host->GetRoutingID(), gfx::Rect())); | |
1295 } | |
1296 | |
1297 void ContentViewCoreImpl::SelectWordAroundCaret(JNIEnv* env, jobject obj) { | |
1298 RenderViewHost* host = web_contents_->GetRenderViewHost(); | |
1299 if (!host) | |
1300 return; | |
1301 host->SelectWordAroundCaret(); | |
1302 } | |
1303 | |
1304 namespace { | 1215 namespace { |
1305 | 1216 |
1306 static void AddNavigationEntryToHistory(JNIEnv* env, jobject obj, | 1217 static void AddNavigationEntryToHistory(JNIEnv* env, jobject obj, |
1307 jobject history, | 1218 jobject history, |
1308 NavigationEntry* entry, | 1219 NavigationEntry* entry, |
1309 int index) { | 1220 int index) { |
1310 // Get the details of the current entry | 1221 // Get the details of the current entry |
1311 ScopedJavaLocalRef<jstring> j_url( | 1222 ScopedJavaLocalRef<jstring> j_url( |
1312 ConvertUTF8ToJavaString(env, entry->GetURL().spec())); | 1223 ConvertUTF8ToJavaString(env, entry->GetURL().spec())); |
1313 ScopedJavaLocalRef<jstring> j_virtual_url( | 1224 ScopedJavaLocalRef<jstring> j_virtual_url( |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1681 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1592 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1682 retained_objects_set); | 1593 retained_objects_set); |
1683 return reinterpret_cast<intptr_t>(view); | 1594 return reinterpret_cast<intptr_t>(view); |
1684 } | 1595 } |
1685 | 1596 |
1686 bool RegisterContentViewCore(JNIEnv* env) { | 1597 bool RegisterContentViewCore(JNIEnv* env) { |
1687 return RegisterNativesImpl(env); | 1598 return RegisterNativesImpl(env); |
1688 } | 1599 } |
1689 | 1600 |
1690 } // namespace content | 1601 } // namespace content |
OLD | NEW |