Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp

Issue 2254533002: [FeaturePolicy] Initial implementation of Feature Policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fp-flag
Patch Set: Remove overaggressive bool transform Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4 #include "bindings/core/v8/ConditionalFeatures.h"
5
6 #include "bindings/core/v8/ScriptController.h"
7 #include "bindings/core/v8/ScriptState.h"
8 #include "bindings/core/v8/WindowProxy.h"
9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
10 #include "core/dom/Document.h"
11 #include "core/dom/ExecutionContext.h"
12 #include "core/frame/LocalFrame.h"
13 #include "core/workers/WorkerGlobalScope.h"
14 #include "platform/feature_policy/FeaturePolicy.h"
15 #include "wtf/text/WTFString.h"
16
17 namespace blink {
18
19 void initializeConditionalFeatures(ExecutionContext* context)
20 {
21 if (context->isDocument()) {
22 LocalFrame* frame = toDocument(context)->frame();
23 if (!frame)
24 return;
25 ScriptState* state = ScriptState::forMainWorld(frame);
26 if (!state)
27 return;
28 if (!frame->script().windowProxy(state->world())->isContextInitialized() )
29 return;
30 v8::HandleScope handleScope(state->isolate());
31 installOriginTrials(state);
32 } else if (context->isWorkerGlobalScope()) {
33 WorkerOrWorkletScriptController* scriptController = toWorkerGlobalScope( context)->scriptController();
34 if (!scriptController)
35 return;
36 ScriptState* state = scriptController->getScriptState();
37 if (!state)
38 return;
39 if (!scriptController->isContextInitialized())
40 return;
41 v8::HandleScope handleScope(state->isolate());
42 installOriginTrials(state);
43 }
44 }
45
46 bool isFeatureEnabledInFrame(const FeaturePolicyFeature* feature, const Frame* f rame)
47 {
48 if (!frame)
49 return FeaturePolicy::isFeatureEnabledByDefault(feature, true);
50 FeaturePolicy* featurePolicy = frame->getFeaturePolicy();
51 if (!featurePolicy)
52 return FeaturePolicy::isFeatureEnabledByDefault(feature, frame->isMainFr ame());
53 return featurePolicy->isFeatureEnabledForOrigin(feature, frame->securityCont ext()->getSecurityOrigin());
54 }
55
56 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698