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

Unified Diff: chrome/browser/extensions/api/messaging/message_service.cc

Issue 145463002: Extensions: Send the tab id to platform apps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 11 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/api/messaging/message_service.cc
===================================================================
--- chrome/browser/extensions/api/messaging/message_service.cc (revision 246091)
+++ chrome/browser/extensions/api/messaging/message_service.cc (working copy)
@@ -119,14 +119,9 @@
static content::RenderProcessHost* GetExtensionProcess(
Profile* profile, const std::string& extension_id) {
SiteInstance* site_instance =
- ExtensionSystem::Get(profile)->process_manager()->
- GetSiteInstanceForURL(
- Extension::GetBaseURLFromExtensionId(extension_id));
-
- if (!site_instance->HasProcess())
- return NULL;
-
- return site_instance->GetProcess();
+ ExtensionSystem::Get(profile)->process_manager()->GetSiteInstanceForURL(
+ Extension::GetBaseURLFromExtensionId(extension_id));
+ return site_instance->HasProcess() ? site_instance->GetProcess() : NULL;
}
} // namespace
@@ -152,12 +147,12 @@
// Sanity checks to make sure our channel<->port converters are correct.
DCHECK(IS_OPENER_PORT_ID(port1_id));
- DCHECK(GET_OPPOSITE_PORT_ID(port1_id) == port2_id);
- DCHECK(GET_OPPOSITE_PORT_ID(port2_id) == port1_id);
- DCHECK(GET_CHANNEL_ID(port1_id) == GET_CHANNEL_ID(port2_id));
- DCHECK(GET_CHANNEL_ID(port1_id) == channel_id);
- DCHECK(GET_CHANNEL_OPENER_ID(channel_id) == port1_id);
- DCHECK(GET_CHANNEL_RECEIVERS_ID(channel_id) == port2_id);
+ DCHECK_EQ(GET_OPPOSITE_PORT_ID(port1_id), port2_id);
+ DCHECK_EQ(GET_OPPOSITE_PORT_ID(port2_id), port1_id);
+ DCHECK_EQ(GET_CHANNEL_ID(port1_id), GET_CHANNEL_ID(port2_id));
+ DCHECK_EQ(GET_CHANNEL_ID(port1_id), channel_id);
+ DCHECK_EQ(GET_CHANNEL_OPENER_ID(channel_id), port1_id);
+ DCHECK_EQ(GET_CHANNEL_RECEIVERS_ID(channel_id), port2_id);
*port1 = port1_id;
*port2 = port2_id;
@@ -303,10 +298,12 @@
if (source_contents && ExtensionTabUtil::GetTabId(source_contents) >= 0) {
// Platform apps can be sent messages, but don't have a Tab concept.
- if (!target_extension->is_platform_app())
- source_tab.reset(ExtensionTabUtil::CreateTabValue(source_contents));
- source_url_for_tab = source_url;
+ // Only the tab id is useful to platform apps for internal use. The
+ // unnecessary bits will be stripped out in
+ // MessagingBindings::DispatchOnConnect().
+ source_tab.reset(ExtensionTabUtil::CreateTabValue(source_contents));
}
+ source_url_for_tab = source_url;
not at google - send to devlin 2014/01/24 21:37:27 I don't think this source_url_for_tab is necessary
Lei Zhang 2014/01/25 01:47:09 Under |kUrlKey| right? I removed |source_url_for_t
not at google - send to devlin 2014/01/27 17:51:46 Actually not quite what I meant but what you did i
Lei Zhang 2014/01/27 23:19:13 Yes, I noticed the rabbit hole is quite deep and I
OpenChannelParams* params = new OpenChannelParams(source,
source_tab.Pass(),
@@ -549,8 +546,7 @@
channels_.erase(channel_iter);
}
-void MessageService::PostMessage(
- int source_port_id, const Message& message) {
+void MessageService::PostMessage(int source_port_id, const Message& message) {
int channel_id = GET_CHANNEL_ID(source_port_id);
MessageChannelMap::iterator iter = channels_.find(channel_id);
if (iter == channels_.end()) {

Powered by Google App Engine
This is Rietveld 408576698