summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 08:40:49 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 08:40:49 +0000
commitd725947e8a370c790794a66fd36d349b7b33b8b8 (patch)
treea4e71071b7efee3341da93b451989b95ba8f8920 /chrome/browser
parentc83658c33bdf286c7d4cf8f766616e297624daec (diff)
downloadchromium_src-d725947e8a370c790794a66fd36d349b7b33b8b8.zip
chromium_src-d725947e8a370c790794a66fd36d349b7b33b8b8.tar.gz
chromium_src-d725947e8a370c790794a66fd36d349b7b33b8b8.tar.bz2
Enforce extension permissions in C++ (instead of Javascript).
BUG=38920 TEST=ExtensionApiTest.Incognito Review URL: http://codereview.chromium.org/1148009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42441 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/extension_port_container.cc4
-rw-r--r--chrome/browser/automation/extension_port_container.h3
-rw-r--r--chrome/browser/debugger/extension_ports_remote_service.cc4
-rw-r--r--chrome/browser/debugger/extension_ports_remote_service.h5
-rw-r--r--chrome/browser/extensions/extension_message_service.cc17
-rw-r--r--chrome/browser/extensions/extension_messages_unittest.cc6
6 files changed, 22 insertions, 17 deletions
diff --git a/chrome/browser/automation/extension_port_container.cc b/chrome/browser/automation/extension_port_container.cc
index 1fd4b70..e167e7e 100644
--- a/chrome/browser/automation/extension_port_container.cc
+++ b/chrome/browser/automation/extension_port_container.cc
@@ -112,7 +112,9 @@ bool ExtensionPortContainer::Send(IPC::Message *message) {
}
void ExtensionPortContainer::OnExtensionMessageInvoke(
- const std::string& function_name, const ListValue& args) {
+ const std::string& function_name,
+ const ListValue& args,
+ bool requires_incognito_access) {
if (function_name == ExtensionMessageService::kDispatchOnMessage) {
DCHECK_EQ(args.GetSize(), 2u);
diff --git a/chrome/browser/automation/extension_port_container.h b/chrome/browser/automation/extension_port_container.h
index a9d61ef..b74709d 100644
--- a/chrome/browser/automation/extension_port_container.h
+++ b/chrome/browser/automation/extension_port_container.h
@@ -63,7 +63,8 @@ class ExtensionPortContainer : public IPC::Message::Sender {
void SendConnectionResponse(int connection_id, int port_id);
void OnExtensionMessageInvoke(const std::string& function_name,
- const ListValue& args);
+ const ListValue& args,
+ bool requires_incognito_access);
void OnExtensionHandleMessage(const std::string& message, int source_port_id);
void OnExtensionPortDisconnected(int source_port_id);
diff --git a/chrome/browser/debugger/extension_ports_remote_service.cc b/chrome/browser/debugger/extension_ports_remote_service.cc
index df549fd..c4380d5 100644
--- a/chrome/browser/debugger/extension_ports_remote_service.cc
+++ b/chrome/browser/debugger/extension_ports_remote_service.cc
@@ -241,7 +241,9 @@ bool ExtensionPortsRemoteService::Send(IPC::Message *message) {
}
void ExtensionPortsRemoteService::OnExtensionMessageInvoke(
- const std::string& function_name, const ListValue& args) {
+ const std::string& function_name,
+ const ListValue& args,
+ bool requires_incognito_access) {
if (function_name == ExtensionMessageService::kDispatchOnMessage) {
DCHECK_EQ(args.GetSize(), 2u);
std::string message;
diff --git a/chrome/browser/debugger/extension_ports_remote_service.h b/chrome/browser/debugger/extension_ports_remote_service.h
index 005905c..3a9e53b 100644
--- a/chrome/browser/debugger/extension_ports_remote_service.h
+++ b/chrome/browser/debugger/extension_ports_remote_service.h
@@ -73,8 +73,9 @@ class ExtensionPortsRemoteService : public DevToolsRemoteListener,
const std::string& destination);
// Handles a message from the ExtensionMessageService.
- void OnExtensionMessageInvoke(
- const std::string& function_name, const ListValue& args);
+ void OnExtensionMessageInvoke(const std::string& function_name,
+ const ListValue& args,
+ bool requires_incognito_access);
// Handles a message sent from an extension through the
// ExtensionMessageService, to be passed to the external client.
void OnExtensionMessage(const std::string& message, int port_id);
diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc
index 45b5304..2586151 100644
--- a/chrome/browser/extensions/extension_message_service.cc
+++ b/chrome/browser/extensions/extension_message_service.cc
@@ -69,16 +69,16 @@ static void DispatchOnConnect(const ExtensionMessageService::MessagePort& port,
args.Set(3, Value::CreateStringValue(source_extension_id));
args.Set(4, Value::CreateStringValue(target_extension_id));
CHECK(port.sender);
- port.sender->Send(new ViewMsg_ExtensionMessageInvoke(
- port.routing_id, ExtensionMessageService::kDispatchOnConnect, args));
+ port.sender->Send(new ViewMsg_ExtensionMessageInvoke(port.routing_id,
+ ExtensionMessageService::kDispatchOnConnect, args, false));
}
static void DispatchOnDisconnect(
const ExtensionMessageService::MessagePort& port, int source_port_id) {
ListValue args;
args.Set(0, Value::CreateIntegerValue(source_port_id));
- port.sender->Send(new ViewMsg_ExtensionMessageInvoke(
- port.routing_id, ExtensionMessageService::kDispatchOnDisconnect, args));
+ port.sender->Send(new ViewMsg_ExtensionMessageInvoke(port.routing_id,
+ ExtensionMessageService::kDispatchOnDisconnect, args, false));
}
static void DispatchOnMessage(const ExtensionMessageService::MessagePort& port,
@@ -86,8 +86,8 @@ static void DispatchOnMessage(const ExtensionMessageService::MessagePort& port,
ListValue args;
args.Set(0, Value::CreateStringValue(message));
args.Set(1, Value::CreateIntegerValue(source_port_id));
- port.sender->Send(new ViewMsg_ExtensionMessageInvoke(
- port.routing_id, ExtensionMessageService::kDispatchOnMessage, args));
+ port.sender->Send(new ViewMsg_ExtensionMessageInvoke(port.routing_id,
+ ExtensionMessageService::kDispatchOnMessage, args, false));
}
static void DispatchEvent(const ExtensionMessageService::MessagePort& port,
@@ -97,9 +97,8 @@ static void DispatchEvent(const ExtensionMessageService::MessagePort& port,
ListValue args;
args.Set(0, Value::CreateStringValue(event_name));
args.Set(1, Value::CreateStringValue(event_args));
- args.Set(2, Value::CreateBooleanValue(has_incognito_data));
- port.sender->Send(new ViewMsg_ExtensionMessageInvoke(
- port.routing_id, ExtensionMessageService::kDispatchEvent, args));
+ port.sender->Send(new ViewMsg_ExtensionMessageInvoke(port.routing_id,
+ ExtensionMessageService::kDispatchEvent, args, has_incognito_data));
}
} // namespace
diff --git a/chrome/browser/extensions/extension_messages_unittest.cc b/chrome/browser/extensions/extension_messages_unittest.cc
index 98d4db0..5d06654 100644
--- a/chrome/browser/extensions/extension_messages_unittest.cc
+++ b/chrome/browser/extensions/extension_messages_unittest.cc
@@ -18,14 +18,14 @@ static void DispatchOnConnect(int source_port_id, const std::string& name,
args.Set(3, Value::CreateStringValue("")); // extension ID is empty for tests
args.Set(4, Value::CreateStringValue("")); // extension ID is empty for tests
RendererExtensionBindings::Invoke(
- ExtensionMessageService::kDispatchOnConnect, args, NULL);
+ ExtensionMessageService::kDispatchOnConnect, args, NULL, false);
}
static void DispatchOnDisconnect(int source_port_id) {
ListValue args;
args.Set(0, Value::CreateIntegerValue(source_port_id));
RendererExtensionBindings::Invoke(
- ExtensionMessageService::kDispatchOnDisconnect, args, NULL);
+ ExtensionMessageService::kDispatchOnDisconnect, args, NULL, false);
}
static void DispatchOnMessage(const std::string& message, int source_port_id) {
@@ -33,7 +33,7 @@ static void DispatchOnMessage(const std::string& message, int source_port_id) {
args.Set(0, Value::CreateStringValue(message));
args.Set(1, Value::CreateIntegerValue(source_port_id));
RendererExtensionBindings::Invoke(
- ExtensionMessageService::kDispatchOnMessage, args, NULL);
+ ExtensionMessageService::kDispatchOnMessage, args, NULL, false);
}
// Tests that the bindings for opening a channel to an extension and sending