| 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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS); | 673 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS); |
| 674 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS); | 674 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS); |
| 675 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS); | 675 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS); |
| 676 source_map_.RegisterSource("webRequestInternal", | 676 source_map_.RegisterSource("webRequestInternal", |
| 677 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); | 677 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); |
| 678 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); | 678 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); |
| 679 | 679 |
| 680 // Platform app sources that are not API-specific.. | 680 // Platform app sources that are not API-specific.. |
| 681 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); | 681 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); |
| 682 source_map_.RegisterSource("webview", IDR_WEB_VIEW_JS); | 682 source_map_.RegisterSource("webview", IDR_WEB_VIEW_JS); |
| 683 source_map_.RegisterSource("webview.permissionAPI", |
| 684 IDR_WEB_VIEW_PERMISSION_API_JS); |
| 683 source_map_.RegisterSource("denyWebview", IDR_WEB_VIEW_DENY_JS); | 685 source_map_.RegisterSource("denyWebview", IDR_WEB_VIEW_DENY_JS); |
| 684 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); | 686 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); |
| 685 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); | 687 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); |
| 686 } | 688 } |
| 687 | 689 |
| 688 void Dispatcher::PopulateLazyBindingsMap() { | 690 void Dispatcher::PopulateLazyBindingsMap() { |
| 689 lazy_bindings_map_["app"] = InstallAppBindings; | 691 lazy_bindings_map_["app"] = InstallAppBindings; |
| 690 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; | 692 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; |
| 691 } | 693 } |
| 692 | 694 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 } | 809 } |
| 808 } | 810 } |
| 809 | 811 |
| 810 // Inject custom JS into the platform app context. | 812 // Inject custom JS into the platform app context. |
| 811 if (IsWithinPlatformApp(frame)) | 813 if (IsWithinPlatformApp(frame)) |
| 812 module_system->Require("platformApp"); | 814 module_system->Require("platformApp"); |
| 813 | 815 |
| 814 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | 816 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
| 815 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView); | 817 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView); |
| 816 module_system->Require(has_permission ? "webview" : "denyWebview"); | 818 module_system->Require(has_permission ? "webview" : "denyWebview"); |
| 819 if (extension->HasAPIPermission(APIPermission::kWebViewPermissionAPI)) |
| 820 module_system->Require("webview.permissionAPI"); |
| 817 } | 821 } |
| 818 | 822 |
| 819 context->set_module_system(module_system.Pass()); | 823 context->set_module_system(module_system.Pass()); |
| 820 | 824 |
| 821 context->DispatchOnLoadEvent( | 825 context->DispatchOnLoadEvent( |
| 822 ChromeRenderProcessObserver::is_incognito_process(), | 826 ChromeRenderProcessObserver::is_incognito_process(), |
| 823 manifest_version); | 827 manifest_version); |
| 824 | 828 |
| 825 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); | 829 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); |
| 826 } | 830 } |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 1137 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
| 1134 v8::ThrowException( | 1138 v8::ThrowException( |
| 1135 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 1139 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
| 1136 return false; | 1140 return false; |
| 1137 } | 1141 } |
| 1138 | 1142 |
| 1139 return true; | 1143 return true; |
| 1140 } | 1144 } |
| 1141 | 1145 |
| 1142 } // namespace extensions | 1146 } // namespace extensions |
| OLD | NEW |