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

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

Issue 2037873002: [Extensions] Observe unloading extensions in the TabHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Istiaque's Created 4 years, 6 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 | « chrome/browser/extensions/tab_helper.h ('k') | chrome/browser/extensions/tab_helper_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/tab_helper.cc
diff --git a/chrome/browser/extensions/tab_helper.cc b/chrome/browser/extensions/tab_helper.cc
index 67fd240c883c4dd761db88f9da40670cdf557817..bc92af0b88af50c8d971f4b81f97573ccb8a3a08 100644
--- a/chrome/browser/extensions/tab_helper.cc
+++ b/chrome/browser/extensions/tab_helper.cc
@@ -84,6 +84,7 @@ TabHelper::TabHelper(content::WebContents* web_contents)
location_bar_controller_(new LocationBarController(web_contents)),
extension_action_runner_(new ExtensionActionRunner(web_contents)),
webstore_inline_installer_factory_(new WebstoreInlineInstallerFactory()),
+ registry_observer_(this),
image_loader_ptr_factory_(this),
weak_ptr_factory_(this) {
// The ActiveTabPermissionManager requires a session ID; ensure this
@@ -169,6 +170,13 @@ void TabHelper::SetExtensionApp(const Extension* extension) {
extension_app_ = extension;
+ if (extension_app_) {
+ registry_observer_.Add(
+ ExtensionRegistry::Get(web_contents()->GetBrowserContext()));
+ } else {
+ registry_observer_.RemoveAll();
+ }
+
UpdateExtensionAppIcon(extension_app_);
content::NotificationService::current()->Notify(
@@ -532,6 +540,15 @@ WebContents* TabHelper::GetAssociatedWebContents() const {
return web_contents();
}
+void TabHelper::OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) {
+ DCHECK(extension_app_);
+ if (extension == extension_app_)
+ SetExtensionApp(nullptr);
+}
+
void TabHelper::GetApplicationInfo(WebAppAction action) {
NavigationEntry* entry =
web_contents()->GetController().GetLastCommittedEntry();
« no previous file with comments | « chrome/browser/extensions/tab_helper.h ('k') | chrome/browser/extensions/tab_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698