| 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS); | 688 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS); |
| 689 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS); | 689 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS); |
| 690 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS); | 690 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS); |
| 691 source_map_.RegisterSource("webRequestInternal", | 691 source_map_.RegisterSource("webRequestInternal", |
| 692 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); | 692 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); |
| 693 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); | 693 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); |
| 694 | 694 |
| 695 // Platform app sources that are not API-specific.. | 695 // Platform app sources that are not API-specific.. |
| 696 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); | 696 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); |
| 697 source_map_.RegisterSource("webview", IDR_WEB_VIEW_JS); | 697 source_map_.RegisterSource("webview", IDR_WEB_VIEW_JS); |
| 698 source_map_.RegisterSource("webview.experimentalAPI", |
| 699 IDR_WEB_VIEW_EXPERIMENTAL_API_JS); |
| 698 source_map_.RegisterSource("denyWebview", IDR_WEB_VIEW_DENY_JS); | 700 source_map_.RegisterSource("denyWebview", IDR_WEB_VIEW_DENY_JS); |
| 699 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); | 701 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); |
| 700 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); | 702 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); |
| 701 } | 703 } |
| 702 | 704 |
| 703 void Dispatcher::PopulateLazyBindingsMap() { | 705 void Dispatcher::PopulateLazyBindingsMap() { |
| 704 lazy_bindings_map_["app"] = InstallAppBindings; | 706 lazy_bindings_map_["app"] = InstallAppBindings; |
| 705 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; | 707 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; |
| 706 } | 708 } |
| 707 | 709 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 } | 823 } |
| 822 } | 824 } |
| 823 | 825 |
| 824 // Inject custom JS into the platform app context. | 826 // Inject custom JS into the platform app context. |
| 825 if (IsWithinPlatformApp(frame)) | 827 if (IsWithinPlatformApp(frame)) |
| 826 module_system->Require("platformApp"); | 828 module_system->Require("platformApp"); |
| 827 | 829 |
| 828 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | 830 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
| 829 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView); | 831 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView); |
| 830 module_system->Require(has_permission ? "webview" : "denyWebview"); | 832 module_system->Require(has_permission ? "webview" : "denyWebview"); |
| 833 if (has_permission && |
| 834 extension->HasAPIPermission(APIPermission::kExperimental)) { |
| 835 module_system->Require("webview.experimentalAPI"); |
| 836 } |
| 831 } | 837 } |
| 832 | 838 |
| 833 context->set_module_system(module_system.Pass()); | 839 context->set_module_system(module_system.Pass()); |
| 834 | 840 |
| 835 context->DispatchOnLoadEvent( | 841 context->DispatchOnLoadEvent( |
| 836 ChromeRenderProcessObserver::is_incognito_process(), | 842 ChromeRenderProcessObserver::is_incognito_process(), |
| 837 manifest_version); | 843 manifest_version); |
| 838 | 844 |
| 839 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); | 845 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); |
| 840 } | 846 } |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 1155 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
| 1150 v8::ThrowException( | 1156 v8::ThrowException( |
| 1151 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 1157 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
| 1152 return false; | 1158 return false; |
| 1153 } | 1159 } |
| 1154 | 1160 |
| 1155 return true; | 1161 return true; |
| 1156 } | 1162 } |
| 1157 | 1163 |
| 1158 } // namespace extensions | 1164 } // namespace extensions |
| OLD | NEW |