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 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1416 ScopedJavaGlobalRef<jobject> j_callback; | 1416 ScopedJavaGlobalRef<jobject> j_callback; |
1417 j_callback.Reset(env, callback); | 1417 j_callback.Reset(env, callback); |
1418 content::RenderFrameHost::JavaScriptResultCallback c_callback = | 1418 content::RenderFrameHost::JavaScriptResultCallback c_callback = |
1419 base::Bind(&JavaScriptResultCallback, j_callback); | 1419 base::Bind(&JavaScriptResultCallback, j_callback); |
1420 | 1420 |
1421 web_contents_->GetMainFrame()->ExecuteJavaScript( | 1421 web_contents_->GetMainFrame()->ExecuteJavaScript( |
1422 ConvertJavaStringToUTF16(env, script), | 1422 ConvertJavaStringToUTF16(env, script), |
1423 c_callback); | 1423 c_callback); |
1424 } | 1424 } |
1425 | 1425 |
1426 // TODO(sgurun) add support for posting a frame whose name is known (only | |
1427 // main frame is supported at this time, see crbug.com/389721) | |
1428 // TODO(sgurun) add support for passing message ports | |
1429 void ContentViewCoreImpl::PostMessageToFrame(JNIEnv* env, jobject obj, | |
1430 jstring frame_name, jstring message, jstring source_origin, | |
1431 jstring target_origin) { | |
1432 | |
1433 RenderViewHost* host = web_contents_->GetRenderViewHost(); | |
1434 ViewMsg_PostMessage_Params params; | |
1435 params.source_origin = ConvertJavaStringToUTF16(env, source_origin); | |
1436 params.target_origin = ConvertJavaStringToUTF16(env, target_origin); | |
1437 params.data = ConvertJavaStringToUTF16(env, message); | |
1438 params.is_data_raw_string = true; | |
1439 // TODO(sgurun) What is the right value here? | |
1440 params.source_routing_id = MSG_ROUTING_NONE; | |
1441 if (host) | |
mnaganov (inactive)
2014/07/14 15:19:29
nit: bail out early if there is no host?
sgurun-gerrit only
2014/07/16 00:43:28
Done.
| |
1442 host->Send(new ViewMsg_PostMessageEvent(host->GetRoutingID(), params)); | |
1443 } | |
1444 | |
1445 | |
1426 bool ContentViewCoreImpl::GetUseDesktopUserAgent( | 1446 bool ContentViewCoreImpl::GetUseDesktopUserAgent( |
1427 JNIEnv* env, jobject obj) { | 1447 JNIEnv* env, jobject obj) { |
1428 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); | 1448 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |
1429 return entry && entry->GetIsOverridingUserAgent(); | 1449 return entry && entry->GetIsOverridingUserAgent(); |
1430 } | 1450 } |
1431 | 1451 |
1432 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter, | 1452 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter, |
1433 int text_input_type, | 1453 int text_input_type, |
1434 const std::string& text, | 1454 const std::string& text, |
1435 int selection_start, | 1455 int selection_start, |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1657 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1677 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1658 retained_objects_set); | 1678 retained_objects_set); |
1659 return reinterpret_cast<intptr_t>(view); | 1679 return reinterpret_cast<intptr_t>(view); |
1660 } | 1680 } |
1661 | 1681 |
1662 bool RegisterContentViewCore(JNIEnv* env) { | 1682 bool RegisterContentViewCore(JNIEnv* env) { |
1663 return RegisterNativesImpl(env); | 1683 return RegisterNativesImpl(env); |
1664 } | 1684 } |
1665 | 1685 |
1666 } // namespace content | 1686 } // namespace content |
OLD | NEW |