Commit f635948b authored by yilkal's avatar yilkal Committed by Commit Bot

Check SupervisedUserNavigationObserver exists before dereferencing.

This CL makes minor changes to check if the absence of
SupervisedUserNavigationObserver is the cause of crash in android
chrome in TabContentsSyncedTabDelegate::ShouldSync.

Bug: 1048643
Change-Id: I8cdb18b30ba42ba781b09d0ba455fc8c26d101f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2079004
Commit-Queue: Yilkal Abe <yilkal@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745547}
parent 980fd551
......@@ -130,7 +130,11 @@ TabContentsSyncedTabDelegate::GetBlockedNavigations() const {
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
SupervisedUserNavigationObserver* navigation_observer =
SupervisedUserNavigationObserver::FromWebContents(web_contents_);
DCHECK(navigation_observer);
// TODO(1048643) The check on |navigation_observer| should be a DCHECK.
if (!navigation_observer)
return nullptr;
return &navigation_observer->blocked_navigations();
#else
NOTREACHED();
......@@ -144,9 +148,15 @@ bool TabContentsSyncedTabDelegate::ShouldSync(
GetWindowId()) == nullptr)
return false;
// Is there a valid NavigationEntry?
if (ProfileIsSupervised() && !GetBlockedNavigations()->empty())
if (ProfileIsSupervised()) {
const auto* blocked_navigations = GetBlockedNavigations();
// TODO(1048643) If profile is supervised, |blocked_navigations| should not
// be nullptr. This is a work around to check if the crash reported in the
// bug was caused by the violation of the invariant.
if (blocked_navigations && !blocked_navigations->empty())
return true;
}
if (IsInitialBlankNavigation())
return false; // This deliberately ignores a new pending entry.
......
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