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

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

Issue 279073003: Add a function triggering extension installed to ExtensionRegistryObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/webstore_installer.cc
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
index 25ef1e838135de5053b85cdab684aa7c380a504f..044a8b10438e0a089a5176c97f23431b74bfd070 100644
--- a/chrome/browser/extensions/webstore_installer.cc
+++ b/chrome/browser/extensions/webstore_installer.cc
@@ -48,6 +48,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
@@ -286,6 +287,7 @@ WebstoreInstaller::WebstoreInstaller(Profile* profile,
scoped_ptr<Approval> approval,
InstallSource source)
: content::WebContentsObserver(web_contents),
+ extension_registry_observer_(this),
profile_(profile),
delegate_(delegate),
id_(id),
@@ -299,10 +301,9 @@ WebstoreInstaller::WebstoreInstaller(Profile* profile,
registrar_.Add(this, chrome::NOTIFICATION_CRX_INSTALLER_DONE,
content::NotificationService::AllSources());
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
- content::Source<Profile>(profile->GetOriginalProfile()));
registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR,
content::Source<CrxInstaller>(NULL));
+ extension_registry_observer_.Add(ExtensionRegistry::Get(profile));
}
void WebstoreInstaller::Start() {
@@ -384,40 +385,6 @@ void WebstoreInstaller::Observe(int type,
break;
}
- case chrome::NOTIFICATION_EXTENSION_INSTALLED: {
- CHECK(profile_->IsSameProfile(content::Source<Profile>(source).ptr()));
- const Extension* extension =
- content::Details<const InstalledExtensionInfo>(details)->extension;
- if (pending_modules_.empty())
- return;
- SharedModuleInfo::ImportInfo info = pending_modules_.front();
- if (extension->id() != info.extension_id)
- return;
- pending_modules_.pop_front();
-
- if (pending_modules_.empty()) {
- CHECK_EQ(extension->id(), id_);
- ReportSuccess();
- } else {
- const Version version_required(info.minimum_version);
- if (version_required.IsValid() &&
- extension->version()->CompareTo(version_required) < 0) {
- // It should not happen, CrxInstaller will make sure the version is
- // equal or newer than version_required.
- ReportFailure(kDependencyNotFoundError,
- FAILURE_REASON_DEPENDENCY_NOT_FOUND);
- } else if (!SharedModuleInfo::IsSharedModule(extension)) {
- // It should not happen, CrxInstaller will make sure it is a shared
- // module.
- ReportFailure(kDependencyNotSharedModuleError,
- FAILURE_REASON_DEPENDENCY_NOT_SHARED_MODULE);
- } else {
- DownloadNextPendingModule();
- }
- }
- break;
- }
-
case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR: {
CrxInstaller* crx_installer = content::Source<CrxInstaller>(source).ptr();
CHECK(crx_installer);
@@ -441,6 +408,40 @@ void WebstoreInstaller::Observe(int type,
}
}
+void WebstoreInstaller::OnExtensionInstalled(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ InstalledExtensionInfo info) {
+ CHECK(profile_->IsSameProfile(Profile::FromBrowserContext(browser_context)));
+ if (pending_modules_.empty())
+ return;
+ SharedModuleInfo::ImportInfo import_info = pending_modules_.front();
+ if (extension->id() != import_info.extension_id)
+ return;
+ pending_modules_.pop_front();
+
+ if (pending_modules_.empty()) {
+ CHECK_EQ(extension->id(), id_);
+ ReportSuccess();
+ } else {
+ const Version version_required(import_info.minimum_version);
+ if (version_required.IsValid() &&
+ extension->version()->CompareTo(version_required) < 0) {
+ // It should not happen, CrxInstaller will make sure the version is
+ // equal or newer than version_required.
+ ReportFailure(kDependencyNotFoundError,
+ FAILURE_REASON_DEPENDENCY_NOT_FOUND);
+ } else if (!SharedModuleInfo::IsSharedModule(extension)) {
+ // It should not happen, CrxInstaller will make sure it is a shared
+ // module.
+ ReportFailure(kDependencyNotSharedModuleError,
+ FAILURE_REASON_DEPENDENCY_NOT_SHARED_MODULE);
+ } else {
+ DownloadNextPendingModule();
+ }
+ }
+}
+
void WebstoreInstaller::InvalidateDelegate() {
delegate_ = NULL;
}

Powered by Google App Engine
This is Rietveld 408576698