Commit 96ea572a authored by Cicy Tan's avatar Cicy Tan Committed by Commit Bot

[Chromecast] Call CreateWindowForWebContents only once

If the method is called a second time, instead make a window priority
request.

Bug: internal 160358649
Test: on device
Change-Id: I6b38cafb3198a607136e54542f65c6f4df8b163b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2293419Reviewed-by: default avatarLuke Halliwell (slow) <halliwell@chromium.org>
Commit-Queue: Cicy Tan <shiyun@google.com>
Cr-Commit-Position: refs/heads/master@{#787432}
parent 1c231d0f
...@@ -77,6 +77,7 @@ CastContentWindowAndroid::CastContentWindowAndroid( ...@@ -77,6 +77,7 @@ CastContentWindowAndroid::CastContentWindowAndroid(
const CastContentWindow::CreateParams& params) const CastContentWindow::CreateParams& params)
: CastContentWindow(params), : CastContentWindow(params),
activity_id_(delegate_->GetId()), activity_id_(delegate_->GetId()),
web_contents_attached_(false),
java_window_(CreateJavaWindow(reinterpret_cast<jlong>(this), java_window_(CreateJavaWindow(reinterpret_cast<jlong>(this),
params.is_headless, params.is_headless,
params.enable_touch_input, params.enable_touch_input,
...@@ -94,6 +95,10 @@ void CastContentWindowAndroid::CreateWindowForWebContents( ...@@ -94,6 +95,10 @@ void CastContentWindowAndroid::CreateWindowForWebContents(
mojom::ZOrder /* z_order */, mojom::ZOrder /* z_order */,
VisibilityPriority visibility_priority) { VisibilityPriority visibility_priority) {
DCHECK(cast_web_contents); DCHECK(cast_web_contents);
if (web_contents_attached_) {
RequestVisibility(visibility_priority);
return;
}
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
base::android::ScopedJavaLocalRef<jobject> java_web_contents = base::android::ScopedJavaLocalRef<jobject> java_web_contents =
cast_web_contents->web_contents()->GetJavaWebContents(); cast_web_contents->web_contents()->GetJavaWebContents();
...@@ -101,6 +106,7 @@ void CastContentWindowAndroid::CreateWindowForWebContents( ...@@ -101,6 +106,7 @@ void CastContentWindowAndroid::CreateWindowForWebContents(
Java_CastContentWindowAndroid_createWindowForWebContents( Java_CastContentWindowAndroid_createWindowForWebContents(
env, java_window_, java_web_contents, env, java_window_, java_web_contents,
static_cast<int>(visibility_priority)); static_cast<int>(visibility_priority));
web_contents_attached_ = true;
} }
void CastContentWindowAndroid::GrantScreenAccess() { void CastContentWindowAndroid::GrantScreenAccess() {
......
...@@ -56,6 +56,7 @@ class CastContentWindowAndroid : public CastContentWindow { ...@@ -56,6 +56,7 @@ class CastContentWindowAndroid : public CastContentWindow {
private: private:
const std::string activity_id_; const std::string activity_id_;
bool web_contents_attached_;
base::android::ScopedJavaGlobalRef<jobject> java_window_; base::android::ScopedJavaGlobalRef<jobject> java_window_;
DISALLOW_COPY_AND_ASSIGN(CastContentWindowAndroid); DISALLOW_COPY_AND_ASSIGN(CastContentWindowAndroid);
......
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