Commit 28492529 authored by Dave Tapuska's avatar Dave Tapuska Committed by Chromium LUCI CQ

Do not send the UpdateBrowserControlsState before CreateView.

If the UpdateBrowserControlsState is sent before the view (and main
frame) are created then it won't go anywhere.

Ensure the disabling of browser controls state occurs after the main
is created by adding a WebContentsObserver.

BUG=1158712

Change-Id: I96dca9b47381291769a6727ad973656559a6701d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2613151Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841055}
parent b77a27f4
...@@ -47,6 +47,17 @@ void ThinWebView::Destroy(JNIEnv* env, const JavaParamRef<jobject>& object) { ...@@ -47,6 +47,17 @@ void ThinWebView::Destroy(JNIEnv* env, const JavaParamRef<jobject>& object) {
delete this; delete this;
} }
void ThinWebView::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) {
// Only update the browser controls state for the main frame.
if (render_frame_host->GetParent())
return;
// Disable browser controls when used for thin webview.
render_frame_host->UpdateBrowserControlsState(
cc::BrowserControlsState::kHidden, cc::BrowserControlsState::kHidden,
false);
}
void ThinWebView::SetWebContents( void ThinWebView::SetWebContents(
JNIEnv* env, JNIEnv* env,
const JavaParamRef<jobject>& obj, const JavaParamRef<jobject>& obj,
...@@ -65,6 +76,7 @@ void ThinWebView::SetWebContents(content::WebContents* web_contents, ...@@ -65,6 +76,7 @@ void ThinWebView::SetWebContents(content::WebContents* web_contents,
WebContentsDelegateAndroid* delegate) { WebContentsDelegateAndroid* delegate) {
DCHECK(web_contents); DCHECK(web_contents);
web_contents_ = web_contents; web_contents_ = web_contents;
Observe(web_contents_);
ui::ViewAndroid* view_android = web_contents_->GetNativeView(); ui::ViewAndroid* view_android = web_contents_->GetNativeView();
if (view_android->parent() != window_android_) { if (view_android->parent() != window_android_) {
window_android_->AddChild(view_android); window_android_->AddChild(view_android);
...@@ -77,11 +89,6 @@ void ThinWebView::SetWebContents(content::WebContents* web_contents, ...@@ -77,11 +89,6 @@ void ThinWebView::SetWebContents(content::WebContents* web_contents,
web_contents->SetDelegate(delegate); web_contents->SetDelegate(delegate);
ThinWebViewInitializer::GetInstance()->AttachTabHelpers(web_contents); ThinWebViewInitializer::GetInstance()->AttachTabHelpers(web_contents);
// Disable browser controls when used for thin webview.
web_contents->GetMainFrame()->UpdateBrowserControlsState(
cc::BrowserControlsState::kHidden, cc::BrowserControlsState::kHidden,
false);
} }
void ThinWebView::SizeChanged(JNIEnv* env, void ThinWebView::SizeChanged(JNIEnv* env,
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "components/thin_webview/internal/compositor_view_impl.h" #include "components/thin_webview/internal/compositor_view_impl.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "ui/android/window_android.h" #include "ui/android/window_android.h"
namespace web_contents_delegate_android { namespace web_contents_delegate_android {
...@@ -22,13 +23,13 @@ namespace thin_webview { ...@@ -22,13 +23,13 @@ namespace thin_webview {
namespace android { namespace android {
// Native counterpart of ThinWebViewImpl.java. // Native counterpart of ThinWebViewImpl.java.
class ThinWebView { class ThinWebView : public content::WebContentsObserver {
public: public:
ThinWebView(JNIEnv* env, ThinWebView(JNIEnv* env,
jobject obj, jobject obj,
CompositorView* compositor_view, CompositorView* compositor_view,
ui::WindowAndroid* window_android); ui::WindowAndroid* window_android);
~ThinWebView(); ~ThinWebView() override;
void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& object); void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& object);
...@@ -44,6 +45,9 @@ class ThinWebView { ...@@ -44,6 +45,9 @@ class ThinWebView {
jint height); jint height);
private: private:
// content::WebContentsObserver overrides:
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
void SetWebContents( void SetWebContents(
content::WebContents* web_contents, content::WebContents* web_contents,
web_contents_delegate_android::WebContentsDelegateAndroid* delegate); web_contents_delegate_android::WebContentsDelegateAndroid* delegate);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment