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

Unified Diff: third_party/WebKit/Source/core/html/HTMLIFrameElementAllow.cpp

Issue 2680083002: Initial Implementation of Iframe Attribute for Feature Policy (Part 1) (Closed)
Patch Set: Removed getAllowedFeatureNames() from HTMLIFrameElement Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/HTMLIFrameElementAllow.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLIFrameElementAllow.cpp b/third_party/WebKit/Source/core/html/HTMLIFrameElementAllow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4fd4fdbc9a03bb14bc7e4cf508475816711ec10b
--- /dev/null
+++ b/third_party/WebKit/Source/core/html/HTMLIFrameElementAllow.cpp
@@ -0,0 +1,76 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
iclelland 2017/02/08 15:06:24 2017
lunalu1 2017/02/08 19:50:30 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/html/HTMLIFrameElementAllow.h"
+
+#include "core/html/HTMLIFrameElement.h"
+#include "platform/feature_policy/FeaturePolicy.h"
+
+using blink::WebFeaturePolicyFeature;
+
+namespace blink {
+
+namespace {
+
+bool isTokenSupported(const AtomicString& token) {
+ if (FeaturePolicy::getWebFeaturePolicyFeature(token.getString()) ==
+ WebFeaturePolicyFeature::NotFound) {
+ return false;
+ }
+ return true;
+}
+
+} // namespace
+
+HTMLIFrameElementAllow::HTMLIFrameElementAllow(HTMLIFrameElement* element)
+ : DOMTokenList(this), m_element(element) {}
+
+HTMLIFrameElementAllow::~HTMLIFrameElementAllow() {}
+
+DEFINE_TRACE(HTMLIFrameElementAllow) {
+ visitor->trace(m_element);
+ DOMTokenList::trace(visitor);
+ DOMTokenListObserver::trace(visitor);
+}
+
+HashSet<WebFeaturePolicyFeature>
+HTMLIFrameElementAllow::parseAllowedFeatureNames(
+ String& invalidTokensErrorMessage) const {
+ HashSet<WebFeaturePolicyFeature> allowedFeatureNames;
+ unsigned numTokenErrors = 0;
+ StringBuilder tokenErrors;
+ const SpaceSplitString& tokens = this->tokens();
+
+ for (size_t i = 0; i < tokens.size(); ++i) {
+ WebFeaturePolicyFeature feature =
+ FeaturePolicy::getWebFeaturePolicyFeature(tokens[i]);
+ if (feature == WebFeaturePolicyFeature::NotFound) {
+ tokenErrors.append(numTokenErrors ? ", '" : "\'");
+ tokenErrors.append(tokens[i]);
+ tokenErrors.append('\'');
+ ++numTokenErrors;
+ } else {
+ allowedFeatureNames.insert(feature);
+ }
+ }
+
+ if (numTokenErrors) {
+ tokenErrors.append(numTokenErrors > 1 ? " are invalid feature names."
+ : " is an invalid feature name.");
+ invalidTokensErrorMessage = tokenErrors.toString();
+ }
+
+ return allowedFeatureNames;
+}
+
+bool HTMLIFrameElementAllow::validateTokenValue(const AtomicString& tokenValue,
+ ExceptionState&) const {
+ return isTokenSupported(tokenValue);
iclelland 2017/02/08 15:06:24 Could this just be return FeaturePolicy::getWebFe
lunalu1 2017/02/08 19:50:30 Done.
+}
+
+void HTMLIFrameElementAllow::valueWasSet() {
+ m_element->allowValueWasSet();
iclelland 2017/02/08 15:06:24 HTMLIframeElementPermissions.cpp has a check -- if
lunalu1 2017/02/08 19:50:30 Done.
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698