| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/dispatcher.h" | 5 #include "extensions/renderer/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/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 v8_schema_registry_->AsNativeHandler()); | 971 v8_schema_registry_->AsNativeHandler()); |
| 972 module_system->RegisterNativeHandler( | 972 module_system->RegisterNativeHandler( |
| 973 "print", scoped_ptr<NativeHandler>(new PrintNativeHandler(context))); | 973 "print", scoped_ptr<NativeHandler>(new PrintNativeHandler(context))); |
| 974 module_system->RegisterNativeHandler( | 974 module_system->RegisterNativeHandler( |
| 975 "test_features", | 975 "test_features", |
| 976 scoped_ptr<NativeHandler>(new TestFeaturesNativeHandler(context))); | 976 scoped_ptr<NativeHandler>(new TestFeaturesNativeHandler(context))); |
| 977 module_system->RegisterNativeHandler( | 977 module_system->RegisterNativeHandler( |
| 978 "user_gestures", | 978 "user_gestures", |
| 979 scoped_ptr<NativeHandler>(new UserGesturesNativeHandler(context))); | 979 scoped_ptr<NativeHandler>(new UserGesturesNativeHandler(context))); |
| 980 module_system->RegisterNativeHandler( | 980 module_system->RegisterNativeHandler( |
| 981 "utils", scoped_ptr<NativeHandler>(new UtilsNativeHandler(context))); | 981 "utils_natives", |
| 982 scoped_ptr<NativeHandler>(new UtilsNativeHandler(context))); |
| 982 module_system->RegisterNativeHandler( | 983 module_system->RegisterNativeHandler( |
| 983 "v8_context", | 984 "v8_context", |
| 984 scoped_ptr<NativeHandler>(new V8ContextNativeHandler(context, this))); | 985 scoped_ptr<NativeHandler>(new V8ContextNativeHandler(context, this))); |
| 985 | 986 |
| 986 const Extension* extension = context->extension(); | 987 const Extension* extension = context->extension(); |
| 987 int manifest_version = extension ? extension->manifest_version() : 1; | 988 int manifest_version = extension ? extension->manifest_version() : 1; |
| 988 bool send_request_disabled = | 989 bool send_request_disabled = |
| 989 (extension && Manifest::IsUnpackedLocation(extension->location()) && | 990 (extension && Manifest::IsUnpackedLocation(extension->location()) && |
| 990 BackgroundInfo::HasLazyBackgroundPage(extension)); | 991 BackgroundInfo::HasLazyBackgroundPage(extension)); |
| 991 module_system->RegisterNativeHandler( | 992 module_system->RegisterNativeHandler( |
| 992 "process", | 993 "process", |
| 993 scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler( | 994 scoped_ptr<NativeHandler>(new ProcessInfoNativeHandler( |
| 994 context, | 995 context, |
| 995 context->GetExtensionID(), | 996 context->GetExtensionID(), |
| 996 context->GetContextTypeDescription(), | 997 context->GetContextTypeDescription(), |
| 997 ExtensionsRendererClient::Get()->IsIncognitoProcess(), | 998 ExtensionsRendererClient::Get()->IsIncognitoProcess(), |
| 998 manifest_version, | 999 manifest_version, |
| 999 send_request_disabled))); | 1000 send_request_disabled))); |
| 1000 | 1001 |
| 1001 module_system->RegisterNativeHandler( | 1002 module_system->RegisterNativeHandler( |
| 1002 "event_natives", | 1003 "event_natives", |
| 1003 scoped_ptr<NativeHandler>(new EventBindings(this, context))); | 1004 scoped_ptr<NativeHandler>(new EventBindings(this, context))); |
| 1004 module_system->RegisterNativeHandler( | 1005 module_system->RegisterNativeHandler( |
| 1005 "messaging_natives", | 1006 "messaging_natives", |
| 1006 scoped_ptr<NativeHandler>(MessagingBindings::Get(this, context))); | 1007 scoped_ptr<NativeHandler>(MessagingBindings::Get(this, context))); |
| 1007 module_system->RegisterNativeHandler( | 1008 module_system->RegisterNativeHandler( |
| 1008 "apiDefinitions", | 1009 "apiDefinitions", |
| 1009 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this, context))); | 1010 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this, context))); |
| 1010 module_system->RegisterNativeHandler( | 1011 module_system->RegisterNativeHandler( |
| 1011 "sendRequest", | 1012 "send_request_natives", |
| 1012 scoped_ptr<NativeHandler>( | 1013 scoped_ptr<NativeHandler>( |
| 1013 new SendRequestNatives(request_sender_.get(), context))); | 1014 new SendRequestNatives(request_sender_.get(), context))); |
| 1014 module_system->RegisterNativeHandler( | 1015 module_system->RegisterNativeHandler( |
| 1015 "setIcon", | 1016 "set_icon_natives", |
| 1016 scoped_ptr<NativeHandler>( | 1017 scoped_ptr<NativeHandler>( |
| 1017 new SetIconNatives(request_sender_.get(), context))); | 1018 new SetIconNatives(request_sender_.get(), context))); |
| 1018 module_system->RegisterNativeHandler( | 1019 module_system->RegisterNativeHandler( |
| 1019 "activityLogger", | 1020 "activityLogger", |
| 1020 scoped_ptr<NativeHandler>(new APIActivityLogger(context))); | 1021 scoped_ptr<NativeHandler>(new APIActivityLogger(context))); |
| 1021 module_system->RegisterNativeHandler( | 1022 module_system->RegisterNativeHandler( |
| 1022 "renderViewObserverNatives", | 1023 "renderViewObserverNatives", |
| 1023 scoped_ptr<NativeHandler>(new RenderViewObserverNatives(context))); | 1024 scoped_ptr<NativeHandler>(new RenderViewObserverNatives(context))); |
| 1024 | 1025 |
| 1025 // Natives used by multiple APIs. | 1026 // Natives used by multiple APIs. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1036 scoped_ptr<NativeHandler>(new BlobNativeHandler(context))); | 1037 scoped_ptr<NativeHandler>(new BlobNativeHandler(context))); |
| 1037 module_system->RegisterNativeHandler( | 1038 module_system->RegisterNativeHandler( |
| 1038 "context_menus", | 1039 "context_menus", |
| 1039 scoped_ptr<NativeHandler>(new ContextMenusCustomBindings(context))); | 1040 scoped_ptr<NativeHandler>(new ContextMenusCustomBindings(context))); |
| 1040 module_system->RegisterNativeHandler( | 1041 module_system->RegisterNativeHandler( |
| 1041 "css_natives", scoped_ptr<NativeHandler>(new CssNativeHandler(context))); | 1042 "css_natives", scoped_ptr<NativeHandler>(new CssNativeHandler(context))); |
| 1042 module_system->RegisterNativeHandler( | 1043 module_system->RegisterNativeHandler( |
| 1043 "document_natives", | 1044 "document_natives", |
| 1044 scoped_ptr<NativeHandler>(new DocumentCustomBindings(context))); | 1045 scoped_ptr<NativeHandler>(new DocumentCustomBindings(context))); |
| 1045 module_system->RegisterNativeHandler( | 1046 module_system->RegisterNativeHandler( |
| 1046 "i18n", scoped_ptr<NativeHandler>(new I18NCustomBindings(context))); | 1047 "i18n_natives", |
| 1048 scoped_ptr<NativeHandler>(new I18NCustomBindings(context))); |
| 1047 module_system->RegisterNativeHandler( | 1049 module_system->RegisterNativeHandler( |
| 1048 "id_generator", | 1050 "id_generator", |
| 1049 scoped_ptr<NativeHandler>(new IdGeneratorCustomBindings(context))); | 1051 scoped_ptr<NativeHandler>(new IdGeneratorCustomBindings(context))); |
| 1050 module_system->RegisterNativeHandler( | 1052 module_system->RegisterNativeHandler( |
| 1051 "runtime", scoped_ptr<NativeHandler>(new RuntimeCustomBindings(context))); | 1053 "runtime_natives", |
| 1054 scoped_ptr<NativeHandler>(new RuntimeCustomBindings(context))); |
| 1052 | 1055 |
| 1053 delegate_->RegisterNativeHandlers(this, module_system, context); | 1056 delegate_->RegisterNativeHandlers(this, module_system, context); |
| 1054 } | 1057 } |
| 1055 | 1058 |
| 1056 void Dispatcher::PopulateSourceMap() { | 1059 void Dispatcher::PopulateSourceMap() { |
| 1057 // Libraries. | 1060 // Libraries. |
| 1058 source_map_.RegisterSource("entryIdManager", IDR_ENTRY_ID_MANAGER); | 1061 source_map_.RegisterSource("entryIdManager", IDR_ENTRY_ID_MANAGER); |
| 1059 source_map_.RegisterSource(kEventBindings, IDR_EVENT_BINDINGS_JS); | 1062 source_map_.RegisterSource(kEventBindings, IDR_EVENT_BINDINGS_JS); |
| 1060 source_map_.RegisterSource("imageUtil", IDR_IMAGE_UTIL_JS); | 1063 source_map_.RegisterSource("imageUtil", IDR_IMAGE_UTIL_JS); |
| 1061 source_map_.RegisterSource("json_schema", IDR_JSON_SCHEMA_JS); | 1064 source_map_.RegisterSource("json_schema", IDR_JSON_SCHEMA_JS); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 return v8::Handle<v8::Object>(); | 1233 return v8::Handle<v8::Object>(); |
| 1231 | 1234 |
| 1232 if (bind_name) | 1235 if (bind_name) |
| 1233 *bind_name = split.back(); | 1236 *bind_name = split.back(); |
| 1234 | 1237 |
| 1235 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) | 1238 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) |
| 1236 : bind_object; | 1239 : bind_object; |
| 1237 } | 1240 } |
| 1238 | 1241 |
| 1239 } // namespace extensions | 1242 } // namespace extensions |
| OLD | NEW |