OLD | NEW |
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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 accessibility_state->ResetAccessibilityMode(); | 1532 accessibility_state->ResetAccessibilityMode(); |
1533 if (host_impl) | 1533 if (host_impl) |
1534 host_impl->ResetAccessibilityMode(); | 1534 host_impl->ResetAccessibilityMode(); |
1535 } | 1535 } |
1536 } | 1536 } |
1537 | 1537 |
1538 void ContentViewCoreImpl::OnTextSurroundingSelectionResponse( | 1538 void ContentViewCoreImpl::OnTextSurroundingSelectionResponse( |
1539 const base::string16& content, | 1539 const base::string16& content, |
1540 int start_offset, | 1540 int start_offset, |
1541 int end_offset) { | 1541 int end_offset) { |
1542 JNIEnv* env = AttachCurrentThread(); | 1542 if (text_surroundings_delegate_ != NULL) { |
1543 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1543 text_surroundings_delegate_->OnTextSurroundingSelectionResponse( |
1544 if (obj.is_null()) | 1544 content, start_offset, end_offset); |
1545 return; | 1545 } |
1546 | |
1547 ScopedJavaLocalRef<jstring> jcontent = ConvertUTF16ToJavaString(env, content); | |
1548 Java_ContentViewCore_onTextSurroundingSelectionResponse( | |
1549 env, obj.obj(), jcontent.obj(), start_offset, end_offset); | |
1550 } | 1546 } |
1551 | 1547 |
1552 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { | 1548 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { |
1553 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); | 1549 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); |
1554 if (rwhv) | 1550 if (rwhv) |
1555 rwhv->UpdateScreenInfo(GetViewAndroid()); | 1551 rwhv->UpdateScreenInfo(GetViewAndroid()); |
1556 | 1552 |
1557 // TODO(mlamouri): temporary plumbing for Screen Orientation, this will change | 1553 // TODO(mlamouri): temporary plumbing for Screen Orientation, this will change |
1558 // in the future. The OnResize IPC message sent from UpdateScreenInfo() will | 1554 // in the future. The OnResize IPC message sent from UpdateScreenInfo() will |
1559 // propagate the information. | 1555 // propagate the information. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 return GetRenderProcessIdFromRenderViewHost( | 1604 return GetRenderProcessIdFromRenderViewHost( |
1609 web_contents_->GetRenderViewHost()); | 1605 web_contents_->GetRenderViewHost()); |
1610 } | 1606 } |
1611 | 1607 |
1612 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, | 1608 void ContentViewCoreImpl::SetBackgroundOpaque(JNIEnv* env, jobject jobj, |
1613 jboolean opaque) { | 1609 jboolean opaque) { |
1614 if (GetRenderWidgetHostViewAndroid()) | 1610 if (GetRenderWidgetHostViewAndroid()) |
1615 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); | 1611 GetRenderWidgetHostViewAndroid()->SetBackgroundOpaque(opaque); |
1616 } | 1612 } |
1617 | 1613 |
1618 void ContentViewCoreImpl::TextSurroundingSelectionRequest( | 1614 void ContentViewCoreImpl::TextSurroundingSelectionRequest(int max_length) { |
1619 JNIEnv*, jobject, jint max_length) { | |
1620 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); | 1615 RenderFrameHost* focused_frame = web_contents_->GetFocusedFrame(); |
1621 | 1616 |
1622 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( | 1617 focused_frame->Send(new FrameMsg_TextSurroundingSelectionRequest( |
1623 focused_frame->GetRoutingID(), max_length)); | 1618 focused_frame->GetRoutingID(), max_length)); |
1624 } | 1619 } |
1625 | 1620 |
1626 void ContentViewCoreImpl::OnSmartClipDataExtracted( | 1621 void ContentViewCoreImpl::OnSmartClipDataExtracted( |
1627 const base::string16& result) { | 1622 const base::string16& result) { |
1628 JNIEnv* env = AttachCurrentThread(); | 1623 JNIEnv* env = AttachCurrentThread(); |
1629 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 1624 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
(...skipping 25 matching lines...) Expand all Loading... |
1655 reinterpret_cast<ui::WindowAndroid*>(window_android), | 1650 reinterpret_cast<ui::WindowAndroid*>(window_android), |
1656 retained_objects_set); | 1651 retained_objects_set); |
1657 return reinterpret_cast<intptr_t>(view); | 1652 return reinterpret_cast<intptr_t>(view); |
1658 } | 1653 } |
1659 | 1654 |
1660 bool RegisterContentViewCore(JNIEnv* env) { | 1655 bool RegisterContentViewCore(JNIEnv* env) { |
1661 return RegisterNativesImpl(env); | 1656 return RegisterNativesImpl(env); |
1662 } | 1657 } |
1663 | 1658 |
1664 } // namespace content | 1659 } // namespace content |
OLD | NEW |