| OLD | NEW |
| 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/renderer/extensions/dispatcher.h" | 5 #include "chrome/renderer/extensions/dispatcher.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/sha1.h" | 12 #include "base/sha1.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "chrome/common/child_process_logging.h" | 17 #include "chrome/common/child_process_logging.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/chrome_version_info.h" | 19 #include "chrome/common/chrome_version_info.h" |
| 20 #include "chrome/common/extensions/api/extension_api.h" | 20 #include "chrome/common/extensions/api/extension_api.h" |
| 21 #include "chrome/common/extensions/background_info.h" | 21 #include "chrome/common/extensions/background_info.h" |
| 22 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
| 23 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
| 24 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 25 #include "chrome/common/extensions/extension_messages.h" | 24 #include "chrome/common/extensions/extension_messages.h" |
| 26 #include "chrome/common/extensions/features/feature.h" | 25 #include "chrome/common/extensions/features/feature.h" |
| 27 #include "chrome/common/extensions/features/feature_channel.h" | 26 #include "chrome/common/extensions/features/feature_channel.h" |
| 28 #include "chrome/common/extensions/manifest.h" | 27 #include "chrome/common/extensions/manifest.h" |
| 29 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" | 28 #include "chrome/common/extensions/manifest_handlers/externally_connectable.h" |
| 30 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" | 29 #include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h" |
| 31 #include "chrome/common/extensions/message_bundle.h" | 30 #include "chrome/common/extensions/message_bundle.h" |
| 32 #include "chrome/common/extensions/permissions/permission_set.h" | 31 #include "chrome/common/extensions/permissions/permission_set.h" |
| 33 #include "chrome/common/extensions/permissions/permissions_data.h" | 32 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 34 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #include "chrome/renderer/extensions/tts_custom_bindings.h" | 71 #include "chrome/renderer/extensions/tts_custom_bindings.h" |
| 73 #include "chrome/renderer/extensions/user_script_slave.h" | 72 #include "chrome/renderer/extensions/user_script_slave.h" |
| 74 #include "chrome/renderer/extensions/web_request_custom_bindings.h" | 73 #include "chrome/renderer/extensions/web_request_custom_bindings.h" |
| 75 #include "chrome/renderer/extensions/webstore_bindings.h" | 74 #include "chrome/renderer/extensions/webstore_bindings.h" |
| 76 #include "chrome/renderer/resource_bundle_source_map.h" | 75 #include "chrome/renderer/resource_bundle_source_map.h" |
| 77 #include "content/public/renderer/render_thread.h" | 76 #include "content/public/renderer/render_thread.h" |
| 78 #include "content/public/renderer/render_view.h" | 77 #include "content/public/renderer/render_view.h" |
| 79 #include "content/public/renderer/v8_value_converter.h" | 78 #include "content/public/renderer/v8_value_converter.h" |
| 80 #include "extensions/common/constants.h" | 79 #include "extensions/common/constants.h" |
| 81 #include "extensions/common/features/feature_provider.h" | 80 #include "extensions/common/features/feature_provider.h" |
| 81 #include "extensions/common/manifest_constants.h" |
| 82 #include "extensions/common/view_type.h" | 82 #include "extensions/common/view_type.h" |
| 83 #include "grit/common_resources.h" | 83 #include "grit/common_resources.h" |
| 84 #include "grit/renderer_resources.h" | 84 #include "grit/renderer_resources.h" |
| 85 #include "third_party/WebKit/public/platform/WebString.h" | 85 #include "third_party/WebKit/public/platform/WebString.h" |
| 86 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 86 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 87 #include "third_party/WebKit/public/web/WebCustomElement.h" | 87 #include "third_party/WebKit/public/web/WebCustomElement.h" |
| 88 #include "third_party/WebKit/public/web/WebDataSource.h" | 88 #include "third_party/WebKit/public/web/WebDataSource.h" |
| 89 #include "third_party/WebKit/public/web/WebDocument.h" | 89 #include "third_party/WebKit/public/web/WebDocument.h" |
| 90 #include "third_party/WebKit/public/web/WebFrame.h" | 90 #include "third_party/WebKit/public/web/WebFrame.h" |
| 91 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 91 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 function_names_.insert(names[i]); | 506 function_names_.insert(names[i]); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void Dispatcher::OnSetSystemFont(const std::string& font_family, | 509 void Dispatcher::OnSetSystemFont(const std::string& font_family, |
| 510 const std::string& font_size) { | 510 const std::string& font_size) { |
| 511 system_font_family_ = font_family; | 511 system_font_family_ = font_family; |
| 512 system_font_size_ = font_size; | 512 system_font_size_ = font_size; |
| 513 } | 513 } |
| 514 | 514 |
| 515 void Dispatcher::OnSetChannel(int channel) { | 515 void Dispatcher::OnSetChannel(int channel) { |
| 516 extensions::SetCurrentChannel( | 516 SetCurrentChannel(static_cast<chrome::VersionInfo::Channel>(channel)); |
| 517 static_cast<chrome::VersionInfo::Channel>(channel)); | |
| 518 } | 517 } |
| 519 | 518 |
| 520 void Dispatcher::OnMessageInvoke(const std::string& extension_id, | 519 void Dispatcher::OnMessageInvoke(const std::string& extension_id, |
| 521 const std::string& module_name, | 520 const std::string& module_name, |
| 522 const std::string& function_name, | 521 const std::string& function_name, |
| 523 const base::ListValue& args, | 522 const base::ListValue& args, |
| 524 bool user_gesture) { | 523 bool user_gesture) { |
| 525 InvokeModuleSystemMethod( | 524 InvokeModuleSystemMethod( |
| 526 NULL, extension_id, module_name, function_name, args, user_gesture); | 525 NULL, extension_id, module_name, function_name, args, user_gesture); |
| 527 } | 526 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 RegisterBinding("app", context); | 656 RegisterBinding("app", context); |
| 658 RegisterBinding("webstore", context); | 657 RegisterBinding("webstore", context); |
| 659 | 658 |
| 660 // ... and that the runtime API might be available if any extension can | 659 // ... and that the runtime API might be available if any extension can |
| 661 // connect to it. | 660 // connect to it. |
| 662 bool runtime_is_available = false; | 661 bool runtime_is_available = false; |
| 663 for (ExtensionSet::const_iterator it = extensions_.begin(); | 662 for (ExtensionSet::const_iterator it = extensions_.begin(); |
| 664 it != extensions_.end(); ++it) { | 663 it != extensions_.end(); ++it) { |
| 665 ExternallyConnectableInfo* info = | 664 ExternallyConnectableInfo* info = |
| 666 static_cast<ExternallyConnectableInfo*>((*it)->GetManifestData( | 665 static_cast<ExternallyConnectableInfo*>((*it)->GetManifestData( |
| 667 extension_manifest_keys::kExternallyConnectable)); | 666 manifest_keys::kExternallyConnectable)); |
| 668 if (info && info->matches.MatchesURL(context->GetURL())) { | 667 if (info && info->matches.MatchesURL(context->GetURL())) { |
| 669 runtime_is_available = true; | 668 runtime_is_available = true; |
| 670 break; | 669 break; |
| 671 } | 670 } |
| 672 } | 671 } |
| 673 if (runtime_is_available) | 672 if (runtime_is_available) |
| 674 RegisterBinding("runtime", context); | 673 RegisterBinding("runtime", context); |
| 675 break; | 674 break; |
| 676 } | 675 } |
| 677 | 676 |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 } | 1413 } |
| 1415 | 1414 |
| 1416 void Dispatcher::OnCancelSuspend(const std::string& extension_id) { | 1415 void Dispatcher::OnCancelSuspend(const std::string& extension_id) { |
| 1417 DispatchEvent(extension_id, kOnSuspendCanceledEvent); | 1416 DispatchEvent(extension_id, kOnSuspendCanceledEvent); |
| 1418 } | 1417 } |
| 1419 | 1418 |
| 1420 // TODO(kalman): This is checking for the wrong thing, it should be checking if | 1419 // TODO(kalman): This is checking for the wrong thing, it should be checking if |
| 1421 // the frame's security origin is unique. The extension sandbox directive is | 1420 // the frame's security origin is unique. The extension sandbox directive is |
| 1422 // checked for in chrome/common/extensions/csp_handler.cc. | 1421 // checked for in chrome/common/extensions/csp_handler.cc. |
| 1423 bool Dispatcher::IsSandboxedPage(const GURL& url) const { | 1422 bool Dispatcher::IsSandboxedPage(const GURL& url) const { |
| 1424 if (url.SchemeIs(extensions::kExtensionScheme)) { | 1423 if (url.SchemeIs(kExtensionScheme)) { |
| 1425 const Extension* extension = extensions_.GetByID(url.host()); | 1424 const Extension* extension = extensions_.GetByID(url.host()); |
| 1426 if (extension) { | 1425 if (extension) { |
| 1427 return extensions::SandboxedPageInfo::IsSandboxedPage(extension, | 1426 return SandboxedPageInfo::IsSandboxedPage(extension, url.path()); |
| 1428 url.path()); | |
| 1429 } | 1427 } |
| 1430 } | 1428 } |
| 1431 return false; | 1429 return false; |
| 1432 } | 1430 } |
| 1433 | 1431 |
| 1434 Feature::Context Dispatcher::ClassifyJavaScriptContext( | 1432 Feature::Context Dispatcher::ClassifyJavaScriptContext( |
| 1435 const std::string& extension_id, | 1433 const std::string& extension_id, |
| 1436 int extension_group, | 1434 int extension_group, |
| 1437 const GURL& url, | 1435 const GURL& url, |
| 1438 const WebKit::WebSecurityOrigin& origin) { | 1436 const WebKit::WebSecurityOrigin& origin) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 RenderView* background_view = | 1557 RenderView* background_view = |
| 1560 ExtensionHelper::GetBackgroundPage(extension_id); | 1558 ExtensionHelper::GetBackgroundPage(extension_id); |
| 1561 if (background_view) { | 1559 if (background_view) { |
| 1562 background_view->Send(new ExtensionHostMsg_EventAck( | 1560 background_view->Send(new ExtensionHostMsg_EventAck( |
| 1563 background_view->GetRoutingID())); | 1561 background_view->GetRoutingID())); |
| 1564 } | 1562 } |
| 1565 } | 1563 } |
| 1566 } | 1564 } |
| 1567 | 1565 |
| 1568 } // namespace extensions | 1566 } // namespace extensions |
| OLD | NEW |