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

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

Issue 174226: Extension ports devtools remote service.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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/extension_message_service.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_message_service.cc
===================================================================
--- chrome/browser/extensions/extension_message_service.cc (revision 23787)
+++ chrome/browser/extensions/extension_message_service.cc (working copy)
@@ -225,9 +225,11 @@
MessagePort receiver(
profile_->GetExtensionProcessManager()->GetExtensionProcess(extension_id),
MSG_ROUTING_CONTROL);
- OpenChannelOnUIThreadImpl(source, source_process_id, source_routing_id,
- receiver, receiver_port_id, extension_id,
- channel_name);
+ TabContents* source_contents = tab_util::GetTabContentsByID(
+ source_process_id, source_routing_id);
+ OpenChannelOnUIThreadImpl(source, source_contents,
+ receiver, receiver_port_id,
+ extension_id, channel_name);
}
void ExtensionMessageService::OpenChannelToTabOnUIThread(
@@ -242,13 +244,15 @@
receiver.sender = contents->render_view_host();
receiver.routing_id = contents->render_view_host()->routing_id();
}
- OpenChannelOnUIThreadImpl(source, source_process_id, source_routing_id,
- receiver, receiver_port_id, extension_id,
- channel_name);
+ TabContents* source_contents = tab_util::GetTabContentsByID(
+ source_process_id, source_routing_id);
+ OpenChannelOnUIThreadImpl(source, source_contents,
+ receiver, receiver_port_id,
+ extension_id, channel_name);
}
bool ExtensionMessageService::OpenChannelOnUIThreadImpl(
- IPC::Message::Sender* source, int source_process_id, int source_routing_id,
+ IPC::Message::Sender* source, TabContents* source_contents,
const MessagePort& receiver, int receiver_port_id,
const std::string& extension_id, const std::string& channel_name) {
DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
@@ -280,10 +284,9 @@
// Include info about the opener's tab (if it was a tab).
std::string tab_json = "null";
- TabContents* contents = tab_util::GetTabContentsByID(source_process_id,
- source_routing_id);
- if (contents) {
- DictionaryValue* tab_value = ExtensionTabUtil::CreateTabValue(contents);
+ if (source_contents) {
+ DictionaryValue* tab_value =
+ ExtensionTabUtil::CreateTabValue(source_contents);
JSONWriter::Write(tab_value, false, &tab_json);
}
@@ -297,9 +300,9 @@
return true;
}
-int ExtensionMessageService::OpenAutomationChannelToExtension(
- int source_process_id, int routing_id, const std::string& extension_id,
- const std::string& channel_name, IPC::Message::Sender* source) {
+int ExtensionMessageService::OpenSpecialChannelToExtension(
+ const std::string& extension_id, const std::string& channel_name,
+ IPC::Message::Sender* source) {
DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
DCHECK(profile_);
@@ -308,22 +311,39 @@
// Create a channel ID for both sides of the channel.
AllocatePortIdPair(&port1_id, &port2_id);
- // TODO(siggi): The source process- and routing ids are used to
- // describe the originating tab to the target extension.
- // This isn't really appropriate here, the originating tab
- // information should be supplied by the caller for
- // automation-initiated ports.
MessagePort receiver(
- profile_->GetExtensionProcessManager()->GetExtensionProcess(extension_id),
+ profile_->GetExtensionProcessManager()->
+ GetExtensionProcess(extension_id),
MSG_ROUTING_CONTROL);
- if (!OpenChannelOnUIThreadImpl(source, source_process_id, routing_id,
- receiver, port2_id, extension_id,
- channel_name))
+ if (!OpenChannelOnUIThreadImpl(
+ source, NULL, receiver, port2_id, extension_id, channel_name))
return -1;
return port1_id;
}
+int ExtensionMessageService::OpenSpecialChannelToTab(
+ const std::string& extension_id, const std::string& channel_name,
+ TabContents* target_tab_contents, IPC::Message::Sender* source) {
+ DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
+ DCHECK(target_tab_contents);
+
+ int port1_id = -1;
+ int port2_id = -1;
+ // Create a channel ID for both sides of the channel.
+ AllocatePortIdPair(&port1_id, &port2_id);
+
+ MessagePort receiver(
+ target_tab_contents->render_view_host(),
+ target_tab_contents->render_view_host()->routing_id());
+ if (!OpenChannelOnUIThreadImpl(source, NULL,
+ receiver, port2_id,
+ extension_id, channel_name))
+ return -1;
+
+ return port1_id;
+}
+
void ExtensionMessageService::CloseChannel(int port_id) {
DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI);
« no previous file with comments | « chrome/browser/extensions/extension_message_service.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698