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

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

Issue 16625012: Remove ExtensionURLInfo, make security decisions in render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address feedback Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/extension_function_dispatcher.h" 5 #include "chrome/browser/extensions/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 18 matching lines...) Expand all
29 #include "chrome/common/extensions/extension_set.h" 29 #include "chrome/common/extensions/extension_set.h"
30 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
31 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
33 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
34 #include "content/public/browser/render_view_host_observer.h" 34 #include "content/public/browser/render_view_host_observer.h"
35 #include "content/public/browser/user_metrics.h" 35 #include "content/public/browser/user_metrics.h"
36 #include "content/public/common/result_codes.h" 36 #include "content/public/common/result_codes.h"
37 #include "ipc/ipc_message.h" 37 #include "ipc/ipc_message.h"
38 #include "ipc/ipc_message_macros.h" 38 #include "ipc/ipc_message_macros.h"
39 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
40 #include "webkit/glue/resource_type.h" 39 #include "webkit/glue/resource_type.h"
41 40
42 using extensions::Extension; 41 using extensions::Extension;
43 using extensions::ExtensionAPI; 42 using extensions::ExtensionAPI;
44 using content::RenderViewHost; 43 using content::RenderViewHost;
45 using WebKit::WebSecurityOrigin;
46 44
47 namespace { 45 namespace {
48 46
49 void LogSuccess(const std::string& extension_id, 47 void LogSuccess(const std::string& extension_id,
50 const std::string& api_name, 48 const std::string& api_name,
51 scoped_ptr<base::ListValue> args, 49 scoped_ptr<base::ListValue> args,
52 Profile* profile) { 50 Profile* profile) {
53 // The ActivityLog can only be accessed from the main (UI) thread. If we're 51 // The ActivityLog can only be accessed from the main (UI) thread. If we're
54 // running on the wrong thread, re-dispatch from the main thread. 52 // running on the wrong thread, re-dispatch from the main thread.
55 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 53 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 ExtensionService* service = profile()->GetExtensionService(); 353 ExtensionService* service = profile()->GetExtensionService();
356 ExtensionProcessManager* process_manager = 354 ExtensionProcessManager* process_manager =
357 extensions::ExtensionSystem::Get(profile())->process_manager(); 355 extensions::ExtensionSystem::Get(profile())->process_manager();
358 extensions::ProcessMap* process_map = service->process_map(); 356 extensions::ProcessMap* process_map = service->process_map();
359 if (!service || !process_map) 357 if (!service || !process_map)
360 return; 358 return;
361 359
362 const Extension* extension = service->extensions()->GetByID( 360 const Extension* extension = service->extensions()->GetByID(
363 params.extension_id); 361 params.extension_id);
364 if (!extension) 362 if (!extension)
365 extension = service->extensions()->GetHostedAppByURL(ExtensionURLInfo( 363 extension = service->extensions()->GetHostedAppByURL(params.source_url);
366 WebSecurityOrigin::createFromString(params.source_origin),
367 params.source_url));
368 364
369 scoped_refptr<ExtensionFunction> function( 365 scoped_refptr<ExtensionFunction> function(
370 CreateExtensionFunction(params, extension, 366 CreateExtensionFunction(params, extension,
371 render_view_host->GetProcess()->GetID(), 367 render_view_host->GetProcess()->GetID(),
372 *(service->process_map()), 368 *(service->process_map()),
373 extensions::ExtensionAPI::GetSharedInstance(), 369 extensions::ExtensionAPI::GetSharedInstance(),
374 profile(), callback)); 370 profile(), callback));
375 scoped_ptr<ListValue> args(params.arguments.DeepCopy()); 371 scoped_ptr<ListValue> args(params.arguments.DeepCopy());
376 372
377 if (!function.get()) { 373 if (!function.get()) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 return function; 533 return function;
538 } 534 }
539 535
540 // static 536 // static
541 void ExtensionFunctionDispatcher::SendAccessDenied( 537 void ExtensionFunctionDispatcher::SendAccessDenied(
542 const ExtensionFunction::ResponseCallback& callback) { 538 const ExtensionFunction::ResponseCallback& callback) {
543 ListValue empty_list; 539 ListValue empty_list;
544 callback.Run(ExtensionFunction::FAILED, empty_list, 540 callback.Run(ExtensionFunction::FAILED, empty_list,
545 "Access to extension API denied."); 541 "Access to extension API denied.");
546 } 542 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/offline/offline_load_page.cc ('k') | chrome/browser/extensions/extension_info_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698