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