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

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

Issue 322203002: Add an interface to gather text surrounding the selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@surroundings-patch-5
Patch Set: Moved the callback to RenderWidgetHostViewAndroid. Created 6 years, 6 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/render_frame_host.h" 47 #include "content/public/browser/render_frame_host.h"
47 #include "content/public/browser/web_contents.h" 48 #include "content/public/browser/web_contents.h"
48 #include "content/public/common/content_client.h" 49 #include "content/public/common/content_client.h"
49 #include "content/public/common/content_switches.h" 50 #include "content/public/common/content_switches.h"
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 return GetRenderProcessIdFromRenderViewHost( 1566 return GetRenderProcessIdFromRenderViewHost(
1566 web_contents_->GetRenderViewHost()); 1567 web_contents_->GetRenderViewHost());
1567 } 1568 }
1568 1569
1569 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, 1570 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj,
1570 jboolean opaque) { 1571 jboolean opaque) {
1571 if (GetRenderWidgetHostViewAndroid()) 1572 if (GetRenderWidgetHostViewAndroid())
1572 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); 1573 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque);
1573 } 1574 }
1574 1575
1576 void ContentViewCoreImpl::RequestTextSurroundingSelection(
1577 int max_length,
1578 const base::Callback<
1579 void(const base::string16& content, int start_offset, int end_offset)>&
1580 callback) {
1581 DCHECK(!callback.is_null());
1582 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame();
1583 if (!focused_frame)
1584 return;
1585 if (GetRenderWidgetHostViewAndroid()) {
1586 GetRenderWidgetHostViewAndroid()->SetTextSurroundingSelectionCallback(
1587 callback);
1588 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest(
1589 focused_frame->GetRoutingID(), max_length));
1590 }
1591 }
1592
1575 void ContentViewCoreImpl::OnSmartClipDataExtracted( 1593 void ContentViewCoreImpl::OnSmartClipDataExtracted(
1576 const base::string16& result) { 1594 const base::string16& result) {
1577 JNIEnv* env = AttachCurrentThread(); 1595 JNIEnv* env = AttachCurrentThread();
1578 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 1596 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1579 if (obj.is_null()) 1597 if (obj.is_null())
1580 return; 1598 return;
1581 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result); 1599 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result);
1582 Java_ContentViewCore_onSmartClipDataExtracted( 1600 Java_ContentViewCore_onSmartClipDataExtracted(
1583 env, obj.obj(), jresult.obj()); 1601 env, obj.obj(), jresult.obj());
1584 } 1602 }
(...skipping 19 matching lines...) Expand all
1604 reinterpret_cast<ui::WindowAndroid*>(window_android), 1622 reinterpret_cast<ui::WindowAndroid*>(window_android),
1605 retained_objects_set); 1623 retained_objects_set);
1606 return reinterpret_cast<intptr_t>(view); 1624 return reinterpret_cast<intptr_t>(view);
1607 } 1625 }
1608 1626
1609 bool RegisterContentViewCore(JNIEnv* env) { 1627 bool RegisterContentViewCore(JNIEnv* env) {
1610 return RegisterNativesImpl(env); 1628 return RegisterNativesImpl(env);
1611 } 1629 }
1612 1630
1613 } // namespace content 1631 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/renderer_host/render_widget_host_view_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698