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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLKeygenElement.cpp

Issue 2536993002: Remove support for the keygen tag (Closed)
Patch Set: Rebased Created 3 years, 12 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 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 *
23 */
24
25 #include "core/html/HTMLKeygenElement.h"
26
27 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
28 #include "core/HTMLNames.h"
29 #include "core/dom/Document.h"
30 #include "core/dom/Text.h"
31 #include "core/dom/shadow/ShadowRoot.h"
32 #include "core/frame/Deprecation.h"
33 #include "core/html/FormData.h"
34 #include "core/html/HTMLOptionElement.h"
35 #include "core/html/HTMLSelectElement.h"
36 #include "core/layout/LayoutBlockFlow.h"
37 #include "core/loader/FrameLoaderClient.h"
38 #include "platform/text/PlatformLocale.h"
39 #include "public/platform/Platform.h"
40 #include "public/platform/WebLocalizedString.h"
41 #include "wtf/StdLibExtras.h"
42
43 using namespace blink;
44
45 namespace blink {
46
47 using namespace HTMLNames;
48
49 HTMLKeygenElement::HTMLKeygenElement(Document& document)
50 : HTMLFormControlElementWithState(keygenTag, document) {
51 Deprecation::countDeprecation(document, UseCounter::HTMLKeygenElement);
52 if (document.frame())
53 document.frame()->loader().client()->didUseKeygen();
54 }
55
56 HTMLKeygenElement* HTMLKeygenElement::create(Document& document) {
57 HTMLKeygenElement* keygen = new HTMLKeygenElement(document);
58 keygen->ensureUserAgentShadowRoot();
59 return keygen;
60 }
61
62 LayoutObject* HTMLKeygenElement::createLayoutObject(
63 const ComputedStyle& style) {
64 // TODO(mstensho): While it's harmful and meaningless to allow most display
65 // types on replaced content (e.g. table, table-row or flex), it would be
66 // useful to honor at least some of them. Table-cell (and maybe table-caption
67 // too), for instance. See crbug.com/335040
68 return new LayoutBlockFlow(this);
69 }
70
71 void HTMLKeygenElement::didAddUserAgentShadowRoot(ShadowRoot& root) {
72 DEFINE_STATIC_LOCAL(AtomicString, keygenSelectPseudoId,
73 ("-webkit-keygen-select"));
74
75 Vector<String> keys;
76 keys.reserveCapacity(2);
77 keys.push_back(
78 locale().queryString(WebLocalizedString::KeygenMenuHighGradeKeySize));
79 keys.push_back(
80 locale().queryString(WebLocalizedString::KeygenMenuMediumGradeKeySize));
81
82 // Create a select element with one option element for each key size.
83 HTMLSelectElement* select = HTMLSelectElement::create(document());
84 select->setShadowPseudoId(keygenSelectPseudoId);
85 for (const String& key : keys) {
86 HTMLOptionElement* option = HTMLOptionElement::create(document());
87 option->appendChild(Text::create(document(), key));
88 select->appendChild(option);
89 }
90
91 root.appendChild(select);
92 }
93
94 void HTMLKeygenElement::parseAttribute(const QualifiedName& name,
95 const AtomicString& oldValue,
96 const AtomicString& value) {
97 // Reflect disabled attribute on the shadow select element
98 if (name == disabledAttr)
99 shadowSelect()->setAttribute(name, value);
100
101 HTMLFormControlElement::parseAttribute(name, oldValue, value);
102 }
103
104 void HTMLKeygenElement::appendToFormData(FormData& formData) {
105 // Only RSA is supported at this time.
106 const AtomicString& keyType = fastGetAttribute(keytypeAttr);
107 if (!keyType.isNull() && !equalIgnoringCase(keyType, "rsa"))
108 return;
109 SecurityOrigin* topOrigin =
110 document().frame()->tree().top()->securityContext()->getSecurityOrigin();
111 String value = Platform::current()->signedPublicKeyAndChallengeString(
112 shadowSelect()->selectedIndex(), fastGetAttribute(challengeAttr),
113 document().baseURL(), KURL(KURL(), topOrigin->toString()));
114 if (!value.isNull())
115 formData.append(name(), value);
116 }
117
118 const AtomicString& HTMLKeygenElement::formControlType() const {
119 DEFINE_STATIC_LOCAL(const AtomicString, keygen, ("keygen"));
120 return keygen;
121 }
122
123 void HTMLKeygenElement::resetImpl() {
124 shadowSelect()->reset();
125 }
126
127 HTMLSelectElement* HTMLKeygenElement::shadowSelect() const {
128 ShadowRoot* root = userAgentShadowRoot();
129 return root ? toHTMLSelectElementOrDie(root->firstChild()) : nullptr;
130 }
131
132 bool HTMLKeygenElement::isInteractiveContent() const {
133 return true;
134 }
135
136 bool HTMLKeygenElement::supportsAutofocus() const {
137 return true;
138 }
139
140 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLKeygenElement.h ('k') | third_party/WebKit/Source/core/html/HTMLKeygenElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698