Index: chrome/browser/extensions/api/image_writer_private/operation_manager.cc |
diff --git a/chrome/browser/extensions/api/image_writer_private/operation_manager.cc b/chrome/browser/extensions/api/image_writer_private/operation_manager.cc |
index fa99aff852dc1025831d45615e062db8e9948054..89fa7928d7993426cbd7b1c35c12b062505a0f77 100644 |
--- a/chrome/browser/extensions/api/image_writer_private/operation_manager.cc |
+++ b/chrome/browser/extensions/api/image_writer_private/operation_manager.cc |
@@ -18,6 +18,7 @@ |
#include "content/public/browser/notification_service.h" |
#include "extensions/browser/event_router.h" |
#include "extensions/browser/extension_host.h" |
+#include "extensions/browser/extension_registry.h" |
namespace image_writer_api = extensions::api::image_writer_private; |
@@ -27,17 +28,23 @@ namespace image_writer { |
using content::BrowserThread; |
OperationManager::OperationManager(content::BrowserContext* context) |
- : profile_(Profile::FromBrowserContext(context)), weak_factory_(this) { |
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
- content::Source<Profile>(profile_)); |
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
- content::Source<Profile>(profile_)); |
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
- content::Source<Profile>(profile_)); |
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
- content::Source<Profile>(profile_)); |
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
- content::Source<Profile>(profile_)); |
+ : browser_context_(context), |
+ extension_registry_observer_(this), |
+ weak_factory_(this) { |
+ extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_)); |
+ Profile* profile = Profile::FromBrowserContext(browser_context_); |
+ registrar_.Add(this, |
+ chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
+ content::Source<Profile>(profile)); |
+ registrar_.Add(this, |
+ chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
+ content::Source<Profile>(profile)); |
+ registrar_.Add(this, |
+ chrome::NOTIFICATION_EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
+ content::Source<Profile>(profile)); |
+ registrar_.Add(this, |
+ chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
+ content::Source<Profile>(profile)); |
} |
OperationManager::~OperationManager() { |
@@ -69,7 +76,7 @@ void OperationManager::StartWriteFromUrl( |
scoped_refptr<Operation> operation( |
new WriteFromUrlOperation(weak_factory_.GetWeakPtr(), |
extension_id, |
- profile_->GetRequestContext(), |
+ browser_context_->GetRequestContext(), |
url, |
hash, |
device_path)); |
@@ -149,7 +156,7 @@ void OperationManager::OnProgress(const ExtensionId& extension_id, |
scoped_ptr<Event> event(new Event( |
image_writer_api::OnWriteProgress::kEventName, args.Pass())); |
- EventRouter::Get(profile_) |
+ EventRouter::Get(browser_context_) |
->DispatchEventToExtension(extension_id, event.Pass()); |
} |
@@ -160,7 +167,7 @@ void OperationManager::OnComplete(const ExtensionId& extension_id) { |
scoped_ptr<Event> event(new Event( |
image_writer_api::OnWriteComplete::kEventName, args.Pass())); |
- EventRouter::Get(profile_) |
+ EventRouter::Get(browser_context_) |
->DispatchEventToExtension(extension_id, event.Pass()); |
DeleteOperation(extension_id); |
@@ -183,7 +190,7 @@ void OperationManager::OnError(const ExtensionId& extension_id, |
scoped_ptr<Event> event(new Event( |
image_writer_api::OnWriteError::kEventName, args.Pass())); |
- EventRouter::Get(profile_) |
+ EventRouter::Get(browser_context_) |
->DispatchEventToExtension(extension_id, event.Pass()); |
DeleteOperation(extension_id); |
@@ -204,6 +211,13 @@ void OperationManager::DeleteOperation(const ExtensionId& extension_id) { |
} |
} |
+void OperationManager::OnExtensionUnloaded( |
+ content::BrowserContext* browser_context, |
+ const Extension* extension, |
+ UnloadedExtensionInfo::Reason reason) { |
+ DeleteOperation(extension->id()); |
+} |
+ |
void OperationManager::Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
@@ -212,10 +226,6 @@ void OperationManager::Observe(int type, |
DeleteOperation(content::Details<const Extension>(details).ptr()->id()); |
break; |
} |
not at google - send to devlin
2014/05/06 15:04:11
this case looks wrong to me, it should be covered
limasdf
2014/05/06 15:19:10
Done.
|
- case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
- DeleteOperation(content::Details<const Extension>(details).ptr()->id()); |
- break; |
- } |
case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { |
DeleteOperation(content::Details<const Extension>(details).ptr()->id()); |
break; |