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

Side by Side Diff: third_party/WebKit/Source/core/dom/Fullscreen.cpp

Issue 2767983003: Initial Implementation of Iframe Attribute for Feature Policy (Part 4) (Closed)
Patch Set: Codereview: nit + added more unit tests for container policy Created 3 years, 7 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
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // is an iframe element with an |allowattribute| attribute specified, and 73 // is an iframe element with an |allowattribute| attribute specified, and
74 // whose node document is allowed to use the feature indicated by 74 // whose node document is allowed to use the feature indicated by
75 // |allowattribute|, then return true. 75 // |allowattribute|, then return true.
76 if (frame->Owner() && frame->Owner()->AllowFullscreen()) 76 if (frame->Owner() && frame->Owner()->AllowFullscreen())
77 return AllowedToUseFullscreen(frame->Tree().Parent()); 77 return AllowedToUseFullscreen(frame->Tree().Parent());
78 78
79 // 4. Return false. 79 // 4. Return false.
80 return false; 80 return false;
81 } 81 }
82 82
83 // If Feature Policy is enabled, then we need this hack to support it, until 83 // 2. If Feature Policy is enabled, return the policy for "fullscreen"
84 // we have proper support for <iframe allowfullscreen> in FP: 84 // feature.
85 85 return frame->IsFeatureEnabled(WebFeaturePolicyFeature::kFullscreen);
86 // 1. If FP, by itself, enables fullscreen in this document, then fullscreen
87 // is allowed.
88 if (frame->IsFeatureEnabled(WebFeaturePolicyFeature::kFullscreen)) {
89 return true;
90 }
91
92 // 2. Otherwise, if the embedding frame's document is allowed to use
93 // fullscreen (either through FP or otherwise), and either:
94 // a) this is a same-origin embedded document, or
95 // b) this document's iframe has the allowfullscreen attribute set,
96 // then fullscreen is allowed.
97 if (!frame->IsMainFrame()) {
98 if (AllowedToUseFullscreen(frame->Tree().Parent())) {
99 return (frame->Owner() && frame->Owner()->AllowFullscreen()) ||
100 frame->Tree()
101 .Parent()
102 ->GetSecurityContext()
103 ->GetSecurityOrigin()
104 ->IsSameSchemeHostPortAndSuborigin(
105 frame->GetSecurityContext()->GetSecurityOrigin());
106 }
107 }
108
109 // Otherwise, fullscreen is not allowed. (If we reach here and this is the
110 // main frame, then fullscreen must have been disabled by FP.)
111 return false;
112 } 86 }
113 87
114 bool AllowedToRequestFullscreen(Document& document) { 88 bool AllowedToRequestFullscreen(Document& document) {
115 // An algorithm is allowed to request fullscreen if one of the following is 89 // An algorithm is allowed to request fullscreen if one of the following is
116 // true: 90 // true:
117 91
118 // The algorithm is triggered by a user activation. 92 // The algorithm is triggered by a user activation.
119 if (UserGestureIndicator::UtilizeUserGesture()) 93 if (UserGestureIndicator::UtilizeUserGesture())
120 return true; 94 return true;
121 95
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 DEFINE_TRACE(Fullscreen) { 847 DEFINE_TRACE(Fullscreen) {
874 visitor->Trace(pending_fullscreen_element_); 848 visitor->Trace(pending_fullscreen_element_);
875 visitor->Trace(fullscreen_element_stack_); 849 visitor->Trace(fullscreen_element_stack_);
876 visitor->Trace(current_full_screen_element_); 850 visitor->Trace(current_full_screen_element_);
877 visitor->Trace(event_queue_); 851 visitor->Trace(event_queue_);
878 Supplement<Document>::Trace(visitor); 852 Supplement<Document>::Trace(visitor);
879 ContextLifecycleObserver::Trace(visitor); 853 ContextLifecycleObserver::Trace(visitor);
880 } 854 }
881 855
882 } // namespace blink 856 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698