Skip to content

Commit

Permalink
[Chromecast] Call CreateWindowForWebContents only once
Browse files Browse the repository at this point in the history
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/+/2293419
Reviewed-by: Luke Halliwell (slow) <halliwell@chromium.org>
Commit-Queue: Cicy Tan <shiyun@google.com>
Cr-Commit-Position: refs/heads/master@{#787432}
  • Loading branch information
shiyun-g authored and Commit Bot committed Jul 10, 2020
1 parent 1c231d0 commit 96ea572
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions chromecast/browser/android/cast_content_window_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ CastContentWindowAndroid::CastContentWindowAndroid(
const CastContentWindow::CreateParams& params)
: CastContentWindow(params),
activity_id_(delegate_->GetId()),
web_contents_attached_(false),
java_window_(CreateJavaWindow(reinterpret_cast<jlong>(this),
params.is_headless,
params.enable_touch_input,
Expand All @@ -94,13 +95,18 @@ void CastContentWindowAndroid::CreateWindowForWebContents(
mojom::ZOrder /* z_order */,
VisibilityPriority visibility_priority) {
DCHECK(cast_web_contents);
if (web_contents_attached_) {
RequestVisibility(visibility_priority);
return;
}
JNIEnv* env = base::android::AttachCurrentThread();
base::android::ScopedJavaLocalRef<jobject> java_web_contents =
cast_web_contents->web_contents()->GetJavaWebContents();

Java_CastContentWindowAndroid_createWindowForWebContents(
env, java_window_, java_web_contents,
static_cast<int>(visibility_priority));
web_contents_attached_ = true;
}

void CastContentWindowAndroid::GrantScreenAccess() {
Expand Down
1 change: 1 addition & 0 deletions chromecast/browser/android/cast_content_window_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CastContentWindowAndroid : public CastContentWindow {

private:
const std::string activity_id_;
bool web_contents_attached_;
base::android::ScopedJavaGlobalRef<jobject> java_window_;

DISALLOW_COPY_AND_ASSIGN(CastContentWindowAndroid);
Expand Down

0 comments on commit 96ea572

Please sign in to comment.