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

Unified Diff: content/browser/web_contents/web_contents_view_android.cc

Issue 2453213003: Have WebContentsViewAndroid own ViewAndroid (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/web_contents/web_contents_view_android.cc
diff --git a/content/browser/web_contents/web_contents_view_android.cc b/content/browser/web_contents/web_contents_view_android.cc
index 0222bc629b44766fe282fe8df395257522a925a6..4a7afa442638b46c723ab60165c1724aec7c5a8f 100644
--- a/content/browser/web_contents/web_contents_view_android.cc
+++ b/content/browser/web_contents/web_contents_view_android.cc
@@ -7,6 +7,7 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/logging.h"
+#include "cc/layers/layer.h"
#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/frame_host/interstitial_page_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_android.h"
@@ -64,6 +65,8 @@ WebContentsViewAndroid::WebContentsViewAndroid(
}
WebContentsViewAndroid::~WebContentsViewAndroid() {
+ if (view_ && view_->GetLayer())
+ view_->GetLayer()->RemoveFromParent();
}
void WebContentsViewAndroid::SetContentViewCore(
@@ -87,7 +90,7 @@ void WebContentsViewAndroid::SetContentViewCore(
}
gfx::NativeView WebContentsViewAndroid::GetNativeView() const {
- return content_view_core_ ? content_view_core_->GetViewAndroid() : nullptr;
+ return view_.get();
}
gfx::NativeView WebContentsViewAndroid::GetContentNativeView() const {
@@ -161,6 +164,11 @@ gfx::Rect WebContentsViewAndroid::GetViewBounds() const {
void WebContentsViewAndroid::CreateView(
const gfx::Size& initial_size, gfx::NativeView context) {
+ // On Android, avoid using the native view copied over from the CreateParams
+ // of the existing web contents view where initial size and the view are
+ // already set. Embedder provides one associated with a Java layer
+ // content view and the delegate.
+ if (initial_size.IsEmpty() && context) view_.reset(context);
}
RenderWidgetHostViewBase* WebContentsViewAndroid::CreateViewForWidget(

Powered by Google App Engine
This is Rietveld 408576698