| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "chrome/browser/extensions/extension_process_manager.h" | 43 #include "chrome/browser/extensions/extension_process_manager.h" |
| 44 #include "chrome/browser/extensions/extension_processes_api.h" | 44 #include "chrome/browser/extensions/extension_processes_api.h" |
| 45 #include "chrome/browser/extensions/extension_proxy_api.h" | 45 #include "chrome/browser/extensions/extension_proxy_api.h" |
| 46 #include "chrome/browser/extensions/extension_rlz_module.h" | 46 #include "chrome/browser/extensions/extension_rlz_module.h" |
| 47 #include "chrome/browser/extensions/extension_sidebar_api.h" | 47 #include "chrome/browser/extensions/extension_sidebar_api.h" |
| 48 #include "chrome/browser/extensions/extension_tabs_module.h" | 48 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 49 #include "chrome/browser/extensions/extension_test_api.h" | 49 #include "chrome/browser/extensions/extension_test_api.h" |
| 50 #include "chrome/browser/extensions/extension_tts_api.h" | 50 #include "chrome/browser/extensions/extension_tts_api.h" |
| 51 #include "chrome/browser/extensions/extension_webstore_private_api.h" | 51 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
| 52 #include "chrome/browser/extensions/extensions_quota_service.h" | 52 #include "chrome/browser/extensions/extensions_quota_service.h" |
| 53 #include "chrome/browser/extensions/extensions_service.h" | 53 #include "chrome/browser/extensions/extension_service.h" |
| 54 #include "chrome/browser/profiles/profile.h" | 54 #include "chrome/browser/profiles/profile.h" |
| 55 #include "chrome/browser/renderer_host/render_process_host.h" | 55 #include "chrome/browser/renderer_host/render_process_host.h" |
| 56 #include "chrome/browser/renderer_host/render_view_host.h" | 56 #include "chrome/browser/renderer_host/render_view_host.h" |
| 57 #include "chrome/common/render_messages.h" | 57 #include "chrome/common/render_messages.h" |
| 58 #include "chrome/common/render_messages_params.h" | 58 #include "chrome/common/render_messages_params.h" |
| 59 #include "chrome/common/result_codes.h" | 59 #include "chrome/common/result_codes.h" |
| 60 #include "chrome/common/url_constants.h" | 60 #include "chrome/common/url_constants.h" |
| 61 #include "third_party/skia/include/core/SkBitmap.h" | 61 #include "third_party/skia/include/core/SkBitmap.h" |
| 62 | 62 |
| 63 | 63 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 334 } |
| 335 | 335 |
| 336 void ExtensionFunctionDispatcher::ResetFunctions() { | 336 void ExtensionFunctionDispatcher::ResetFunctions() { |
| 337 FactoryRegistry::GetInstance()->ResetFunctions(); | 337 FactoryRegistry::GetInstance()->ResetFunctions(); |
| 338 } | 338 } |
| 339 | 339 |
| 340 ExtensionFunctionDispatcher* ExtensionFunctionDispatcher::Create( | 340 ExtensionFunctionDispatcher* ExtensionFunctionDispatcher::Create( |
| 341 RenderViewHost* render_view_host, | 341 RenderViewHost* render_view_host, |
| 342 Delegate* delegate, | 342 Delegate* delegate, |
| 343 const GURL& url) { | 343 const GURL& url) { |
| 344 ExtensionsService* service = | 344 ExtensionService* service = |
| 345 render_view_host->process()->profile()->GetExtensionsService(); | 345 render_view_host->process()->profile()->GetExtensionService(); |
| 346 DCHECK(service); | 346 DCHECK(service); |
| 347 | 347 |
| 348 if (!service->ExtensionBindingsAllowed(url)) | 348 if (!service->ExtensionBindingsAllowed(url)) |
| 349 return NULL; | 349 return NULL; |
| 350 | 350 |
| 351 const Extension* extension = service->GetExtensionByURL(url); | 351 const Extension* extension = service->GetExtensionByURL(url); |
| 352 if (!extension) | 352 if (!extension) |
| 353 extension = service->GetExtensionByWebExtent(url); | 353 extension = service->GetExtensionByWebExtent(url); |
| 354 | 354 |
| 355 if (extension) | 355 if (extension) |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 scoped_refptr<ExtensionFunction> function( | 446 scoped_refptr<ExtensionFunction> function( |
| 447 FactoryRegistry::GetInstance()->NewFunction(params.name)); | 447 FactoryRegistry::GetInstance()->NewFunction(params.name)); |
| 448 function->set_dispatcher_peer(peer_); | 448 function->set_dispatcher_peer(peer_); |
| 449 function->set_profile(profile_); | 449 function->set_profile(profile_); |
| 450 function->set_extension_id(extension_id()); | 450 function->set_extension_id(extension_id()); |
| 451 function->SetArgs(¶ms.arguments); | 451 function->SetArgs(¶ms.arguments); |
| 452 function->set_source_url(params.source_url); | 452 function->set_source_url(params.source_url); |
| 453 function->set_request_id(params.request_id); | 453 function->set_request_id(params.request_id); |
| 454 function->set_has_callback(params.has_callback); | 454 function->set_has_callback(params.has_callback); |
| 455 function->set_user_gesture(params.user_gesture); | 455 function->set_user_gesture(params.user_gesture); |
| 456 ExtensionsService* service = profile()->GetExtensionsService(); | 456 ExtensionService* service = profile()->GetExtensionService(); |
| 457 DCHECK(service); | 457 DCHECK(service); |
| 458 const Extension* extension = service->GetExtensionById(extension_id(), false); | 458 const Extension* extension = service->GetExtensionById(extension_id(), false); |
| 459 DCHECK(extension); | 459 DCHECK(extension); |
| 460 function->set_include_incognito(service->CanCrossIncognito(extension)); | 460 function->set_include_incognito(service->CanCrossIncognito(extension)); |
| 461 | 461 |
| 462 if (!service->ExtensionBindingsAllowed(function->source_url()) || | 462 if (!service->ExtensionBindingsAllowed(function->source_url()) || |
| 463 !extension->HasApiPermission(function->name())) { | 463 !extension->HasApiPermission(function->name())) { |
| 464 render_view_host_->BlockExtensionRequest(function->request_id()); | 464 render_view_host_->BlockExtensionRequest(function->request_id()); |
| 465 return; | 465 return; |
| 466 } | 466 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 494 } else { | 494 } else { |
| 495 NOTREACHED(); | 495 NOTREACHED(); |
| 496 base::KillProcess(render_view_host_->process()->GetHandle(), | 496 base::KillProcess(render_view_host_->process()->GetHandle(), |
| 497 ResultCodes::KILLED_BAD_MESSAGE, false); | 497 ResultCodes::KILLED_BAD_MESSAGE, false); |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 Profile* ExtensionFunctionDispatcher::profile() { | 501 Profile* ExtensionFunctionDispatcher::profile() { |
| 502 return profile_; | 502 return profile_; |
| 503 } | 503 } |
| OLD | NEW |