[email protected] | 64c82073 | 2012-01-05 20:50:34 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 6 | |
[email protected] | 745feedb | 2010-08-02 04:08:07 | [diff] [blame] | 7 | #include <map> |
| 8 | |
[email protected] | ffbec69 | 2012-02-26 20:26:42 | [diff] [blame] | 9 | #include "base/json/json_string_value_serializer.h" |
[email protected] | 5bc248a | 2012-04-04 23:38:11 | [diff] [blame] | 10 | #include "base/lazy_instance.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 11 | #include "base/memory/ref_counted.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 12 | #include "base/process_util.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 13 | #include "base/values.h" |
[email protected] | 17d40f0 | 2010-07-01 01:18:06 | [diff] [blame] | 14 | #include "build/build_config.h" |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 15 | #include "chrome/browser/extensions/extension_activity_log.h" |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 16 | #include "chrome/browser/extensions/extension_function.h" |
[email protected] | ae33d32 | 2012-03-19 22:24:35 | [diff] [blame] | 17 | #include "chrome/browser/extensions/extension_function_registry.h" |
[email protected] | 2f69b38 | 2011-02-19 00:34:25 | [diff] [blame] | 18 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | 8f9d4eb | 2011-02-05 01:39:10 | [diff] [blame] | 19 | #include "chrome/browser/extensions/extension_web_ui.h" |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 20 | #include "chrome/browser/extensions/extensions_quota_service.h" |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 21 | #include "chrome/browser/extensions/process_map.h" |
[email protected] | ed2b100 | 2011-05-25 14:12:10 | [diff] [blame] | 22 | #include "chrome/browser/external_protocol/external_protocol_handler.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 23 | #include "chrome/browser/profiles/profile.h" |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 24 | #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 25 | #include "chrome/common/extensions/api/extension_api.h" |
[email protected] | 44c49c9 | 2011-03-28 16:17:23 | [diff] [blame] | 26 | #include "chrome/common/extensions/extension_messages.h" |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 27 | #include "chrome/common/extensions/extension_set.h" |
[email protected] | 9c45b718 | 2009-08-04 16:44:43 | [diff] [blame] | 28 | #include "chrome/common/url_constants.h" |
[email protected] | c333e79 | 2012-01-06 16:57:39 | [diff] [blame] | 29 | #include "content/public/browser/render_process_host.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 30 | #include "content/public/browser/render_view_host.h" |
[email protected] | f82d57b5 | 2011-04-27 19:13:17 | [diff] [blame] | 31 | #include "ipc/ipc_message.h" |
| 32 | #include "ipc/ipc_message_macros.h" |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 33 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
[email protected] | ae33d32 | 2012-03-19 22:24:35 | [diff] [blame] | 34 | #include "webkit/glue/resource_type.h" |
[email protected] | 61b55b6 | 2011-03-24 09:03:10 | [diff] [blame] | 35 | |
[email protected] | 1c321ee | 2012-05-21 03:02:34 | [diff] [blame] | 36 | using extensions::Extension; |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 37 | using extensions::ExtensionAPI; |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 38 | using content::RenderViewHost; |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 39 | using WebKit::WebSecurityOrigin; |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 40 | |
[email protected] | 5bc248a | 2012-04-04 23:38:11 | [diff] [blame] | 41 | namespace { |
| 42 | |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 43 | const char kAccessDenied[] = "access denied"; |
| 44 | const char kQuotaExceeded[] = "quota exceeded"; |
| 45 | |
| 46 | void LogSuccess(const Extension* extension, |
| 47 | const ExtensionHostMsg_Request_Params& params) { |
| 48 | ExtensionActivityLog* extension_activity_log = |
| 49 | ExtensionActivityLog::GetInstance(); |
| 50 | if (extension_activity_log->HasObservers(extension)) { |
| 51 | std::string call_signature = params.name + "("; |
| 52 | ListValue::const_iterator it = params.arguments.begin(); |
| 53 | for (; it != params.arguments.end(); ++it) { |
| 54 | std::string arg; |
| 55 | JSONStringValueSerializer serializer(&arg); |
| 56 | if (serializer.SerializeAndOmitBinaryValues(**it)) { |
| 57 | if (it != params.arguments.begin()) |
| 58 | call_signature += ", "; |
| 59 | call_signature += arg; |
| 60 | } |
| 61 | } |
| 62 | call_signature += ")"; |
| 63 | |
| 64 | extension_activity_log->Log( |
| 65 | extension, |
| 66 | ExtensionActivityLog::ACTIVITY_EXTENSION_API_CALL, |
| 67 | call_signature); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | void LogFailure(const Extension* extension, |
| 72 | const std::string& func_name, |
| 73 | const char* reason) { |
| 74 | ExtensionActivityLog* extension_activity_log = |
| 75 | ExtensionActivityLog::GetInstance(); |
| 76 | if (extension_activity_log->HasObservers(extension)) { |
| 77 | extension_activity_log->Log( |
| 78 | extension, |
| 79 | ExtensionActivityLog::ACTIVITY_EXTENSION_API_BLOCK, |
| 80 | func_name + ": " + reason); |
| 81 | } |
| 82 | } |
| 83 | |
[email protected] | 5bc248a | 2012-04-04 23:38:11 | [diff] [blame] | 84 | // Separate copy of ExtensionAPI used for IO thread extension functions. We need |
| 85 | // this because ExtensionAPI has mutable data. It should be possible to remove |
| 86 | // this once all the extension APIs are updated to the feature system. |
| 87 | struct Static { |
| 88 | Static() |
| 89 | : api(extensions::ExtensionAPI::CreateWithDefaultConfiguration()) { |
| 90 | } |
| 91 | scoped_ptr<extensions::ExtensionAPI> api; |
| 92 | }; |
| 93 | base::LazyInstance<Static> g_global_io_data = LAZY_INSTANCE_INITIALIZER; |
| 94 | |
| 95 | } // namespace |
| 96 | |
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame] | 97 | extensions::WindowController* |
| 98 | ExtensionFunctionDispatcher::Delegate::GetExtensionWindowController() |
[email protected] | d72d3a6 | 2012-05-10 03:45:08 | [diff] [blame] | 99 | const { |
| 100 | return NULL; |
| 101 | } |
| 102 | |
| 103 | content::WebContents* |
[email protected] | 44f4b13 | 2012-07-17 20:36:57 | [diff] [blame] | 104 | ExtensionFunctionDispatcher::Delegate::GetAssociatedWebContents() const { |
[email protected] | d72d3a6 | 2012-05-10 03:45:08 | [diff] [blame] | 105 | return NULL; |
| 106 | } |
[email protected] | 5bc248a | 2012-04-04 23:38:11 | [diff] [blame] | 107 | |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 108 | void ExtensionFunctionDispatcher::GetAllFunctionNames( |
| 109 | std::vector<std::string>* names) { |
[email protected] | ae33d32 | 2012-03-19 22:24:35 | [diff] [blame] | 110 | ExtensionFunctionRegistry::GetInstance()->GetAllNames(names); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 111 | } |
| 112 | |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 113 | bool ExtensionFunctionDispatcher::OverrideFunction( |
| 114 | const std::string& name, ExtensionFunctionFactory factory) { |
[email protected] | ae33d32 | 2012-03-19 22:24:35 | [diff] [blame] | 115 | return ExtensionFunctionRegistry::GetInstance()->OverrideFunction(name, |
| 116 | factory); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | void ExtensionFunctionDispatcher::ResetFunctions() { |
[email protected] | ae33d32 | 2012-03-19 22:24:35 | [diff] [blame] | 120 | ExtensionFunctionRegistry::GetInstance()->ResetFunctions(); |
[email protected] | b83e460 | 2009-05-15 22:58:33 | [diff] [blame] | 121 | } |
| 122 | |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 123 | // static |
| 124 | void ExtensionFunctionDispatcher::DispatchOnIOThread( |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 125 | ExtensionInfoMap* extension_info_map, |
[email protected] | 67351452 | 2011-07-13 18:17:18 | [diff] [blame] | 126 | void* profile, |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 127 | int render_process_id, |
| 128 | base::WeakPtr<ChromeRenderMessageFilter> ipc_sender, |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 129 | int routing_id, |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 130 | const ExtensionHostMsg_Request_Params& params) { |
| 131 | const Extension* extension = |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 132 | extension_info_map->extensions().GetByID(params.extension_id); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 133 | |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 134 | scoped_refptr<ExtensionFunction> function( |
| 135 | CreateExtensionFunction(params, extension, render_process_id, |
[email protected] | 5bc248a | 2012-04-04 23:38:11 | [diff] [blame] | 136 | extension_info_map->process_map(), |
| 137 | g_global_io_data.Get().api.get(), |
| 138 | profile, |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 139 | ipc_sender, routing_id)); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 140 | if (!function) { |
| 141 | LogFailure(extension, params.name, kAccessDenied); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 142 | return; |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 143 | } |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 144 | |
| 145 | IOThreadExtensionFunction* function_io = |
| 146 | function->AsIOThreadExtensionFunction(); |
| 147 | if (!function_io) { |
| 148 | NOTREACHED(); |
| 149 | return; |
| 150 | } |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 151 | function_io->set_ipc_sender(ipc_sender, routing_id); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 152 | function_io->set_extension_info_map(extension_info_map); |
| 153 | function->set_include_incognito( |
| 154 | extension_info_map->IsIncognitoEnabled(extension->id())); |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 155 | |
[email protected] | 3629691 | 2012-03-20 11:08:49 | [diff] [blame] | 156 | ExtensionsQuotaService* quota = extension_info_map->GetQuotaService(); |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 157 | if (quota->Assess(extension->id(), function, ¶ms.arguments, |
| 158 | base::TimeTicks::Now())) { |
| 159 | function->Run(); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 160 | LogSuccess(extension, params); |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 161 | } else { |
| 162 | function->OnQuotaExceeded(); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 163 | LogFailure(extension, params.name, kQuotaExceeded); |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 164 | } |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 165 | } |
| 166 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 167 | ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(Profile* profile, |
| 168 | Delegate* delegate) |
| 169 | : profile_(profile), |
[email protected] | 55ce33071 | 2011-05-24 19:04:27 | [diff] [blame] | 170 | delegate_(delegate) { |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 171 | } |
| 172 | |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 173 | ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() { |
[email protected] | 32dda36 | 2009-06-05 19:07:01 | [diff] [blame] | 174 | } |
| 175 | |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 176 | void ExtensionFunctionDispatcher::Dispatch( |
| 177 | const ExtensionHostMsg_Request_Params& params, |
| 178 | RenderViewHost* render_view_host) { |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 179 | ExtensionService* service = profile()->GetExtensionService(); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 180 | extensions::ProcessMap* process_map = service->process_map(); |
| 181 | if (!service || !process_map) |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 182 | return; |
| 183 | |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 184 | const Extension* extension = service->extensions()->GetByID( |
| 185 | params.extension_id); |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 186 | if (!extension) |
[email protected] | 615d88f | 2011-12-13 01:47:44 | [diff] [blame] | 187 | extension = service->extensions()->GetHostedAppByURL(ExtensionURLInfo( |
| 188 | WebSecurityOrigin::createFromString(params.source_origin), |
| 189 | params.source_url)); |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 190 | |
[email protected] | 8add541 | 2011-10-01 21:02:14 | [diff] [blame] | 191 | scoped_refptr<ExtensionFunction> function( |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 192 | CreateExtensionFunction(params, extension, |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 193 | render_view_host->GetProcess()->GetID(), |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 194 | *(service->process_map()), |
[email protected] | 5bc248a | 2012-04-04 23:38:11 | [diff] [blame] | 195 | extensions::ExtensionAPI::GetSharedInstance(), |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 196 | profile(), render_view_host, |
| 197 | render_view_host->GetRoutingID())); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 198 | if (!function) { |
| 199 | LogFailure(extension, params.name, kAccessDenied); |
[email protected] | f82d57b5 | 2011-04-27 19:13:17 | [diff] [blame] | 200 | return; |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 201 | } |
[email protected] | f82d57b5 | 2011-04-27 19:13:17 | [diff] [blame] | 202 | |
[email protected] | a2aef2e | 2011-05-26 22:48:12 | [diff] [blame] | 203 | UIThreadExtensionFunction* function_ui = |
| 204 | function->AsUIThreadExtensionFunction(); |
| 205 | if (!function_ui) { |
| 206 | NOTREACHED(); |
| 207 | return; |
| 208 | } |
| 209 | function_ui->SetRenderViewHost(render_view_host); |
| 210 | function_ui->set_dispatcher(AsWeakPtr()); |
| 211 | function_ui->set_profile(profile_); |
[email protected] | 2a8f24e | 2010-11-03 21:37:05 | [diff] [blame] | 212 | function->set_include_incognito(service->CanCrossIncognito(extension)); |
[email protected] | cb0ce1e02 | 2010-03-10 19:54:41 | [diff] [blame] | 213 | |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 214 | ExtensionsQuotaService* quota = service->quota_service(); |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 215 | if (quota->Assess(extension->id(), function, ¶ms.arguments, |
[email protected] | 8b8e7c9 | 2010-08-19 18:05:56 | [diff] [blame] | 216 | base::TimeTicks::Now())) { |
[email protected] | d070ec6 | 2010-07-27 21:28:26 | [diff] [blame] | 217 | // See crbug.com/39178. |
| 218 | ExternalProtocolHandler::PermitLaunchUrl(); |
| 219 | |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 220 | function->Run(); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 221 | LogSuccess(extension, params); |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 222 | } else { |
[email protected] | fd50e7b | 2011-11-03 09:20:25 | [diff] [blame] | 223 | function->OnQuotaExceeded(); |
[email protected] | efd7599 | 2011-12-15 22:42:42 | [diff] [blame] | 224 | LogFailure(extension, params.name, kQuotaExceeded); |
[email protected] | d13950e | 2009-12-04 01:43:02 | [diff] [blame] | 225 | } |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 226 | |
[email protected] | 5734e88 | 2012-05-04 22:17:56 | [diff] [blame] | 227 | // Check if extension was uninstalled by management.uninstall. |
| 228 | if (!service->extensions()->GetByID(params.extension_id)) |
| 229 | return; |
| 230 | |
[email protected] | 720ad131 | 2012-02-27 23:07:36 | [diff] [blame] | 231 | // We only adjust the keepalive count for UIThreadExtensionFunction for |
| 232 | // now, largely for simplicity's sake. This is OK because currently, only |
| 233 | // the webRequest API uses IOThreadExtensionFunction, and that API is not |
| 234 | // compatible with lazy background pages. |
| 235 | profile()->GetExtensionProcessManager()->IncrementLazyKeepaliveCount( |
| 236 | extension); |
| 237 | } |
| 238 | |
| 239 | void ExtensionFunctionDispatcher::OnExtensionFunctionCompleted( |
| 240 | const Extension* extension) { |
| 241 | profile()->GetExtensionProcessManager()->DecrementLazyKeepaliveCount( |
| 242 | extension); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 243 | } |
| 244 | |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 245 | // static |
| 246 | ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction( |
| 247 | const ExtensionHostMsg_Request_Params& params, |
| 248 | const Extension* extension, |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 249 | int requesting_process_id, |
| 250 | const extensions::ProcessMap& process_map, |
[email protected] | 5bc248a | 2012-04-04 23:38:11 | [diff] [blame] | 251 | extensions::ExtensionAPI* api, |
[email protected] | 67351452 | 2011-07-13 18:17:18 | [diff] [blame] | 252 | void* profile, |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 253 | IPC::Sender* ipc_sender, |
| 254 | int routing_id) { |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 255 | if (!extension) { |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 256 | LOG(ERROR) << "Specified extension does not exist."; |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 257 | SendAccessDenied(ipc_sender, routing_id, params.request_id); |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 258 | return NULL; |
| 259 | } |
| 260 | |
[email protected] | 5bc248a | 2012-04-04 23:38:11 | [diff] [blame] | 261 | if (api->IsPrivileged(params.name) && |
[email protected] | 83820d4 | 2011-11-12 22:03:11 | [diff] [blame] | 262 | !process_map.Contains(extension->id(), requesting_process_id)) { |
[email protected] | 6f37144 | 2011-11-09 06:45:46 | [diff] [blame] | 263 | LOG(ERROR) << "Extension API called from incorrect process " |
| 264 | << requesting_process_id |
| 265 | << " from URL " << params.source_url.spec(); |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 266 | SendAccessDenied(ipc_sender, routing_id, params.request_id); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 267 | return NULL; |
| 268 | } |
| 269 | |
[email protected] | 0d3e4a2 | 2011-06-23 19:02:52 | [diff] [blame] | 270 | if (!extension->HasAPIPermission(params.name)) { |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 271 | LOG(ERROR) << "Extension " << extension->id() << " does not have " |
| 272 | << "permission to function: " << params.name; |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 273 | SendAccessDenied(ipc_sender, routing_id, params.request_id); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 274 | return NULL; |
| 275 | } |
| 276 | |
| 277 | ExtensionFunction* function = |
[email protected] | ae33d32 | 2012-03-19 22:24:35 | [diff] [blame] | 278 | ExtensionFunctionRegistry::GetInstance()->NewFunction(params.name); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 279 | function->SetArgs(¶ms.arguments); |
| 280 | function->set_source_url(params.source_url); |
| 281 | function->set_request_id(params.request_id); |
| 282 | function->set_has_callback(params.has_callback); |
| 283 | function->set_user_gesture(params.user_gesture); |
| 284 | function->set_extension(extension); |
[email protected] | 637bf32 | 2011-10-01 20:46:32 | [diff] [blame] | 285 | function->set_profile_id(profile); |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 286 | return function; |
| 287 | } |
| 288 | |
| 289 | // static |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 290 | void ExtensionFunctionDispatcher::SendAccessDenied( |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 291 | IPC::Sender* ipc_sender, int routing_id, int request_id) { |
[email protected] | 602542d | 2012-04-20 02:48:01 | [diff] [blame] | 292 | ListValue empty_list; |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 293 | ipc_sender->Send(new ExtensionMsg_Response( |
[email protected] | 74e21e7 | 2012-07-09 21:20:53 | [diff] [blame] | 294 | routing_id, request_id, false, empty_list, |
[email protected] | c5dbef0 | 2011-05-13 05:06:09 | [diff] [blame] | 295 | "Access to extension API denied.")); |
[email protected] | bfdffe2b | 2009-04-24 22:05:35 | [diff] [blame] | 296 | } |