Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: chrome/browser/ui/omnibox/omnibox_navigation_observer.cc

Issue 865313002: Prevent a possible crash on omnibox navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/omnibox/omnibox_navigation_observer.cc
diff --git a/chrome/browser/ui/omnibox/omnibox_navigation_observer.cc b/chrome/browser/ui/omnibox/omnibox_navigation_observer.cc
index 040dbdefa2cfcd57bace95ae91c9f25a2bc92c59..b8afea78c4aa52205699a0c5acf358f6c5a4e990 100644
--- a/chrome/browser/ui/omnibox/omnibox_navigation_observer.cc
+++ b/chrome/browser/ui/omnibox/omnibox_navigation_observer.cc
@@ -86,15 +86,27 @@ void OmniboxNavigationObserver::Observe(
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_PENDING, type);
- registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
- content::NotificationService::AllSources());
+
+ // It's possible for an attempted omnibox navigation to cause the extensions
+ // system to synchronously navigate an extension background page. Not only is
+ // this navigation not the one we want to observe, the associated WebContents
+ // is invisible and has no InfoBarService, so trying to show an infobar in it
+ // later will crash. Just ignore this navigation and keep listening.
content::NavigationController* controller =
content::Source<content::NavigationController>(source).ptr();
+ content::WebContents* web_contents = controller->GetWebContents();
+ if (!InfoBarService::FromWebContents(web_contents))
Vitaly Buka (NO REVIEWS) 2015/01/22 21:59:09 Using InfoBarservice for unwanted web-contents loo
Peter Kasting 2015/01/22 22:02:26 There's no theoretical reason why an extension bac
+ return;
+
+ CHECK_EQ(match_.destination_url,
+ content::Details<content::NavigationEntry>(details)->GetURL());
+ registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
+ content::NotificationService::AllSources());
if (fetcher_) {
fetcher_->SetRequestContext(
controller->GetBrowserContext()->GetRequestContext());
}
- WebContentsObserver::Observe(controller->GetWebContents());
+ WebContentsObserver::Observe(web_contents);
// DidStartNavigationToPendingEntry() will be called for this load as well.
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698