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

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 119117: make extension apis tolerate browser absence during start-up & shutdown (Closed)
Patch Set: CR changes Created 11 years, 7 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
Index: chrome/browser/extensions/extension_host.cc
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 741c9fc79f253bec8f3b61d5f882eee7219d3af7..9509577a56223bdba2628ed67f776d8faad09e37 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -132,9 +132,13 @@ void ExtensionHost::ShowCreatedWindow(int route_id,
const GURL& creator_url) {
TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id);
if (contents) {
+ Browser* browser = GetBrowser();
+ DCHECK(browser);
+ if (!browser)
+ return;
// TODO(erikkay) is it safe to pass in NULL as source?
- GetBrowser()->AddTabContents(contents, disposition, initial_pos,
- user_gesture);
+ browser->AddTabContents(contents, disposition, initial_pos,
+ user_gesture);
}
}
@@ -142,7 +146,11 @@ void ExtensionHost::ShowCreatedWidget(int route_id,
const gfx::Rect& initial_pos) {
RenderWidgetHostView* widget_host_view =
delegate_view_helper_.GetCreatedWidget(route_id);
- GetBrowser()->BrowserRenderWidgetShowing();
+ Browser *browser = GetBrowser();
+ DCHECK(browser);
+ if (!browser)
+ return;
+ browser->BrowserRenderWidgetShowing();
// TODO(erikkay): These two lines could be refactored with TabContentsView.
widget_host_view->InitAsPopup(render_view_host()->view(), initial_pos);
widget_host_view->GetRenderWidgetHost()->Init();
@@ -186,8 +194,11 @@ Browser* ExtensionHost::GetBrowser() {
#endif
Browser* browser = BrowserList::GetLastActiveWithProfile(
render_view_host()->process()->profile());
- // TODO(mpcomplete): what this verifies doesn't actually happen yet.
- CHECK(browser) << "ExtensionHost running in Profile with no Browser active."
- " It should have been deleted.";
+ // NOTE(rafaelw): This can return NULL in some circumstances. In particular,
+ // a toolstrip or background_page onload chrome.tabs api call can make it
+ // into here before the browser is sufficiently initialized to return here.
+ // A similar situation may arise during shutdown.
+ // TODO(rafaelw): Delay creation of background_page until the browser
+ // is available. http://code.google.com/p/chromium/issues/detail?id=13284
return browser;
}
« no previous file with comments | « chrome/browser/extensions/extension_function_dispatcher.cc ('k') | chrome/browser/extensions/extension_tabs_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698