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

Side by Side Diff: extensions/browser/extension_function_dispatcher.cc

Issue 670173002: Fix webrequest api for webview in webui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scoped_refptr not testable Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/extension_function_dispatcher.h" 5 #include "extensions/browser/extension_function_dispatcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // static 222 // static
223 void ExtensionFunctionDispatcher::DispatchOnIOThread( 223 void ExtensionFunctionDispatcher::DispatchOnIOThread(
224 InfoMap* extension_info_map, 224 InfoMap* extension_info_map,
225 void* profile_id, 225 void* profile_id,
226 int render_process_id, 226 int render_process_id,
227 base::WeakPtr<ExtensionMessageFilter> ipc_sender, 227 base::WeakPtr<ExtensionMessageFilter> ipc_sender,
228 int routing_id, 228 int routing_id,
229 const ExtensionHostMsg_Request_Params& params) { 229 const ExtensionHostMsg_Request_Params& params) {
230 const Extension* extension = 230 const Extension* extension =
231 extension_info_map->extensions().GetByID(params.extension_id); 231 extension_info_map->extensions().GetByID(params.extension_id);
232 if (!extension)
233 return;
234 232
235 ExtensionFunction::ResponseCallback callback( 233 ExtensionFunction::ResponseCallback callback(
236 base::Bind(&IOThreadResponseCallback, ipc_sender, routing_id, 234 base::Bind(&IOThreadResponseCallback, ipc_sender, routing_id,
237 params.request_id)); 235 params.request_id));
238 236
239 scoped_refptr<ExtensionFunction> function( 237 scoped_refptr<ExtensionFunction> function(
240 CreateExtensionFunction(params, 238 CreateExtensionFunction(params,
241 extension, 239 extension,
242 render_process_id, 240 render_process_id,
243 extension_info_map->process_map(), 241 extension_info_map->process_map(),
244 g_global_io_data.Get().api.get(), 242 g_global_io_data.Get().api.get(),
245 profile_id, 243 profile_id,
246 callback)); 244 callback));
247 if (!function.get()) 245 if (!function.get())
248 return; 246 return;
249 247
250 IOThreadExtensionFunction* function_io = 248 IOThreadExtensionFunction* function_io =
251 function->AsIOThreadExtensionFunction(); 249 function->AsIOThreadExtensionFunction();
252 if (!function_io) { 250 if (!function_io) {
253 NOTREACHED(); 251 NOTREACHED();
254 return; 252 return;
255 } 253 }
256 function_io->set_ipc_sender(ipc_sender, routing_id); 254 function_io->set_ipc_sender(ipc_sender, routing_id);
257 function_io->set_extension_info_map(extension_info_map); 255 function_io->set_extension_info_map(extension_info_map);
258 function->set_include_incognito( 256 if (extension) {
259 extension_info_map->IsIncognitoEnabled(extension->id())); 257 function->set_include_incognito(
258 extension_info_map->IsIncognitoEnabled(extension->id()));
259 }
260 260
261 if (!CheckPermissions(function.get(), params, callback)) 261 if (!CheckPermissions(function.get(), params, callback))
262 return; 262 return;
263 263
264 if (!extension) {
265 // Skip all of the UMA, quota, event page, activity logging stuff if there
266 // isn't an extension, e.g. if the function call was from WebUI.
267 function->Run()->Execute();
268 return;
269 }
270
264 QuotaService* quota = extension_info_map->GetQuotaService(); 271 QuotaService* quota = extension_info_map->GetQuotaService();
265 std::string violation_error = quota->Assess(extension->id(), 272 std::string violation_error = quota->Assess(extension->id(),
266 function.get(), 273 function.get(),
267 &params.arguments, 274 &params.arguments,
268 base::TimeTicks::Now()); 275 base::TimeTicks::Now());
269 if (violation_error.empty()) { 276 if (violation_error.empty()) {
270 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy()); 277 scoped_ptr<base::ListValue> args(params.arguments.DeepCopy());
271 NotifyApiFunctionCalled(extension->id(), 278 NotifyApiFunctionCalled(extension->id(),
272 params.name, 279 params.name,
273 args.Pass(), 280 args.Pass(),
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 469
463 // static 470 // static
464 void ExtensionFunctionDispatcher::SendAccessDenied( 471 void ExtensionFunctionDispatcher::SendAccessDenied(
465 const ExtensionFunction::ResponseCallback& callback) { 472 const ExtensionFunction::ResponseCallback& callback) {
466 base::ListValue empty_list; 473 base::ListValue empty_list;
467 callback.Run(ExtensionFunction::FAILED, empty_list, 474 callback.Run(ExtensionFunction::FAILED, empty_list,
468 "Access to extension API denied."); 475 "Access to extension API denied.");
469 } 476 }
470 477
471 } // namespace extensions 478 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_function.h ('k') | extensions/browser/guest_view/guest_view_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698