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

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: fix null pointer deref Created 6 years, 10 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 248111)
+++ chrome/browser/extensions/api/messaging/message_service.cc (working copy)
@@ -16,6 +16,7 @@
#include "chrome/browser/extensions/api/messaging/extension_message_port.h"
#include "chrome/browser/extensions/api/messaging/incognito_connectability.h"
#include "chrome/browser/extensions/api/messaging/native_message_port.h"
+#include "chrome/browser/extensions/api/tabs/tabs_constants.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
@@ -119,14 +120,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 +148,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;
@@ -300,9 +296,10 @@
GURL source_url_for_tab;
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));
+ // 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;
}
@@ -323,7 +320,9 @@
if (include_tls_channel_id) {
pending_tls_channel_id_channels_[GET_CHANNEL_ID(params->receiver_port_id)]
= PendingMessagesQueue();
- property_provider_.GetDomainBoundCert(profile, params->source_url,
+ property_provider_.GetDomainBoundCert(
+ profile,
+ source_url,
base::Bind(&MessageService::GotDomainBoundCert,
weak_factory_.GetWeakPtr(),
base::Passed(make_scoped_ptr(params))));
@@ -551,8 +550,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