Commit 65559050 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

weblayer: minor cleanup of TabImpl::UserData

This needs to handle the case of a WebContents that isn't associated
with a Tab. This also renames |controller| to |tab|, which better
reflects the type.

BUG=none
TEST=none

Change-Id: Idbf58316d3223e00e28f2d7c675e125c30ecaecf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210499Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770730}
parent eeb9431b
......@@ -151,7 +151,7 @@ void OpenCaptivePortalLoginTabInWebContents(
constexpr int kWebContentsUserDataKey = 0;
struct UserData : public base::SupportsUserData::Data {
TabImpl* controller = nullptr;
TabImpl* tab = nullptr;
};
#if defined(OS_ANDROID)
......@@ -249,7 +249,7 @@ TabImpl::TabImpl(ProfileImpl* profile,
&TabImpl::UpdateRendererPrefs, base::Unretained(this), true));
std::unique_ptr<UserData> user_data = std::make_unique<UserData>();
user_data->controller = this;
user_data->tab = this;
web_contents_->SetUserData(&kWebContentsUserDataKey, std::move(user_data));
web_contents_->SetDelegate(this);
......@@ -325,9 +325,9 @@ TabImpl* TabImpl::FromWebContents(content::WebContents* web_contents) {
if (!web_contents)
return nullptr;
return reinterpret_cast<UserData*>(
web_contents->GetUserData(&kWebContentsUserDataKey))
->controller;
UserData* user_data = reinterpret_cast<UserData*>(
web_contents->GetUserData(&kWebContentsUserDataKey));
return user_data ? user_data->tab : nullptr;
}
void TabImpl::AddDataObserver(DataObserver* observer) {
......
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