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

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

Issue 2499373002: Implementation for feature policy - fullscreen (Closed)
Patch Set: Codereview update 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 if (fullscreenSupported) {
iclelland 2016/12/05 20:48:30 Can we add a comment here? Something like "If Fea
lunalu1 2016/12/05 21:07:32 Done.
121 if (frame->tree()
122 .parent()
123 ->securityContext()
124 ->getFeaturePolicy()
125 ->isFeatureEnabled(kFullscreenFeature)) {
126 return true;
127 }
128 } else if (isFeatureEnabledInFrame(kFullscreenFeature, frame)) {
iclelland 2016/12/05 20:48:30 And I'd add a comment here that says "Even if the
lunalu1 2016/12/05 21:07:32 Done.
129 return true;
130 }
131
132 document.addConsoleMessage(ConsoleMessage::create(
133 JSMessageSource, WarningMessageLevel,
134 "Fullscreen API is disabled by feature policy for this frame"));
135 return false;
107 } 136 }
108 137
109 // https://fullscreen.spec.whatwg.org/#fullscreen-element-ready-check 138 // https://fullscreen.spec.whatwg.org/#fullscreen-element-ready-check
110 bool fullscreenElementReady(const Element& element) { 139 bool fullscreenElementReady(const Element& element) {
111 // A fullscreen element ready check for an element |element| returns true if 140 // A fullscreen element ready check for an element |element| returns true if
112 // all of the following are true, and false otherwise: 141 // all of the following are true, and false otherwise:
113 142
114 // |element| is in a document. 143 // |element| is in a document.
115 if (!element.isConnected()) 144 if (!element.isConnected())
116 return false; 145 return false;
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 796
768 DEFINE_TRACE(Fullscreen) { 797 DEFINE_TRACE(Fullscreen) {
769 visitor->trace(m_currentFullScreenElement); 798 visitor->trace(m_currentFullScreenElement);
770 visitor->trace(m_fullscreenElementStack); 799 visitor->trace(m_fullscreenElementStack);
771 visitor->trace(m_eventQueue); 800 visitor->trace(m_eventQueue);
772 Supplement<Document>::trace(visitor); 801 Supplement<Document>::trace(visitor);
773 ContextLifecycleObserver::trace(visitor); 802 ContextLifecycleObserver::trace(visitor);
774 } 803 }
775 804
776 } // namespace blink 805 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698