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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 #include "extensions/renderer/safe_builtins.h" | 66 #include "extensions/renderer/safe_builtins.h" |
67 #include "extensions/renderer/script_context.h" | 67 #include "extensions/renderer/script_context.h" |
68 #include "extensions/renderer/script_context_set.h" | 68 #include "extensions/renderer/script_context_set.h" |
69 #include "extensions/renderer/send_request_natives.h" | 69 #include "extensions/renderer/send_request_natives.h" |
70 #include "extensions/renderer/set_icon_natives.h" | 70 #include "extensions/renderer/set_icon_natives.h" |
71 #include "extensions/renderer/test_features_native_handler.h" | 71 #include "extensions/renderer/test_features_native_handler.h" |
72 #include "extensions/renderer/user_gestures_native_handler.h" | 72 #include "extensions/renderer/user_gestures_native_handler.h" |
73 #include "extensions/renderer/user_script_slave.h" | 73 #include "extensions/renderer/user_script_slave.h" |
74 #include "extensions/renderer/utils_native_handler.h" | 74 #include "extensions/renderer/utils_native_handler.h" |
75 #include "extensions/renderer/v8_context_native_handler.h" | 75 #include "extensions/renderer/v8_context_native_handler.h" |
76 #include "grit/common_resources.h" | |
77 #include "grit/renderer_resources.h" | 76 #include "grit/renderer_resources.h" |
78 #include "third_party/WebKit/public/platform/WebString.h" | 77 #include "third_party/WebKit/public/platform/WebString.h" |
79 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 78 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
80 #include "third_party/WebKit/public/web/WebCustomElement.h" | 79 #include "third_party/WebKit/public/web/WebCustomElement.h" |
81 #include "third_party/WebKit/public/web/WebDataSource.h" | 80 #include "third_party/WebKit/public/web/WebDataSource.h" |
82 #include "third_party/WebKit/public/web/WebDocument.h" | 81 #include "third_party/WebKit/public/web/WebDocument.h" |
83 #include "third_party/WebKit/public/web/WebFrame.h" | 82 #include "third_party/WebKit/public/web/WebFrame.h" |
84 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 83 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
85 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" | 84 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" |
86 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 85 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 if (runtime_is_available) | 859 if (runtime_is_available) |
861 RegisterBinding("runtime", context); | 860 RegisterBinding("runtime", context); |
862 break; | 861 break; |
863 } | 862 } |
864 | 863 |
865 case Feature::BLESSED_EXTENSION_CONTEXT: | 864 case Feature::BLESSED_EXTENSION_CONTEXT: |
866 case Feature::UNBLESSED_EXTENSION_CONTEXT: | 865 case Feature::UNBLESSED_EXTENSION_CONTEXT: |
867 case Feature::CONTENT_SCRIPT_CONTEXT: { | 866 case Feature::CONTENT_SCRIPT_CONTEXT: { |
868 // Extension context; iterate through all the APIs and bind the available | 867 // Extension context; iterate through all the APIs and bind the available |
869 // ones. | 868 // ones. |
870 FeatureProvider* api_feature_provider = FeatureProvider::GetAPIFeatures(); | 869 const FeatureProvider* api_feature_provider = |
| 870 FeatureProvider::GetAPIFeatures(); |
871 const std::vector<std::string>& apis = | 871 const std::vector<std::string>& apis = |
872 api_feature_provider->GetAllFeatureNames(); | 872 api_feature_provider->GetAllFeatureNames(); |
873 for (std::vector<std::string>::const_iterator it = apis.begin(); | 873 for (std::vector<std::string>::const_iterator it = apis.begin(); |
874 it != apis.end(); | 874 it != apis.end(); |
875 ++it) { | 875 ++it) { |
876 const std::string& api_name = *it; | 876 const std::string& api_name = *it; |
877 Feature* feature = api_feature_provider->GetFeature(api_name); | 877 Feature* feature = api_feature_provider->GetFeature(api_name); |
878 DCHECK(feature); | 878 DCHECK(feature); |
879 | 879 |
880 // Internal APIs are included via require(api_name) from internal code | 880 // Internal APIs are included via require(api_name) from internal code |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 // Check if this API has an ancestor. If the API's ancestor is available and | 1180 // Check if this API has an ancestor. If the API's ancestor is available and |
1181 // the API is not available, don't install the bindings for this API. If | 1181 // the API is not available, don't install the bindings for this API. If |
1182 // the API is available and its ancestor is not, delete the ancestor and | 1182 // the API is available and its ancestor is not, delete the ancestor and |
1183 // install the bindings for the API. This is to prevent loading the ancestor | 1183 // install the bindings for the API. This is to prevent loading the ancestor |
1184 // API schema if it will not be needed. | 1184 // API schema if it will not be needed. |
1185 // | 1185 // |
1186 // For example: | 1186 // For example: |
1187 // If app is available and app.window is not, just install app. | 1187 // If app is available and app.window is not, just install app. |
1188 // If app.window is available and app is not, delete app and install | 1188 // If app.window is available and app is not, delete app and install |
1189 // app.window on a new object so app does not have to be loaded. | 1189 // app.window on a new object so app does not have to be loaded. |
1190 FeatureProvider* api_feature_provider = FeatureProvider::GetAPIFeatures(); | 1190 const FeatureProvider* api_feature_provider = |
| 1191 FeatureProvider::GetAPIFeatures(); |
1191 std::string ancestor_name; | 1192 std::string ancestor_name; |
1192 bool only_ancestor_available = false; | 1193 bool only_ancestor_available = false; |
1193 | 1194 |
1194 for (size_t i = 0; i < split.size() - 1; ++i) { | 1195 for (size_t i = 0; i < split.size() - 1; ++i) { |
1195 ancestor_name += (i ? "." : "") + split[i]; | 1196 ancestor_name += (i ? "." : "") + split[i]; |
1196 if (api_feature_provider->GetFeature(ancestor_name) && | 1197 if (api_feature_provider->GetFeature(ancestor_name) && |
1197 context->GetAvailability(ancestor_name).is_available() && | 1198 context->GetAvailability(ancestor_name).is_available() && |
1198 !context->GetAvailability(api_name).is_available()) { | 1199 !context->GetAvailability(api_name).is_available()) { |
1199 only_ancestor_available = true; | 1200 only_ancestor_available = true; |
1200 break; | 1201 break; |
(...skipping 11 matching lines...) Expand all Loading... |
1212 return v8::Handle<v8::Object>(); | 1213 return v8::Handle<v8::Object>(); |
1213 | 1214 |
1214 if (bind_name) | 1215 if (bind_name) |
1215 *bind_name = split.back(); | 1216 *bind_name = split.back(); |
1216 | 1217 |
1217 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) | 1218 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) |
1218 : bind_object; | 1219 : bind_object; |
1219 } | 1220 } |
1220 | 1221 |
1221 } // namespace extensions | 1222 } // namespace extensions |
OLD | NEW |