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

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

Issue 701233002: [Android] Support unfocusable container views. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 574 }
575 575
576 bool ContentViewCoreImpl::HasFocus() { 576 bool ContentViewCoreImpl::HasFocus() {
577 JNIEnv* env = AttachCurrentThread(); 577 JNIEnv* env = AttachCurrentThread();
578 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 578 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
579 if (obj.is_null()) 579 if (obj.is_null())
580 return false; 580 return false;
581 return Java_ContentViewCore_hasFocus(env, obj.obj()); 581 return Java_ContentViewCore_hasFocus(env, obj.obj());
582 } 582 }
583 583
584 bool ContentViewCoreImpl::IsFocusable() {
585 JNIEnv* env = AttachCurrentThread();
586 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
587 if (obj.is_null())
588 return false;
589 return Java_ContentViewCore_isFocusable(env, obj.obj());
590 }
591
584 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) { 592 void ContentViewCoreImpl::OnSelectionChanged(const std::string& text) {
585 JNIEnv* env = AttachCurrentThread(); 593 JNIEnv* env = AttachCurrentThread();
586 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); 594 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
587 if (obj.is_null()) 595 if (obj.is_null())
588 return; 596 return;
589 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text); 597 ScopedJavaLocalRef<jstring> jtext = ConvertUTF8ToJavaString(env, text);
590 Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj()); 598 Java_ContentViewCore_onSelectionChanged(env, obj.obj(), jtext.obj());
591 } 599 }
592 600
593 void ContentViewCoreImpl::OnSelectionEvent(SelectionEventType event, 601 void ContentViewCoreImpl::OnSelectionEvent(SelectionEventType event,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } 840 }
833 841
834 void ContentViewCoreImpl::SetFocus(JNIEnv* env, jobject obj, jboolean focused) { 842 void ContentViewCoreImpl::SetFocus(JNIEnv* env, jobject obj, jboolean focused) {
835 SetFocusInternal(focused); 843 SetFocusInternal(focused);
836 } 844 }
837 845
838 void ContentViewCoreImpl::SetFocusInternal(bool focused) { 846 void ContentViewCoreImpl::SetFocusInternal(bool focused) {
839 if (!GetRenderWidgetHostViewAndroid()) 847 if (!GetRenderWidgetHostViewAndroid())
840 return; 848 return;
841 849
850 if (!IsFocusable()) {
851 LOG(WARN) << "Unfocusable container view, treating as always focused.";
jdduke (slow) 2014/11/05 21:20:31 Hmm, we know that this condition exists, will the
852 focused = true;
853 }
854
842 if (focused) 855 if (focused)
843 GetRenderWidgetHostViewAndroid()->Focus(); 856 GetRenderWidgetHostViewAndroid()->Focus();
844 else 857 else
845 GetRenderWidgetHostViewAndroid()->Blur(); 858 GetRenderWidgetHostViewAndroid()->Blur();
846 } 859 }
847 860
848 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env, 861 void ContentViewCoreImpl::SendOrientationChangeEvent(JNIEnv* env,
849 jobject obj, 862 jobject obj,
850 jint orientation) { 863 jint orientation) {
851 if (device_orientation_ != orientation) { 864 if (device_orientation_ != orientation) {
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 reinterpret_cast<ui::WindowAndroid*>(window_android), 1338 reinterpret_cast<ui::WindowAndroid*>(window_android),
1326 retained_objects_set); 1339 retained_objects_set);
1327 return reinterpret_cast<intptr_t>(view); 1340 return reinterpret_cast<intptr_t>(view);
1328 } 1341 }
1329 1342
1330 bool RegisterContentViewCore(JNIEnv* env) { 1343 bool RegisterContentViewCore(JNIEnv* env) {
1331 return RegisterNativesImpl(env); 1344 return RegisterNativesImpl(env);
1332 } 1345 }
1333 1346
1334 } // namespace content 1347 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698