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

Side by Side Diff: third_party/WebKit/Source/web/WebFrameSerializer.cpp

Issue 2560693002: Disable form elements in MHTML (Closed)
Patch Set: Address feedback 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate { 78 class MHTMLFrameSerializerDelegate final : public FrameSerializer::Delegate {
79 WTF_MAKE_NONCOPYABLE(MHTMLFrameSerializerDelegate); 79 WTF_MAKE_NONCOPYABLE(MHTMLFrameSerializerDelegate);
80 80
81 public: 81 public:
82 explicit MHTMLFrameSerializerDelegate( 82 explicit MHTMLFrameSerializerDelegate(
83 WebFrameSerializer::MHTMLPartsGenerationDelegate&); 83 WebFrameSerializer::MHTMLPartsGenerationDelegate&);
84 bool shouldIgnoreAttribute(const Element&, const Attribute&) override; 84 bool shouldIgnoreAttribute(const Element&, const Attribute&) override;
85 bool rewriteLink(const Element&, String& rewrittenLink) override; 85 bool rewriteLink(const Element&, String& rewrittenLink) override;
86 bool shouldSkipResourceWithURL(const KURL&) override; 86 bool shouldSkipResourceWithURL(const KURL&) override;
87 bool shouldSkipResource(const Resource&) override; 87 bool shouldSkipResource(const Resource&) override;
88 Vector<Attribute> getCustomAttributes(const Element&) override;
88 89
89 private: 90 private:
90 WebFrameSerializer::MHTMLPartsGenerationDelegate& m_webDelegate; 91 WebFrameSerializer::MHTMLPartsGenerationDelegate& m_webDelegate;
91 }; 92 };
92 93
93 MHTMLFrameSerializerDelegate::MHTMLFrameSerializerDelegate( 94 MHTMLFrameSerializerDelegate::MHTMLFrameSerializerDelegate(
94 WebFrameSerializer::MHTMLPartsGenerationDelegate& webDelegate) 95 WebFrameSerializer::MHTMLPartsGenerationDelegate& webDelegate)
95 : m_webDelegate(webDelegate) {} 96 : m_webDelegate(webDelegate) {}
96 97
97 bool MHTMLFrameSerializerDelegate::shouldIgnoreAttribute( 98 bool MHTMLFrameSerializerDelegate::shouldIgnoreAttribute(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 160 }
160 161
161 bool MHTMLFrameSerializerDelegate::shouldSkipResource( 162 bool MHTMLFrameSerializerDelegate::shouldSkipResource(
162 const Resource& resource) { 163 const Resource& resource) {
163 return m_webDelegate.cacheControlPolicy() == 164 return m_webDelegate.cacheControlPolicy() ==
164 WebFrameSerializerCacheControlPolicy:: 165 WebFrameSerializerCacheControlPolicy::
165 SkipAnyFrameOrResourceMarkedNoStore && 166 SkipAnyFrameOrResourceMarkedNoStore &&
166 resource.hasCacheControlNoStoreHeader(); 167 resource.hasCacheControlNoStoreHeader();
167 } 168 }
168 169
170 Vector<Attribute> MHTMLFrameSerializerDelegate::getCustomAttributes(
171 const Element& element) {
172 Vector<Attribute> attributes;
173
174 // Disable all form elements in MTHML to tell the user that the form cannot be
175 // worked on. MHTML is loaded in full sandboxing mode which disable the form
176 // submission and script execution.
177 if (element.isFormControlElement() &&
178 !element.fastHasAttribute(HTMLNames::disabledAttr)) {
179 Attribute disabledAttribute(HTMLNames::disabledAttr, "");
180 attributes.append(disabledAttribute);
181 }
182
183 return attributes;
184 }
185
169 bool cacheControlNoStoreHeaderPresent( 186 bool cacheControlNoStoreHeaderPresent(
170 const WebLocalFrameImpl& webLocalFrameImpl) { 187 const WebLocalFrameImpl& webLocalFrameImpl) {
171 const ResourceResponse& response = 188 const ResourceResponse& response =
172 webLocalFrameImpl.dataSource()->response().toResourceResponse(); 189 webLocalFrameImpl.dataSource()->response().toResourceResponse();
173 if (response.cacheControlContainsNoStore()) 190 if (response.cacheControlContainsNoStore())
174 return true; 191 return true;
175 192
176 const ResourceRequest& request = 193 const ResourceRequest& request =
177 webLocalFrameImpl.dataSource()->request().toResourceRequest(); 194 webLocalFrameImpl.dataSource()->request().toResourceRequest();
178 return request.cacheControlContainsNoStore(); 195 return request.cacheControlContainsNoStore();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 const WebString& baseTarget) { 340 const WebString& baseTarget) {
324 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|. 341 // TODO(yosin) We should call |FrameSerializer::baseTagDeclarationOf()|.
325 if (baseTarget.isEmpty()) 342 if (baseTarget.isEmpty())
326 return String("<base href=\".\">"); 343 return String("<base href=\".\">");
327 String baseString = "<base href=\".\" target=\"" + 344 String baseString = "<base href=\".\" target=\"" +
328 static_cast<const String&>(baseTarget) + "\">"; 345 static_cast<const String&>(baseTarget) + "\">";
329 return baseString; 346 return baseString;
330 } 347 }
331 348
332 } // namespace blink 349 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698