| Index: chrome/browser/automation/automation_provider_observers.cc
|
| diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
|
| index 26125f7859e9f6aeb71af499c2a694a7b1a0e789..c5af5bf17f229a4b9de38abd8f1e7f18987205b3 100644
|
| --- a/chrome/browser/automation/automation_provider_observers.cc
|
| +++ b/chrome/browser/automation/automation_provider_observers.cc
|
| @@ -575,7 +575,27 @@ ExtensionReadyNotificationObserver::ExtensionReadyNotificationObserver(
|
| automation_(automation->AsWeakPtr()),
|
| id_(id),
|
| reply_message_(reply_message),
|
| + use_json_(false),
|
| extension_(NULL) {
|
| + Init();
|
| +}
|
| +
|
| +ExtensionReadyNotificationObserver::ExtensionReadyNotificationObserver(
|
| + ExtensionProcessManager* manager, ExtensionService* service,
|
| + AutomationProvider* automation, IPC::Message* reply_message)
|
| + : manager_(manager),
|
| + service_(service),
|
| + automation_(automation->AsWeakPtr()),
|
| + reply_message_(reply_message),
|
| + use_json_(true),
|
| + extension_(NULL) {
|
| + Init();
|
| +}
|
| +
|
| +ExtensionReadyNotificationObserver::~ExtensionReadyNotificationObserver() {
|
| +}
|
| +
|
| +void ExtensionReadyNotificationObserver::Init() {
|
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
|
| content::NotificationService::AllSources());
|
| registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
|
| @@ -588,9 +608,6 @@ ExtensionReadyNotificationObserver::ExtensionReadyNotificationObserver(
|
| content::NotificationService::AllSources());
|
| }
|
|
|
| -ExtensionReadyNotificationObserver::~ExtensionReadyNotificationObserver() {
|
| -}
|
| -
|
| void ExtensionReadyNotificationObserver::Observe(
|
| int type, const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
| @@ -606,8 +623,13 @@ void ExtensionReadyNotificationObserver::Observe(
|
| if (!extension_ || !DidExtensionHostsStopLoading(manager_))
|
| return;
|
| break;
|
| - case chrome::NOTIFICATION_EXTENSION_LOADED:
|
| - extension_ = content::Details<const Extension>(details).ptr();
|
| + case chrome::NOTIFICATION_EXTENSION_LOADED: {
|
| + const Extension* loaded_extension =
|
| + content::Details<const Extension>(details).ptr();
|
| + // Only track internal extension loads.
|
| + if (loaded_extension->location() != Extension::INTERNAL)
|
| + return;
|
| + extension_ = loaded_extension;
|
| if (!DidExtensionHostsStopLoading(manager_))
|
| return;
|
| // For some reason, the background ExtensionHost is not yet
|
| @@ -617,6 +639,7 @@ void ExtensionReadyNotificationObserver::Observe(
|
| if (!service_->IsBackgroundPageReady(extension_))
|
| return;
|
| break;
|
| + }
|
| case chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR:
|
| case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR:
|
| case chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED:
|
| @@ -626,21 +649,27 @@ void ExtensionReadyNotificationObserver::Observe(
|
| break;
|
| }
|
|
|
| - if (id_ == AutomationMsg_InstallExtension::ID) {
|
| - // A handle of zero indicates an error.
|
| - int extension_handle = 0;
|
| - if (extension_)
|
| - extension_handle = automation_->AddExtension(extension_);
|
| - AutomationMsg_InstallExtension::WriteReplyParams(
|
| - reply_message_.get(), extension_handle);
|
| - } else if (id_ == AutomationMsg_EnableExtension::ID) {
|
| - AutomationMsg_EnableExtension::WriteReplyParams(reply_message_.get(), true);
|
| + if (use_json_) {
|
| + DictionaryValue dict;
|
| + dict.SetString("id", extension_->id());
|
| + AutomationJSONReply(automation_, reply_message_.release())
|
| + .SendSuccess(&dict);
|
| } else {
|
| - NOTREACHED();
|
| - LOG(ERROR) << "Cannot write reply params for unknown message id.";
|
| + if (id_ == AutomationMsg_InstallExtension::ID) {
|
| + // A handle of zero indicates an error.
|
| + int extension_handle = 0;
|
| + if (extension_)
|
| + extension_handle = automation_->AddExtension(extension_);
|
| + AutomationMsg_InstallExtension::WriteReplyParams(
|
| + reply_message_.get(), extension_handle);
|
| + } else if (id_ == AutomationMsg_EnableExtension::ID) {
|
| + AutomationMsg_EnableExtension::WriteReplyParams(
|
| + reply_message_.get(), true);
|
| + } else {
|
| + LOG(ERROR) << "Cannot write reply params for unknown message id.";
|
| + }
|
| + automation_->Send(reply_message_.release());
|
| }
|
| -
|
| - automation_->Send(reply_message_.release());
|
| delete this;
|
| }
|
|
|
|
|