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

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

Issue 174277: override chrome:// URLs via extensions. (Closed)
Patch Set: fix linux errors Created 11 years, 4 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 bc03f8f2b6f652090db9bf0957d85be1bb189d83..60aa0d3a1e8a4c72457dbaae2a500cb5ddf84a56 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -174,7 +174,13 @@ void ExtensionHost::DidStopLoading(RenderViewHost* render_view_host) {
}
#endif
- did_stop_loading_ = true;
+ if (!did_stop_loading_) {
+ NotificationService::current()->Notify(
+ NotificationType::EXTENSION_HOST_DID_STOP_LOADING,
+ Source<Profile>(profile_),
+ Details<ExtensionHost>(this));
+ did_stop_loading_ = true;
+ }
}
void ExtensionHost::DocumentAvailableInMainFrame(RenderViewHost* rvh) {
@@ -303,8 +309,18 @@ Browser* ExtensionHost::GetBrowser() {
if (view_.get())
return view_->browser();
#endif
- Browser* browser = BrowserList::GetLastActiveWithProfile(
- render_view_host()->process()->profile());
+ Profile* profile = render_view_host()->process()->profile();
+ Browser* browser = BrowserList::GetLastActiveWithProfile(profile);
+
+ // It's possible for a browser to exist, but to have never been active.
+ // This can happen if you launch the browser on a machine without an active
+ // desktop (a headless buildbot) or if you quickly give another app focus
+ // at launch time. This is easy to do with browser_tests.
+ if (!browser)
+ browser = BrowserList::FindBrowserWithProfile(profile);
+
+ // TODO(erikkay): can this still return NULL? Is Rafael's comment still
+ // valid here?
// 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.
« no previous file with comments | « chrome/browser/extensions/extension_dom_ui.cc ('k') | chrome/browser/extensions/extension_override_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698