Commit 26d14ef5 authored by Yilkal Abe's avatar Yilkal Abe Committed by Commit Bot

Revert "Only use SupervisedUserNavigationObserver for child accounts."

 
This reverts commit 79024af7.

Reason for revert: This revert is required because there are scenarios where the profile becomes supervised user after the navigation observer is supposed to be created. i.e. When SupervisedUserNaivgationObserver::MaybeCreateForWebContents is called the user profile is not marked as supervised hence the navigation observer is not created. This resulted in the crashes reported in the bug below.

Bug: 1061427

Original change's description:
> Only use SupervisedUserNavigationObserver for child accounts.
> 
> This CL makes sure that SupervisedUserNavigationObserver is
> created only for supervised user accounts. This saves memory
> and processing time.
> 
> Bug: 1043232
> Change-Id: I5d13ce0261d07c29384f5ba5dc83e420ed3138dd
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008315
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Dan S <danan@chromium.org>
> Commit-Queue: Yilkal Abe <yilkal@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#733750}

TBR=sky@chromium.org,danan@chromium.org,yilkal@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1043232
Change-Id: I1767afe66b32f34736af2497793d59f598cb61b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102764Reviewed-by: default avatarYilkal Abe <yilkal@chromium.org>
Commit-Queue: Yilkal Abe <yilkal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750225}
parent fe6a9ed3
...@@ -39,22 +39,6 @@ bool IsMainFrame(content::RenderFrameHost* render_frame_host) { ...@@ -39,22 +39,6 @@ bool IsMainFrame(content::RenderFrameHost* render_frame_host) {
using content::NavigationEntry; using content::NavigationEntry;
// static
void SupervisedUserNavigationObserver::MaybeCreateForWebContents(
content::WebContents* web_contents) {
DCHECK(web_contents);
Profile* user_profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
if (!user_profile->IsSupervised())
return;
if (!FromWebContents(web_contents)) {
web_contents->SetUserData(
UserDataKey(),
base::WrapUnique(new SupervisedUserNavigationObserver(web_contents)));
}
}
SupervisedUserNavigationObserver::~SupervisedUserNavigationObserver() { SupervisedUserNavigationObserver::~SupervisedUserNavigationObserver() {
supervised_user_service_->RemoveObserver(this); supervised_user_service_->RemoveObserver(this);
} }
......
...@@ -40,10 +40,6 @@ class SupervisedUserNavigationObserver ...@@ -40,10 +40,6 @@ class SupervisedUserNavigationObserver
public SupervisedUserServiceObserver, public SupervisedUserServiceObserver,
public supervised_user::mojom::SupervisedUserCommands { public supervised_user::mojom::SupervisedUserCommands {
public: public:
// Creates SupervisedUserNavigationObserver if the profile is a child user.
static void MaybeCreateForWebContents(content::WebContents* web_contents);
static void CreateForWebContents(content::WebContents* web_contents) = delete;
~SupervisedUserNavigationObserver() override; ~SupervisedUserNavigationObserver() override;
const std::vector<std::unique_ptr<const sessions::SerializedNavigationEntry>>& const std::vector<std::unique_ptr<const sessions::SerializedNavigationEntry>>&
......
...@@ -427,7 +427,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) { ...@@ -427,7 +427,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
#endif #endif
#if BUILDFLAG(ENABLE_SUPERVISED_USERS) #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
SupervisedUserNavigationObserver::MaybeCreateForWebContents(web_contents); SupervisedUserNavigationObserver::CreateForWebContents(web_contents);
#endif #endif
// --- Section 4: The warning --- // --- Section 4: The warning ---
......
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