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

Side by Side Diff: ui/android/view_android.cc

Issue 2453213003: Have WebContentsViewAndroid own ViewAndroid (Closed)
Patch Set: fixed builds & rebased Created 4 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
« ui/android/view_android.h ('K') | « ui/android/view_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« ui/android/view_android.h ('K') | « ui/android/view_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698