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

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

Issue 378233002: [Android] Extend smart clip to return html along with text (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 JNIEnv* env = AttachCurrentThread(); 1628 JNIEnv* env = AttachCurrentThread();
1629 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 1629 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1630 if (obj.is_null()) 1630 if (obj.is_null())
1631 return false; 1631 return false;
1632 1632
1633 return Java_ContentViewCore_willHandleDeferAfterResponseStarted(env, 1633 return Java_ContentViewCore_willHandleDeferAfterResponseStarted(env,
1634 obj.obj()); 1634 obj.obj());
1635 } 1635 }
1636 1636
1637 void ContentViewCoreImpl::OnSmartClipDataExtracted( 1637 void ContentViewCoreImpl::OnSmartClipDataExtracted(
1638 const gfx::Rect& clip_rect, 1638 const base::string16& text,
1639 const base::string16& result) { 1639 const base::string16& html,
1640 const gfx::Rect& clip_rect) {
1640 JNIEnv* env = AttachCurrentThread(); 1641 JNIEnv* env = AttachCurrentThread();
1641 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 1642 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
1642 if (obj.is_null()) 1643 if (obj.is_null())
1643 return; 1644 return;
1645 ScopedJavaLocalRef<jstring> jtext = ConvertUTF16ToJavaString(env, text);
1646 ScopedJavaLocalRef<jstring> jhtml = ConvertUTF16ToJavaString(env, html);
1644 ScopedJavaLocalRef<jobject> clip_rect_object(CreateJavaRect(env, clip_rect)); 1647 ScopedJavaLocalRef<jobject> clip_rect_object(CreateJavaRect(env, clip_rect));
1645 ScopedJavaLocalRef<jstring> jresult = ConvertUTF16ToJavaString(env, result);
1646 Java_ContentViewCore_onSmartClipDataExtracted( 1648 Java_ContentViewCore_onSmartClipDataExtracted(
1647 env, obj.obj(), jresult.obj(), clip_rect_object.obj()); 1649 env, obj.obj(), jtext.obj(), jhtml.obj(), clip_rect_object.obj());
1648 } 1650 }
1649 1651
1650 void ContentViewCoreImpl::WebContentsDestroyed() { 1652 void ContentViewCoreImpl::WebContentsDestroyed() {
1651 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>( 1653 WebContentsViewAndroid* wcva = static_cast<WebContentsViewAndroid*>(
1652 static_cast<WebContentsImpl*>(web_contents())->GetView()); 1654 static_cast<WebContentsImpl*>(web_contents())->GetView());
1653 DCHECK(wcva); 1655 DCHECK(wcva);
1654 wcva->SetContentViewCore(NULL); 1656 wcva->SetContentViewCore(NULL);
1655 } 1657 }
1656 1658
1657 // This is called for each ContentView. 1659 // This is called for each ContentView.
(...skipping 10 matching lines...) Expand all
1668 reinterpret_cast<ui::WindowAndroid*>(window_android), 1670 reinterpret_cast<ui::WindowAndroid*>(window_android),
1669 retained_objects_set); 1671 retained_objects_set);
1670 return reinterpret_cast<intptr_t>(view); 1672 return reinterpret_cast<intptr_t>(view);
1671 } 1673 }
1672 1674
1673 bool RegisterContentViewCore(JNIEnv* env) { 1675 bool RegisterContentViewCore(JNIEnv* env) {
1674 return RegisterNativesImpl(env); 1676 return RegisterNativesImpl(env);
1675 } 1677 }
1676 1678
1677 } // namespace content 1679 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698