OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef ConditionalFeatures_h | 5 #ifndef ConditionalFeatures_h |
6 #define ConditionalFeatures_h | 6 #define ConditionalFeatures_h |
7 | 7 |
8 #include "bindings/core/v8/DOMWrapperWorld.h" | 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
10 #include "platform/feature_policy/FeaturePolicy.h" | 10 #include "platform/feature_policy/FeaturePolicy.h" |
11 #include "wtf/HashSet.h" | |
11 #include <v8.h> | 12 #include <v8.h> |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 class ScriptState; | 16 class ScriptState; |
16 class LocalFrame; | 17 class LocalFrame; |
17 | 18 |
18 using InstallConditionalFeaturesFunction = void (*)(const WrapperTypeInfo*, | 19 using InstallConditionalFeaturesFunction = void (*)(const WrapperTypeInfo*, |
19 const ScriptState*, | 20 const ScriptState*, |
20 v8::Local<v8::Object>, | 21 v8::Local<v8::Object>, |
21 v8::Local<v8::Function>); | 22 v8::Local<v8::Function>); |
22 | 23 |
24 using InstallConditionalFeaturesIfNeededFunction = | |
25 bool (*)(const WrapperTypeInfo*, const ScriptState*); | |
26 | |
27 using GetAffectedTypesForConditionalFeatureFunction = | |
28 void (*)(const String&, HashSet<const WrapperTypeInfo*>*); | |
29 | |
23 // Installs all of the conditionally enabled V8 bindings for the given type, in | 30 // Installs all of the conditionally enabled V8 bindings for the given type, in |
24 // a specific context. This is called in V8PerContextData, after the constructor | 31 // a specific context. This is called in V8PerContextData, after the constructor |
25 // and prototype for the type have been created. It indirectly calls the | 32 // and prototype for the type have been created. It indirectly calls the |
26 // function set by |setInstallConditionalFeaturesFunction|. | 33 // function set by |setInstallConditionalFeaturesFunction|. |
27 CORE_EXPORT void installConditionalFeatures(const WrapperTypeInfo*, | 34 CORE_EXPORT void installConditionalFeatures(const WrapperTypeInfo*, |
28 const ScriptState*, | 35 const ScriptState*, |
29 v8::Local<v8::Object>, | 36 v8::Local<v8::Object>, |
30 v8::Local<v8::Function>); | 37 v8::Local<v8::Function>); |
31 | 38 |
32 // Sets the function to be called by |installConditionalFeatures|. The function | 39 // Sets the function to be called by |installConditionalFeatures|. The function |
33 // is initially set to the private |installConditionalFeaturesCore| function, | 40 // is initially set to the private |installConditionalFeaturesCore| function, |
34 // but can be overridden by this function. A pointer to the previously set | 41 // but can be overridden by this function. A pointer to the previously set |
35 // function is returned, so that functions can be chained. | 42 // function is returned, so that functions can be chained. |
36 CORE_EXPORT InstallConditionalFeaturesFunction | 43 CORE_EXPORT InstallConditionalFeaturesFunction |
37 setInstallConditionalFeaturesFunction(InstallConditionalFeaturesFunction); | 44 setInstallConditionalFeaturesFunction(InstallConditionalFeaturesFunction); |
45 CORE_EXPORT InstallConditionalFeaturesIfNeededFunction | |
iclelland
2017/01/20 14:31:19
One way to get rid of the three parallel function
chasej
2017/01/25 19:58:20
I've simplified the approach, so that there's only
| |
46 setInstallConditionalFeaturesIfNeededFunction( | |
47 InstallConditionalFeaturesIfNeededFunction); | |
48 CORE_EXPORT GetAffectedTypesForConditionalFeatureFunction | |
49 setGetAffectedTypesForConditionalFeatureFunction( | |
50 GetAffectedTypesForConditionalFeatureFunction); | |
38 | 51 |
39 // Installs all of the conditionally enabled V8 bindings on the Window object. | 52 // Installs all of the conditionally enabled V8 bindings on the Window object. |
40 // This is called separately from other objects so that attributes and | 53 // This is called separately from other objects so that attributes and |
41 // interfaces which need to be visible on the global object are installed even | 54 // interfaces which need to be visible on the global object are installed even |
42 // when the V8 context is reused (i.e., after navigation) | 55 // when the V8 context is reused (i.e., after navigation) |
43 CORE_EXPORT void installPendingConditionalFeaturesOnWindow(const ScriptState*); | 56 CORE_EXPORT void installPendingConditionalFeaturesOnWindow(const ScriptState*); |
44 | 57 |
58 // Installs all of the conditionally enabled V8 bindings for a feature, if | |
59 // needed. This is called to install a newly-enabled feature on any existing | |
60 // objects. If the target object hasn't been created, nothing is installed. The | |
61 // enabled feature will be instead be installed when the object is created | |
62 // (avoids forcing the creation of objects prematurely). | |
63 // Returns true to indicate the feature is installed (either on existing objects | |
64 // or deferred until object creation). | |
iclelland
2017/01/20 14:31:19
I'm confused about what returning false from this
chasej
2017/01/25 19:58:20
You're right. Ultimately, this function should nev
| |
65 CORE_EXPORT bool installPendingConditionalFeature(const ScriptState*, | |
66 const String&); | |
67 | |
45 CORE_EXPORT bool isFeatureEnabledInFrame(const FeaturePolicy::Feature&, | 68 CORE_EXPORT bool isFeatureEnabledInFrame(const FeaturePolicy::Feature&, |
46 const LocalFrame*); | 69 const LocalFrame*); |
47 | 70 |
48 } // namespace blink | 71 } // namespace blink |
49 | 72 |
50 #endif // ConditionalFeatures_h | 73 #endif // ConditionalFeatures_h |
OLD | NEW |