WebHTTPBody: Keep track of whether the data includes passwords.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 12:41:37 +0000 (12:41 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 12:41:37 +0000 (12:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81003

Patch by Marja Hölttä <marja@google.com> on 2012-03-14
Reviewed by Darin Fisher.

This change enables Chrome to save HTTP bodies selectively, only
if they don't contain passwords.

Source/WebCore:

* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create): Check if the data contains passwords.
* platform/network/FormData.cpp:
(WebCore::FormData::FormData): Added containsPasswordData, setContainsPasswordData.
* platform/network/FormData.h:
(WebCore::FormData::containsPasswordData): Added.
(WebCore::FormData::setHasPasswordData): Added.
(FormData):

Source/WebKit/chromium:

* public/platform/WebHTTPBody.h:
(WebHTTPBody): Added containsPasswordData, setContainsPasswordData.
* src/WebHTTPBody.cpp:
(WebKit::WebHTTPBody::containsPasswordData): Added.
(WebKit):
(WebKit::WebHTTPBody::setContainsPasswordData): Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110695 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/loader/FormSubmission.cpp
Source/WebCore/platform/network/FormData.cpp
Source/WebCore/platform/network/FormData.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/platform/WebHTTPBody.h
Source/WebKit/chromium/src/WebHTTPBody.cpp

index bf06ab0..e44d48d 100644 (file)
@@ -1,3 +1,22 @@
+2012-03-14  Marja Hölttä  <marja@google.com>
+
+        WebHTTPBody: Keep track of whether the data includes passwords.
+        https://bugs.webkit.org/show_bug.cgi?id=81003
+
+        Reviewed by Darin Fisher.
+
+        This change enables Chrome to save HTTP bodies selectively, only
+        if they don't contain passwords.
+
+        * loader/FormSubmission.cpp:
+        (WebCore::FormSubmission::create): Check if the data contains passwords.
+        * platform/network/FormData.cpp:
+        (WebCore::FormData::FormData): Added containsPasswordData, setContainsPasswordData.
+        * platform/network/FormData.h:
+        (WebCore::FormData::containsPasswordData): Added.
+        (WebCore::FormData::setHasPasswordData): Added.
+        (FormData):
+
 2012-03-14  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Add snippets tab to scripts navigator.
index 0cab710..d69ce6e 100644 (file)
@@ -180,6 +180,7 @@ PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const A
     RefPtr<DOMFormData> domFormData = DOMFormData::create(dataEncoding.encodingForFormSubmission());
     Vector<pair<String, String> > formValues;
 
+    bool containsPasswordData = false;
     for (unsigned i = 0; i < form->associatedElements().size(); ++i) {
         FormAssociatedElement* control = form->associatedElements()[i];
         HTMLElement* element = toHTMLElement(control);
@@ -192,6 +193,8 @@ PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const A
                 if (input->isSearchField())
                     input->addSearchResult();
             }
+            if (input->isPasswordField() && !input->value().isEmpty())
+                containsPasswordData = true;
         }
     }
 
@@ -211,6 +214,7 @@ PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const A
     }
 
     formData->setIdentifier(generateFormDataIdentifier());
+    formData->setContainsPasswordData(containsPasswordData);
     String targetOrBaseTarget = copiedAttributes.target().isEmpty() ? document->baseTarget() : copiedAttributes.target();
     RefPtr<FormState> formState = FormState::create(form, formValues, document->frame(), trigger);
     return adoptRef(new FormSubmission(copiedAttributes.method(), actionURL, targetOrBaseTarget, encodingType, formState.release(), formData.release(), boundary, lockHistory, event));
index 9665bbd..f581746 100644 (file)
@@ -43,6 +43,7 @@ inline FormData::FormData()
     : m_identifier(0)
     , m_hasGeneratedFiles(false)
     , m_alwaysStream(false)
+    , m_containsPasswordData(false)
 {
 }
 
@@ -52,6 +53,7 @@ inline FormData::FormData(const FormData& data)
     , m_identifier(data.m_identifier)
     , m_hasGeneratedFiles(false)
     , m_alwaysStream(false)
+    , m_containsPasswordData(data.m_containsPasswordData)
 {
     // We shouldn't be copying FormData that hasn't already removed its generated files
     // but just in case, make sure the new FormData is ready to generate its own files.
index 213ddde..1498136 100644 (file)
@@ -135,6 +135,9 @@ public:
     void setIdentifier(int64_t identifier) { m_identifier = identifier; }
     int64_t identifier() const { return m_identifier; }
 
+    bool containsPasswordData() const { return m_containsPasswordData; }
+    void setContainsPasswordData(bool containsPasswordData) { m_containsPasswordData = containsPasswordData; }
+
     static EncodingType parseEncodingType(const String& type)
     {
         if (equalIgnoringCase(type, "text/plain"))
@@ -156,6 +159,7 @@ private:
     bool m_hasGeneratedFiles;
     bool m_alwaysStream;
     Vector<char> m_boundary;
+    bool m_containsPasswordData;
 };
 
 inline bool operator==(const FormData& a, const FormData& b)
index d2bdcf8..1cf4344 100644 (file)
@@ -1,3 +1,20 @@
+2012-03-14  Marja Hölttä  <marja@google.com>
+
+        WebHTTPBody: Keep track of whether the data includes passwords.
+        https://bugs.webkit.org/show_bug.cgi?id=81003
+
+        Reviewed by Darin Fisher.
+
+        This change enables Chrome to save HTTP bodies selectively, only
+        if they don't contain passwords.
+
+        * public/platform/WebHTTPBody.h:
+        (WebHTTPBody): Added containsPasswordData, setContainsPasswordData.
+        * src/WebHTTPBody.cpp:
+        (WebKit::WebHTTPBody::containsPasswordData): Added.
+        (WebKit):
+        (WebKit::WebHTTPBody::setContainsPasswordData): Added.
+
 2012-03-14  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed.  Rolled DEPS.
index e978563..5c63860 100644 (file)
@@ -92,6 +92,9 @@ public:
     WEBKIT_EXPORT long long identifier() const;
     WEBKIT_EXPORT void setIdentifier(long long);
 
+    WEBKIT_EXPORT bool containsPasswordData() const;
+    WEBKIT_EXPORT void setContainsPasswordData(bool);
+
 #if WEBKIT_IMPLEMENTATION
     WebHTTPBody(const WTF::PassRefPtr<WebCore::FormData>&);
     WebHTTPBody& operator=(const WTF::PassRefPtr<WebCore::FormData>&);
index d67a701..d8a0647 100644 (file)
@@ -150,6 +150,16 @@ void WebHTTPBody::setIdentifier(long long identifier)
     return m_private->setIdentifier(identifier);
 }
 
+bool WebHTTPBody::containsPasswordData() const
+{
+    return m_private->containsPasswordData();
+}
+
+void WebHTTPBody::setContainsPasswordData(bool containsPasswordData)
+{
+    m_private->setContainsPasswordData(containsPasswordData);
+}
+
 WebHTTPBody::WebHTTPBody(const PassRefPtr<FormData>& data)
     : m_private(static_cast<WebHTTPBodyPrivate*>(data.leakRef()))
 {