Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 332693004: Add a content API for postMessage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed mnaganov's review Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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,
Yaron 2014/07/16 17:18:05 given that this is only for aw and not chrome, can
sgurun-gerrit only 2014/07/16 18:01:27 Himm, I don't think aw_ can create the ViewMsg_Pos
Yaron 2014/07/16 18:09:19 I'm not sure about making the message public (can
1430 jstring frame_name, jstring message, jstring source_origin,
1431 jstring target_origin) {
1432
1433 RenderViewHost* host = web_contents_->GetRenderViewHost();
1434 if (!host)
1435 return;
1436 ViewMsg_PostMessage_Params params;
1437 params.source_origin = ConvertJavaStringToUTF16(env, source_origin);
1438 params.target_origin = ConvertJavaStringToUTF16(env, target_origin);
1439 params.data = ConvertJavaStringToUTF16(env, message);
1440 params.is_data_raw_string = true;
1441 params.source_routing_id = MSG_ROUTING_NONE;
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698