Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/android/view_android.h" | 5 #include "ui/android/view_android.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "cc/layers/layer.h" | 10 #include "cc/layers/layer.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 view_.reset(); | 61 view_.reset(); |
| 62 delegate_.reset(); | 62 delegate_.reset(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 const base::android::ScopedJavaLocalRef<jobject> | 65 const base::android::ScopedJavaLocalRef<jobject> |
| 66 ViewAndroid::ScopedAnchorView::view() const { | 66 ViewAndroid::ScopedAnchorView::view() const { |
| 67 JNIEnv* env = base::android::AttachCurrentThread(); | 67 JNIEnv* env = base::android::AttachCurrentThread(); |
| 68 return view_.get(env); | 68 return view_.get(env); |
| 69 } | 69 } |
| 70 | 70 |
| 71 ViewAndroid::ViewAndroid(const JavaRef<jobject>& delegate) | 71 ViewAndroid::ViewAndroid(const JavaRef<jobject>& delegate) |
|
boliu
2016/10/31 01:45:52
is there anything (other than tests) that pass in
Jinsuk Kim
2016/10/31 02:01:16
Done.
| |
| 72 : parent_(nullptr) | 72 : parent_(nullptr) |
| 73 , delegate_(base::android::AttachCurrentThread(), | 73 , delegate_(base::android::AttachCurrentThread(), |
| 74 delegate.obj()) {} | 74 delegate.obj()) {} |
| 75 | 75 |
| 76 ViewAndroid::ViewAndroid() : parent_(nullptr) {} | 76 ViewAndroid::ViewAndroid() : parent_(nullptr) {} |
| 77 | 77 |
| 78 ViewAndroid::~ViewAndroid() { | 78 ViewAndroid::~ViewAndroid() { |
| 79 RemoveFromParent(); | 79 RemoveFromParent(); |
| 80 | 80 |
| 81 for (std::list<ViewAndroid*>::iterator it = children_.begin(); | 81 for (std::list<ViewAndroid*>::iterator it = children_.begin(); |
| 82 it != children_.end(); it++) { | 82 it != children_.end(); it++) { |
| 83 DCHECK_EQ((*it)->parent_, this); | 83 DCHECK_EQ((*it)->parent_, this); |
| 84 (*it)->parent_ = nullptr; | 84 (*it)->parent_ = nullptr; |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 | 87 |
| 88 void ViewAndroid::SetDelegate(const JavaRef<jobject>& delegate) { | |
| 89 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 90 delegate_ = JavaObjectWeakGlobalRef(env, delegate); | |
| 91 } | |
| 92 | |
| 88 void ViewAndroid::AddChild(ViewAndroid* child) { | 93 void ViewAndroid::AddChild(ViewAndroid* child) { |
| 89 DCHECK(child); | 94 DCHECK(child); |
| 90 DCHECK(std::find(children_.begin(), children_.end(), child) == | 95 DCHECK(std::find(children_.begin(), children_.end(), child) == |
| 91 children_.end()); | 96 children_.end()); |
| 92 | 97 |
| 93 children_.push_back(child); | 98 children_.push_back(child); |
| 94 if (child->parent_) | 99 if (child->parent_) |
| 95 child->RemoveFromParent(); | 100 child->RemoveFromParent(); |
| 96 child->parent_ = this; | 101 child->parent_ = this; |
| 97 } | 102 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 const JavaRef<jobject>& jimage) { | 173 const JavaRef<jobject>& jimage) { |
| 169 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); | 174 ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate()); |
| 170 if (delegate.is_null()) | 175 if (delegate.is_null()) |
| 171 return false; | 176 return false; |
| 172 JNIEnv* env = base::android::AttachCurrentThread(); | 177 JNIEnv* env = base::android::AttachCurrentThread(); |
| 173 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, | 178 return Java_ViewAndroidDelegate_startDragAndDrop(env, delegate, jtext, |
| 174 jimage); | 179 jimage); |
| 175 } | 180 } |
| 176 | 181 |
| 177 } // namespace ui | 182 } // namespace ui |
| OLD | NEW |