diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-13 12:54:10 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-13 12:54:10 +0000 |
commit | 8426c02d403d815745650e6833b82f22050a1bb2 (patch) | |
tree | 85dcdd2979e2cf569c045ec589de17de7331f116 /chrome/common | |
parent | 16ca52db210a9c32244308eef74b0f4db01d9666 (diff) | |
download | chromium_src-8426c02d403d815745650e6833b82f22050a1bb2.zip chromium_src-8426c02d403d815745650e6833b82f22050a1bb2.tar.gz chromium_src-8426c02d403d815745650e6833b82f22050a1bb2.tar.bz2 |
Add support for restricting broadcasting events to extensions based on host permissions.
BUG=38398
TEST=none
Review URL: http://codereview.chromium.org/1095002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44348 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 2e8b5bf..0ec3183 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -885,6 +885,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)) { @@ -912,8 +917,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, |