diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-14 10:51:19 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-14 10:51:19 +0000 |
commit | a807bbeaaf2155a346ac946aefeed14620dbc17c (patch) | |
tree | f4748ce24b1c9c1c754db15d621611383160aa87 /chrome/common | |
parent | a0e6f1b8324abee0304470219d1b129b3be30e15 (diff) | |
download | chromium_src-a807bbeaaf2155a346ac946aefeed14620dbc17c.zip chromium_src-a807bbeaaf2155a346ac946aefeed14620dbc17c.tar.gz chromium_src-a807bbeaaf2155a346ac946aefeed14620dbc17c.tar.bz2 |
Reland 44348 Add support for restricting broadcasting events to extensions based on host permissions
BUG=38398
TEST=none
TBR=jochen@chromium.org
Review URL: http://codereview.chromium.org/1528038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44470 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rwxr-xr-x | chrome/common/extensions/api/extension_api.json | 19 | ||||
-rw-r--r-- | chrome/common/extensions/extension.cc | 8 | ||||
-rw-r--r-- | chrome/common/extensions/extension.h | 3 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 5 |
4 files changed, 30 insertions, 5 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 30b3f12..51434bc 100755 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -2710,7 +2710,24 @@ ] } ], - "events": [] + "events": [ + { + "name": "onMessage", + "type": "function", + "unprivileged": true, + "description": "Used to test sending messages to extensions.", + "parameters": [ + { + "type": "object", + "name": "info", + "properties": { + "data": { "type": "string", "description": "Additional information." }, + "lastMessage": { "type": "boolean", "description": "True if this was the last message for this test" } + } + } + ] + } + ] }, { "namespace": "experimental.clipboard", diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index a598e9f..a5e9279 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -886,6 +886,11 @@ void Extension::DecodeIconFromPath(const FilePath& icon_path, result->swap(decoded); } +GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) { + return GURL(std::string(chrome::kExtensionScheme) + + chrome::kStandardSchemeSeparator + extension_id + "/"); +} + bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, std::string* error) { if (source.HasKey(keys::kPublicKey)) { @@ -913,8 +918,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key, manifest_value_.reset(static_cast<DictionaryValue*>(source.DeepCopy())); // Initialize the URL. - extension_url_ = GURL(std::string(chrome::kExtensionScheme) + - chrome::kStandardSchemeSeparator + id_ + "/"); + extension_url_ = Extension::GetBaseURLFromExtensionId(id_); // Initialize version. std::string version_str; diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 7d6ac39..6cc385c 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -203,6 +203,9 @@ class Extension { Icons icon_size, scoped_ptr<SkBitmap>* result); + // Returns the base extension url for a given |extension_id|. + static GURL GetBaseURLFromExtensionId(const std::string& extension_id); + // Initialize the extension from a parsed manifest. // Usually, the id of an extension is generated by the "key" property of // its manifest, but if |require_key| is |false|, a temporary ID will be diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index a1028b2..bbfd9d1 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -716,10 +716,11 @@ IPC_BEGIN_MESSAGES(View) // target process. If routed, it will be restricted to the contexts that // are part of the target RenderView. // |args| is a list of primitive Value types that are passed to the function. - IPC_MESSAGE_ROUTED3(ViewMsg_ExtensionMessageInvoke, + IPC_MESSAGE_ROUTED4(ViewMsg_ExtensionMessageInvoke, std::string /* function_name */, ListValue /* args */, - bool /* requires incognito access */) + bool /* requires incognito access */, + GURL /* event URL */) // Tell the renderer process all known extension function names. IPC_MESSAGE_CONTROL1(ViewMsg_Extension_SetFunctionNames, |