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