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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 module_system->RegisterNativeHandler("webstore", | 619 module_system->RegisterNativeHandler("webstore", |
620 scoped_ptr<NativeHandler>(new WebstoreBindings(this, context))); | 620 scoped_ptr<NativeHandler>(new WebstoreBindings(this, context))); |
621 } | 621 } |
622 | 622 |
623 void Dispatcher::PopulateSourceMap() { | 623 void Dispatcher::PopulateSourceMap() { |
624 source_map_.RegisterSource("event_bindings", IDR_EVENT_BINDINGS_JS); | 624 source_map_.RegisterSource("event_bindings", IDR_EVENT_BINDINGS_JS); |
625 source_map_.RegisterSource("miscellaneous_bindings", | 625 source_map_.RegisterSource("miscellaneous_bindings", |
626 IDR_MISCELLANEOUS_BINDINGS_JS); | 626 IDR_MISCELLANEOUS_BINDINGS_JS); |
627 source_map_.RegisterSource("schema_generated_bindings", | 627 source_map_.RegisterSource("schema_generated_bindings", |
628 IDR_SCHEMA_GENERATED_BINDINGS_JS); | 628 IDR_SCHEMA_GENERATED_BINDINGS_JS); |
| 629 source_map_.RegisterSource("json", IDR_JSON_JS); |
629 source_map_.RegisterSource("json_schema", IDR_JSON_SCHEMA_JS); | 630 source_map_.RegisterSource("json_schema", IDR_JSON_SCHEMA_JS); |
630 source_map_.RegisterSource("apitest", IDR_EXTENSION_APITEST_JS); | 631 source_map_.RegisterSource("apitest", IDR_EXTENSION_APITEST_JS); |
631 | 632 |
632 // Libraries. | 633 // Libraries. |
633 source_map_.RegisterSource("contentWatcher", IDR_CONTENT_WATCHER_JS); | 634 source_map_.RegisterSource("contentWatcher", IDR_CONTENT_WATCHER_JS); |
634 source_map_.RegisterSource("lastError", IDR_LAST_ERROR_JS); | 635 source_map_.RegisterSource("lastError", IDR_LAST_ERROR_JS); |
635 source_map_.RegisterSource("schemaUtils", IDR_SCHEMA_UTILS_JS); | 636 source_map_.RegisterSource("schemaUtils", IDR_SCHEMA_UTILS_JS); |
636 source_map_.RegisterSource("sendRequest", IDR_SEND_REQUEST_JS); | 637 source_map_.RegisterSource("sendRequest", IDR_SEND_REQUEST_JS); |
637 source_map_.RegisterSource("setIcon", IDR_SET_ICON_JS); | 638 source_map_.RegisterSource("setIcon", IDR_SET_ICON_JS); |
638 source_map_.RegisterSource("utils", IDR_UTILS_JS); | 639 source_map_.RegisterSource("utils", IDR_UTILS_JS); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 case Feature::UNSPECIFIED_CONTEXT: | 797 case Feature::UNSPECIFIED_CONTEXT: |
797 case Feature::WEB_PAGE_CONTEXT: | 798 case Feature::WEB_PAGE_CONTEXT: |
798 // TODO(kalman): see comment below about ExtensionAPI. | 799 // TODO(kalman): see comment below about ExtensionAPI. |
799 InstallBindings(module_system.get(), v8_context, "app"); | 800 InstallBindings(module_system.get(), v8_context, "app"); |
800 InstallBindings(module_system.get(), v8_context, "webstore"); | 801 InstallBindings(module_system.get(), v8_context, "webstore"); |
801 break; | 802 break; |
802 | 803 |
803 case Feature::BLESSED_EXTENSION_CONTEXT: | 804 case Feature::BLESSED_EXTENSION_CONTEXT: |
804 case Feature::UNBLESSED_EXTENSION_CONTEXT: | 805 case Feature::UNBLESSED_EXTENSION_CONTEXT: |
805 case Feature::CONTENT_SCRIPT_CONTEXT: { | 806 case Feature::CONTENT_SCRIPT_CONTEXT: { |
| 807 module_system->Require("json"); // see paranoid comment in json.js |
806 module_system->Require("miscellaneous_bindings"); | 808 module_system->Require("miscellaneous_bindings"); |
807 module_system->Require("schema_generated_bindings"); | 809 module_system->Require("schema_generated_bindings"); |
808 module_system->Require("apitest"); | 810 module_system->Require("apitest"); |
809 | 811 |
810 // TODO(kalman): move this code back out of the switch and execute it | 812 // TODO(kalman): move this code back out of the switch and execute it |
811 // regardless of |context_type|. ExtensionAPI knows how to return the | 813 // regardless of |context_type|. ExtensionAPI knows how to return the |
812 // correct APIs, however, until it doesn't have a 2MB overhead we can't | 814 // correct APIs, however, until it doesn't have a 2MB overhead we can't |
813 // load it in every process. | 815 // load it in every process. |
814 const std::set<std::string>& apis = context->GetAvailableExtensionAPIs(); | 816 const std::set<std::string>& apis = context->GetAvailableExtensionAPIs(); |
815 for (std::set<std::string>::const_iterator i = apis.begin(); | 817 for (std::set<std::string>::const_iterator i = apis.begin(); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 1151 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
1150 v8::ThrowException( | 1152 v8::ThrowException( |
1151 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 1153 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
1152 return false; | 1154 return false; |
1153 } | 1155 } |
1154 | 1156 |
1155 return true; | 1157 return true; |
1156 } | 1158 } |
1157 | 1159 |
1158 } // namespace extensions | 1160 } // namespace extensions |
OLD | NEW |