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

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

Issue 292113008: Plumbing for browser process to access text surrounding selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@adb_install_humans
Patch Set: Created 6 years, 7 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
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 19 matching lines...) Expand all
30 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " 30 #include "content/browser/renderer_host/input/web_input_event_builders_android.h "
31 #include "content/browser/renderer_host/input/web_input_event_util.h" 31 #include "content/browser/renderer_host/input/web_input_event_util.h"
32 #include "content/browser/renderer_host/java/java_bound_object.h" 32 #include "content/browser/renderer_host/java/java_bound_object.h"
33 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h" 33 #include "content/browser/renderer_host/java/java_bridge_dispatcher_host_manager .h"
34 #include "content/browser/renderer_host/render_view_host_impl.h" 34 #include "content/browser/renderer_host/render_view_host_impl.h"
35 #include "content/browser/renderer_host/render_widget_host_impl.h" 35 #include "content/browser/renderer_host/render_widget_host_impl.h"
36 #include "content/browser/renderer_host/render_widget_host_view_android.h" 36 #include "content/browser/renderer_host/render_widget_host_view_android.h"
37 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h" 37 #include "content/browser/screen_orientation/screen_orientation_dispatcher_host. h"
38 #include "content/browser/ssl/ssl_host_state.h" 38 #include "content/browser/ssl/ssl_host_state.h"
39 #include "content/browser/web_contents/web_contents_view_android.h" 39 #include "content/browser/web_contents/web_contents_view_android.h"
40 #include "content/common/frame_messages.h"
40 #include "content/common/input/web_input_event_traits.h" 41 #include "content/common/input/web_input_event_traits.h"
41 #include "content/common/input_messages.h" 42 #include "content/common/input_messages.h"
42 #include "content/common/view_messages.h" 43 #include "content/common/view_messages.h"
43 #include "content/public/browser/browser_accessibility_state.h" 44 #include "content/public/browser/browser_accessibility_state.h"
44 #include "content/public/browser/browser_context.h" 45 #include "content/public/browser/browser_context.h"
45 #include "content/public/browser/favicon_status.h" 46 #include "content/public/browser/favicon_status.h"
46 #include "content/public/browser/notification_details.h" 47 #include "content/public/browser/notification_details.h"
47 #include "content/public/browser/notification_service.h" 48 #include "content/public/browser/notification_service.h"
48 #include "content/public/browser/notification_source.h" 49 #include "content/public/browser/notification_source.h"
49 #include "content/public/browser/notification_types.h" 50 #include "content/public/browser/notification_types.h"
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 // If it was actually enabled globally, enable it for this RenderWidget now. 1565 // If it was actually enabled globally, enable it for this RenderWidget now.
1565 if (accessibility_state->IsAccessibleBrowser() && host_impl) 1566 if (accessibility_state->IsAccessibleBrowser() && host_impl)
1566 host_impl->AddAccessibilityMode(AccessibilityModeComplete); 1567 host_impl->AddAccessibilityMode(AccessibilityModeComplete);
1567 } else { 1568 } else {
1568 accessibility_state->ResetAccessibilityMode(); 1569 accessibility_state->ResetAccessibilityMode();
1569 if (host_impl) 1570 if (host_impl)
1570 host_impl->ResetAccessibilityMode(); 1571 host_impl->ResetAccessibilityMode();
1571 } 1572 }
1572 } 1573 }
1573 1574
1575 void ContentViewCoreImpl::OnTextSurroundingSelectionResponse(
1576 const base::string16& content,
1577 unsigned start_offset,
1578 unsigned end_offset) {
1579 JNIEnv* env = AttachCurrentThread();
1580 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1581 if (obj.is_null())
1582 return;
1583
1584 ScopedJavaLocalRef<jstring> jcontent = ConvertUTF16ToJavaString(env, content);
1585 Java_ContentViewCore_onTextSurroundingSelectionResponse(
1586 env, obj.obj(), jcontent.obj(), start_offset, end_offset);
1587 }
1588
1574 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { 1589 void ContentViewCoreImpl::SendOrientationChangeEventInternal() {
1575 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 1590 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
1576 if (rwhv) 1591 if (rwhv)
1577 rwhv->UpdateScreenInfo(GetViewAndroid()); 1592 rwhv->UpdateScreenInfo(GetViewAndroid());
1578 1593
1579 // TODO(mlamouri): temporary plumbing for Screen Orientation, this will change 1594 // TODO(mlamouri): temporary plumbing for Screen Orientation, this will change
1580 // in the future. The OnResize IPC message sent from UpdateScreenInfo() will 1595 // in the future. The OnResize IPC message sent from UpdateScreenInfo() will
1581 // propagate the information. 1596 // propagate the information.
1582 blink::WebScreenOrientationType orientation = 1597 blink::WebScreenOrientationType orientation =
1583 blink::WebScreenOrientationPortraitPrimary; 1598 blink::WebScreenOrientationPortraitPrimary;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 1 : (int)(height / dpi_scale()))); 1639 1 : (int)(height / dpi_scale())));
1625 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData( 1640 GetWebContents()->Send(new ViewMsg_ExtractSmartClipData(
1626 GetWebContents()->GetRoutingID(), rect)); 1641 GetWebContents()->GetRoutingID(), rect));
1627 } 1642 }
1628 1643
1629 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) { 1644 jint ContentViewCoreImpl::GetCurrentRenderProcessId(JNIEnv* env, jobject obj) {
1630 return GetRenderProcessIdFromRenderViewHost( 1645 return GetRenderProcessIdFromRenderViewHost(
1631 web_contents_->GetRenderViewHost()); 1646 web_contents_->GetRenderViewHost());
1632 } 1647 }
1633 1648
1649 void ContentViewCoreImpl::TextSurroundingSelectionRequest(
1650 JNIEnv*, jobject, jint max_length) {
1651 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame();
1652
1653 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest(
1654 focused_frame->GetRoutingID(), max_length));
1655 }
1656
1634 void ContentViewCoreImpl::OnSmartClipDataExtracted( 1657 void ContentViewCoreImpl::OnSmartClipDataExtracted(
1635 const base::string16& result) { 1658 const base::string16& result) {
1636 JNIEnv* env = AttachCurrentThread(); 1659 JNIEnv* env = AttachCurrentThread();
1637 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 1660 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1638 if (obj.is_null()) 1661 if (obj.is_null())
1639 return; 1662 return;
1640 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); 1663 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result);
1641 Java_ContentViewCore_onSmartClipDataExtracted( 1664 Java_ContentViewCore_onSmartClipDataExtracted(
1642 env, obj.obj(), jresult.obj()); 1665 env, obj.obj(), jresult.obj());
1643 } 1666 }
(...skipping 19 matching lines...) Expand all
1663 reinterpret_cast<ui::WindowAndroid*>(window_android), 1686 reinterpret_cast<ui::WindowAndroid*>(window_android),
1664 retained_objects_set); 1687 retained_objects_set);
1665 return reinterpret_cast<intptr_t>(view); 1688 return reinterpret_cast<intptr_t>(view);
1666 } 1689 }
1667 1690
1668 bool RegisterContentViewCore(JNIEnv* env) { 1691 bool RegisterContentViewCore(JNIEnv* env) {
1669 return RegisterNativesImpl(env); 1692 return RegisterNativesImpl(env);
1670 } 1693 }
1671 1694
1672 } // namespace content 1695 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698