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

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

Issue 2499373002: Implementation for feature policy - fullscreen (Closed)
Patch Set: Bug fix: handling the case when frame parent does not exist Created 4 years 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 11 matching lines...) Expand all
22 * 22 *
23 * You should have received a copy of the GNU Library General Public License 23 * You should have received a copy of the GNU Library General Public License
24 * along with this library; see the file COPYING.LIB. If not, write to 24 * along with this library; see the file COPYING.LIB. If not, write to
25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 * Boston, MA 02110-1301, USA. 26 * Boston, MA 02110-1301, USA.
27 * 27 *
28 */ 28 */
29 29
30 #include "core/dom/Fullscreen.h" 30 #include "core/dom/Fullscreen.h"
31 31
32 #include "bindings/core/v8/ConditionalFeatures.h"
32 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
33 #include "core/dom/ElementTraversal.h" 34 #include "core/dom/ElementTraversal.h"
34 #include "core/dom/StyleEngine.h" 35 #include "core/dom/StyleEngine.h"
35 #include "core/events/Event.h" 36 #include "core/events/Event.h"
36 #include "core/frame/FrameHost.h" 37 #include "core/frame/FrameHost.h"
37 #include "core/frame/HostsUsingFeatures.h" 38 #include "core/frame/HostsUsingFeatures.h"
38 #include "core/frame/LocalFrame.h" 39 #include "core/frame/LocalFrame.h"
39 #include "core/frame/Settings.h" 40 #include "core/frame/Settings.h"
40 #include "core/frame/UseCounter.h" 41 #include "core/frame/UseCounter.h"
41 #include "core/html/HTMLIFrameElement.h" 42 #include "core/html/HTMLIFrameElement.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 String message = ExceptionMessages::failedToExecute( 94 String message = ExceptionMessages::failedToExecute(
94 "requestFullscreen", "Element", 95 "requestFullscreen", "Element",
95 "API can only be initiated by a user gesture."); 96 "API can only be initiated by a user gesture.");
96 document.addConsoleMessage( 97 document.addConsoleMessage(
97 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message)); 98 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, message));
98 99
99 return false; 100 return false;
100 } 101 }
101 102
102 // https://fullscreen.spec.whatwg.org/#fullscreen-is-supported 103 // https://fullscreen.spec.whatwg.org/#fullscreen-is-supported
103 bool fullscreenIsSupported(const Document& document) { 104 // TODO(lunalu): update the placement of the feature policy code once it is in
105 // https://fullscreen.spec.whatwg.org/.
106 bool fullscreenIsSupported(Document& document) {
107 LocalFrame* frame = document.frame();
108 if (!frame)
109 return false;
110
104 // Fullscreen is supported if there is no previously-established user 111 // Fullscreen is supported if there is no previously-established user
105 // preference, security risk, or platform limitation. 112 // preference, security risk, or platform limitation.
106 return !document.settings() || document.settings()->fullscreenSupported(); 113 bool fullscreenSupported =
114 !document.settings() || document.settings()->fullscreenSupported();
115
116 if (!RuntimeEnabledFeatures::featurePolicyEnabled()) {
117 return fullscreenSupported;
118 }
119
120 // TODO(lunalu): clean all of this up once iframe attributes are supported
121 // for feature policy.
122 if (Frame* parent = frame->tree().parent()) {
123 // If FeaturePolicy is enabled, check the fullscreen is not disabled by
124 // policy in the parent frame.
125 if (fullscreenSupported &&
126 parent->securityContext()->getFeaturePolicy()->isFeatureEnabled(
foolip 2016/12/07 16:09:25 I was working on https://codereview.chromium.org/2
127 kFullscreenFeature)) {
128 return true;
129 }
130 }
131 // Even if the iframe allowfullscreen attribute is not present, allow
132 // fullscreen to be enabled by feature policy.
133 else if (isFeatureEnabledInFrame(kFullscreenFeature, frame)) {
134 return true;
135 }
136
137 document.addConsoleMessage(ConsoleMessage::create(
138 JSMessageSource, WarningMessageLevel,
139 "Fullscreen API is disabled by feature policy for this frame"));
140 return false;
107 } 141 }
108 142
109 // https://fullscreen.spec.whatwg.org/#fullscreen-element-ready-check 143 // https://fullscreen.spec.whatwg.org/#fullscreen-element-ready-check
110 bool fullscreenElementReady(const Element& element) { 144 bool fullscreenElementReady(const Element& element) {
111 // A fullscreen element ready check for an element |element| returns true if 145 // A fullscreen element ready check for an element |element| returns true if
112 // all of the following are true, and false otherwise: 146 // all of the following are true, and false otherwise:
113 147
114 // |element| is in a document. 148 // |element| is in a document.
115 if (!element.isConnected()) 149 if (!element.isConnected())
116 return false; 150 return false;
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 801
768 DEFINE_TRACE(Fullscreen) { 802 DEFINE_TRACE(Fullscreen) {
769 visitor->trace(m_currentFullScreenElement); 803 visitor->trace(m_currentFullScreenElement);
770 visitor->trace(m_fullscreenElementStack); 804 visitor->trace(m_fullscreenElementStack);
771 visitor->trace(m_eventQueue); 805 visitor->trace(m_eventQueue);
772 Supplement<Document>::trace(visitor); 806 Supplement<Document>::trace(visitor);
773 ContextLifecycleObserver::trace(visitor); 807 ContextLifecycleObserver::trace(visitor);
774 } 808 }
775 809
776 } // namespace blink 810 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698