diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-03 18:28:36 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-03 18:28:36 +0000 |
commit | d79e3ab0a375657890bbcdf13aa7f22014ab5f22 (patch) | |
tree | f5afb61c83e06025f52576d3927f10762d788396 /chrome/browser/extensions/extension_message_service.cc | |
parent | babfb240d76d87c726fb20e4153bba958d7e4f8c (diff) | |
download | chromium_src-d79e3ab0a375657890bbcdf13aa7f22014ab5f22.zip chromium_src-d79e3ab0a375657890bbcdf13aa7f22014ab5f22.tar.gz chromium_src-d79e3ab0a375657890bbcdf13aa7f22014ab5f22.tar.bz2 |
Fix some issues with extension messaging for transient pages.
- Calling sendResponse within an onMessage listener no longer throws an error.
- Sending a message to a transient page that is only partially loaded no longer
fails.
BUG=120531
TEST=no
Review URL: https://chromiumcodereview.appspot.com/9968068
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_message_service.cc')
-rw-r--r-- | chrome/browser/extensions/extension_message_service.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc index e8ac077..0465810 100644 --- a/chrome/browser/extensions/extension_message_service.cc +++ b/chrome/browser/extensions/extension_message_service.cc @@ -210,9 +210,10 @@ void ExtensionMessageService::OpenChannelToExtension( source_extension_id, target_extension_id, channel_name); - // If the target process doesn't exist, it might be a lazy background page. - // In that case, queue up the task and load the page. - if (!receiver.process && MaybeAddPendingOpenChannelTask(profile, params)) + // The target might be a lazy background page. In that case, we have to check + // if it is loaded and ready, and if not, queue up the task and load the + // page. + if (MaybeAddPendingOpenChannelTask(profile, params)) return; OpenChannelImpl(params); @@ -422,12 +423,15 @@ bool ExtensionMessageService::MaybeAddPendingOpenChannelTask( // will use. if (!extension->incognito_split_mode()) profile = profile->GetOriginalProfile(); - lazy_background_task_queue_->AddPendingTask(profile, extension_id, - base::Bind(&ExtensionMessageService::PendingOpenChannel, - base::Unretained(this), params, params.source->GetID())); - pending_channels_[GET_CHANNEL_ID(params.receiver_port_id)] = - PendingChannel(profile, extension_id); - return true; + + if (lazy_background_task_queue_->ShouldEnqueueTask(profile, extension)) { + lazy_background_task_queue_->AddPendingTask(profile, extension_id, + base::Bind(&ExtensionMessageService::PendingOpenChannel, + base::Unretained(this), params, params.source->GetID())); + pending_channels_[GET_CHANNEL_ID(params.receiver_port_id)] = + PendingChannel(profile, extension_id); + return true; + } } return false; |