| 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 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS); | 693 source_map_.RegisterSource("ttsEngine", IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS); |
| 694 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS); | 694 source_map_.RegisterSource("types", IDR_TYPES_CUSTOM_BINDINGS_JS); |
| 695 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS); | 695 source_map_.RegisterSource("webRequest", IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS); |
| 696 source_map_.RegisterSource("webRequestInternal", | 696 source_map_.RegisterSource("webRequestInternal", |
| 697 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); | 697 IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS); |
| 698 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); | 698 source_map_.RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); |
| 699 | 699 |
| 700 // Platform app sources that are not API-specific.. | 700 // Platform app sources that are not API-specific.. |
| 701 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); | 701 source_map_.RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); |
| 702 source_map_.RegisterSource("webview", IDR_WEB_VIEW_JS); | 702 source_map_.RegisterSource("webview", IDR_WEB_VIEW_JS); |
| 703 source_map_.RegisterSource("webview.experimental", |
| 704 IDR_WEB_VIEW_EXPERIMENTAL_JS); |
| 703 source_map_.RegisterSource("denyWebview", IDR_WEB_VIEW_DENY_JS); | 705 source_map_.RegisterSource("denyWebview", IDR_WEB_VIEW_DENY_JS); |
| 704 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); | 706 source_map_.RegisterSource("platformApp", IDR_PLATFORM_APP_JS); |
| 705 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); | 707 source_map_.RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); |
| 706 } | 708 } |
| 707 | 709 |
| 708 void Dispatcher::PopulateLazyBindingsMap() { | 710 void Dispatcher::PopulateLazyBindingsMap() { |
| 709 lazy_bindings_map_["app"] = InstallAppBindings; | 711 lazy_bindings_map_["app"] = InstallAppBindings; |
| 710 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; | 712 lazy_bindings_map_["webstore"] = InstallWebstoreBindings; |
| 711 } | 713 } |
| 712 | 714 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 } | 829 } |
| 828 } | 830 } |
| 829 | 831 |
| 830 // Inject custom JS into the platform app context. | 832 // Inject custom JS into the platform app context. |
| 831 if (IsWithinPlatformApp(frame)) | 833 if (IsWithinPlatformApp(frame)) |
| 832 module_system->Require("platformApp"); | 834 module_system->Require("platformApp"); |
| 833 | 835 |
| 834 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | 836 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
| 835 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView); | 837 bool has_permission = extension->HasAPIPermission(APIPermission::kWebView); |
| 836 module_system->Require(has_permission ? "webview" : "denyWebview"); | 838 module_system->Require(has_permission ? "webview" : "denyWebview"); |
| 839 if (has_permission && |
| 840 Feature::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) { |
| 841 module_system->Require("webview.experimental"); |
| 842 } |
| 837 } | 843 } |
| 838 | 844 |
| 839 context->set_module_system(module_system.Pass()); | 845 context->set_module_system(module_system.Pass()); |
| 840 | 846 |
| 841 context->DispatchOnLoadEvent( | 847 context->DispatchOnLoadEvent( |
| 842 ChromeRenderProcessObserver::is_incognito_process(), | 848 ChromeRenderProcessObserver::is_incognito_process(), |
| 843 manifest_version); | 849 manifest_version); |
| 844 | 850 |
| 845 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); | 851 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); |
| 846 } | 852 } |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 1161 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
| 1156 v8::ThrowException( | 1162 v8::ThrowException( |
| 1157 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 1163 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
| 1158 return false; | 1164 return false; |
| 1159 } | 1165 } |
| 1160 | 1166 |
| 1161 return true; | 1167 return true; |
| 1162 } | 1168 } |
| 1163 | 1169 |
| 1164 } // namespace extensions | 1170 } // namespace extensions |
| OLD | NEW |