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 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1438 ScopedJavaGlobalRef<jobject> j_callback; | 1438 ScopedJavaGlobalRef<jobject> j_callback; |
1439 j_callback.Reset(env, callback); | 1439 j_callback.Reset(env, callback); |
1440 content::RenderFrameHost::JavaScriptResultCallback c_callback = | 1440 content::RenderFrameHost::JavaScriptResultCallback c_callback = |
1441 base::Bind(&JavaScriptResultCallback, j_callback); | 1441 base::Bind(&JavaScriptResultCallback, j_callback); |
1442 | 1442 |
1443 web_contents_->GetMainFrame()->ExecuteJavaScript( | 1443 web_contents_->GetMainFrame()->ExecuteJavaScript( |
1444 ConvertJavaStringToUTF16(env, script), | 1444 ConvertJavaStringToUTF16(env, script), |
1445 c_callback); | 1445 c_callback); |
1446 } | 1446 } |
1447 | 1447 |
1448 void ContentViewCoreImpl::PostMessageToMainWindow(JNIEnv* env, jobject obj, | |
1449 jstring message, jstring target_origin) { | |
1450 | |
1451 RenderViewHost* host = web_contents_->GetRenderViewHost(); | |
1452 ViewMsg_PostMessage_Params params; | |
1453 // TODO(sgurun) What should be the value of source_origin for webview | |
1454 // params.source_origin =? "/"; | |
1455 // TODO(sgurun) see why this seems to not work | |
1456 //params.target_origin = ConvertJavaStringToUTF16(env, target_origin); | |
1457 // TODO(sgurun) do not use JSON, pass as base::value | |
1458 params.data = ConvertJavaStringToUTF16(env, message); | |
1459 params.is_data_raw_string = true; | |
1460 params.source_routing_id = GetWebContents()->GetRoutingID(); | |
nasko
2014/06/20 16:56:52
The source routing id is the same routing ID as th
sgurun-gerrit only
2014/07/11 00:45:46
Done.
| |
1461 // TODO(sgurun) do add port ids once we add support for that. | |
1462 | |
1463 if (host) | |
1464 host->Send(new ViewMsg_PostMessageEvent(host->GetRoutingID(), params)); | |
1465 } | |
1466 | |
1467 | |
1448 bool ContentViewCoreImpl::GetUseDesktopUserAgent( | 1468 bool ContentViewCoreImpl::GetUseDesktopUserAgent( |
1449 JNIEnv* env, jobject obj) { | 1469 JNIEnv* env, jobject obj) { |
1450 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); | 1470 NavigationEntry* entry = web_contents_->GetController().GetVisibleEntry(); |
1451 return entry && entry->GetIsOverridingUserAgent(); | 1471 return entry && entry->GetIsOverridingUserAgent(); |
1452 } | 1472 } |
1453 | 1473 |
1454 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter, | 1474 void ContentViewCoreImpl::UpdateImeAdapter(long native_ime_adapter, |
1455 int text_input_type, | 1475 int text_input_type, |
1456 const std::string& text, | 1476 const std::string& text, |
1457 int selection_start, | 1477 int selection_start, |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1632 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1652 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1633 retained_objects_set); | 1653 retained_objects_set); |
1634 return reinterpret_cast<intptr_t>(view); | 1654 return reinterpret_cast<intptr_t>(view); |
1635 } | 1655 } |
1636 | 1656 |
1637 bool RegisterContentViewCore(JNIEnv* env) { | 1657 bool RegisterContentViewCore(JNIEnv* env) { |
1638 return RegisterNativesImpl(env); | 1658 return RegisterNativesImpl(env); |
1639 } | 1659 } |
1640 | 1660 |
1641 } // namespace content | 1661 } // namespace content |
OLD | NEW |