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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 // base::Callback. | 356 // base::Callback. |
357 ScopedJavaGlobalRef<jobject> j_callback; | 357 ScopedJavaGlobalRef<jobject> j_callback; |
358 j_callback.Reset(env, callback); | 358 j_callback.Reset(env, callback); |
359 content::RenderFrameHost::JavaScriptResultCallback js_callback = | 359 content::RenderFrameHost::JavaScriptResultCallback js_callback = |
360 base::Bind(&JavaScriptResultCallback, j_callback); | 360 base::Bind(&JavaScriptResultCallback, j_callback); |
361 | 361 |
362 web_contents_->GetMainFrame()->ExecuteJavaScript( | 362 web_contents_->GetMainFrame()->ExecuteJavaScript( |
363 ConvertJavaStringToUTF16(env, script), js_callback); | 363 ConvertJavaStringToUTF16(env, script), js_callback); |
364 } | 364 } |
365 | 365 |
366 // TODO(sgurun) add support for posting a frame whose name is known (only | |
367 // main frame is supported at this time, see crbug.com/389721) | |
368 // TODO(sgurun) add support for passing message ports | |
369 void WebContentsAndroid::PostMessageToFrame(JNIEnv* env, jobject obj, | |
370 jstring frame_name, jstring message, jstring source_origin, | |
371 jstring target_origin) { | |
372 | |
373 RenderViewHost* host = web_contents_->GetRenderViewHost(); | |
374 if (!host) | |
375 return; | |
376 ViewMsg_PostMessage_Params params; | |
377 params.source_origin = ConvertJavaStringToUTF16(env, source_origin); | |
378 params.target_origin = ConvertJavaStringToUTF16(env, target_origin); | |
379 params.data = ConvertJavaStringToUTF16(env, message); | |
380 params.is_data_raw_string = true; | |
381 params.source_routing_id = MSG_ROUTING_NONE; | |
382 host->Send(new ViewMsg_PostMessageEvent(host->GetRoutingID(), params)); | |
383 } | |
384 | |
385 } // namespace content | 366 } // namespace content |
OLD | NEW |