OLD | NEW |
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/command_line.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 // base::Callback. | 389 // base::Callback. |
390 ScopedJavaGlobalRef<jobject> j_callback; | 390 ScopedJavaGlobalRef<jobject> j_callback; |
391 j_callback.Reset(env, callback); | 391 j_callback.Reset(env, callback); |
392 content::RenderFrameHost::JavaScriptResultCallback js_callback = | 392 content::RenderFrameHost::JavaScriptResultCallback js_callback = |
393 base::Bind(&JavaScriptResultCallback, j_callback); | 393 base::Bind(&JavaScriptResultCallback, j_callback); |
394 | 394 |
395 web_contents_->GetMainFrame()->ExecuteJavaScript( | 395 web_contents_->GetMainFrame()->ExecuteJavaScript( |
396 ConvertJavaStringToUTF16(env, script), js_callback); | 396 ConvertJavaStringToUTF16(env, script), js_callback); |
397 } | 397 } |
398 | 398 |
399 // TODO(sgurun) add support for posting a frame whose name is known (only | |
400 // main frame is supported at this time, see crbug.com/389721) | |
401 // TODO(sgurun) add support for passing message ports | |
402 void WebContentsAndroid::PostMessageToFrame(JNIEnv* env, jobject obj, | |
403 jstring frame_name, jstring message, jstring source_origin, | |
404 jstring target_origin) { | |
405 | |
406 RenderViewHost* host = web_contents_->GetRenderViewHost(); | |
407 if (!host) | |
408 return; | |
409 ViewMsg_PostMessage_Params params; | |
410 params.source_origin = ConvertJavaStringToUTF16(env, source_origin); | |
411 params.target_origin = ConvertJavaStringToUTF16(env, target_origin); | |
412 params.data = ConvertJavaStringToUTF16(env, message); | |
413 params.is_data_raw_string = true; | |
414 params.source_routing_id = MSG_ROUTING_NONE; | |
415 host->Send(new ViewMsg_PostMessageEvent(host->GetRoutingID(), params)); | |
416 } | |
417 | |
418 } // namespace content | 399 } // namespace content |
OLD | NEW |