content: Fix WebContentsUserData for usage across components.

1354402
This commit is contained in:
deepak1556 2019-01-21 22:26:54 +05:30
parent a864167d46
commit 9439ac108d
16 changed files with 48 additions and 15 deletions

View file

@ -577,18 +577,15 @@ const views::Widget* NativeWindow::GetWidget() const {
return widget();
}
// static
const void* const NativeWindowRelay::kNativeWindowRelayUserDataKey =
&NativeWindowRelay::kNativeWindowRelayUserDataKey;
// static
void NativeWindowRelay::CreateForWebContents(
content::WebContents* web_contents,
base::WeakPtr<NativeWindow> window) {
DCHECK(web_contents);
DCHECK(!web_contents->GetUserData(kNativeWindowRelayUserDataKey));
web_contents->SetUserData(kNativeWindowRelayUserDataKey,
base::WrapUnique(new NativeWindowRelay(window)));
if (!web_contents->GetUserData(UserDataKey())) {
web_contents->SetUserData(UserDataKey(),
base::WrapUnique(new NativeWindowRelay(window)));
}
}
NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window)
@ -596,4 +593,6 @@ NativeWindowRelay::NativeWindowRelay(base::WeakPtr<NativeWindow> window)
NativeWindowRelay::~NativeWindowRelay() = default;
WEB_CONTENTS_USER_DATA_KEY_IMPL(NativeWindowRelay)
} // namespace atom