Fix for Username and password showing overlapped in outlook.com
authorbhargavi.k <bhargavi.k@samsung.com>
Thu, 5 Sep 2013 04:09:07 +0000 (09:39 +0530)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Thu, 5 Sep 2013 10:34:44 +0000 (10:34 +0000)
[Title]  Fix for Username and password showing overlapped in outlook.com
[Issue#] N_SE-50239
[Problem] usename default text and actual username text is getting overlapped and display some corruption
[Cause]  This site's user name and password data is being stored, this is secure site hence this data should not be stored.
[Solution] Checking for autocomplete property of password filed , if it is false, then password data is not stored in DB
           Hence the username is not overlapped with default text on edit fields.

Change-Id: I557c9151dad77c51f9a5f8d3fc6115659965780b

13 files changed:
Source/WebCore/html/HTMLFormElement.cpp
Source/WebCore/html/HTMLFormElement.h
Source/WebKit2/UIProcess/API/C/WKPage.h
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/ewk_view_private.h
Source/WebKit2/UIProcess/WebFormClient.cpp
Source/WebKit2/UIProcess/WebFormClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/efl/FormClientEfl.cpp
Source/WebKit2/UIProcess/efl/FormClientEfl.h
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

index 5ce8a15..5a8fb29 100644 (file)
@@ -326,6 +326,29 @@ void HTMLFormElement::getTextFieldValues(StringPairVector& fieldNamesAndValues)
     }
 }
 
+#if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
+bool HTMLFormElement::isAutoCompletePasswordField() const
+{
+    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
+        FormAssociatedElement* control = m_associatedElements[i];
+        HTMLElement* element = toHTMLElement(control);
+        if (!element->hasLocalName(inputTag))
+            continue;
+
+        HTMLInputElement* input = static_cast<HTMLInputElement*>(control);
+        if (!input->isTextField())
+            continue;
+
+        if (!input->isPasswordField())
+            continue;
+
+        return input->shouldAutocomplete();
+    }
+
+    return true;
+}
+#endif
+
 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool processingUserGesture, FormSubmissionTrigger formSubmissionTrigger)
 {
     FrameView* view = document()->view();
index 9d47394..c6345ee 100755 (executable)
@@ -114,6 +114,10 @@ public:
 
     void getTextFieldValues(StringPairVector& fieldNamesAndValues) const;
 
+#if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
+    bool isAutoCompletePasswordField() const;
+#endif
+
 private:
     HTMLFormElement(const QualifiedName&, Document*);
 
index 6b8a999..22eea4f 100755 (executable)
@@ -164,7 +164,7 @@ enum { kWKPagePolicyClientCurrentVersion = 0 };
 
 // Form Client.
 //#if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, bool containsPasswordData, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo);
+typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, bool containsPasswordData, bool isAutoComplete, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo);
 //#else
 //typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo);
 //#endif
index e7ca8c7..571773f 100755 (executable)
@@ -1722,13 +1722,18 @@ void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name,
     smartData->api->formdata_candidate_show(smartData, inputFieldRect.x(), inputFieldRect.y(), inputFieldRect.width(), inputFieldRect.height());
 }
 
-void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm)
+void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm, bool isAutoComplete)
 {
     EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
     EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl);
     if (!ewk_settings_autofill_password_form_enabled_get(ewk_view_settings_get(ewkView))
         && !ewk_settings_form_candidate_data_enabled_get(ewk_view_settings_get(ewkView)))
         return;
+
+    // if isAutoComplete is off then return
+    if (isPasswordForm && !isAutoComplete)
+        return;
+
     ewk_view_context_get(ewkView)->addFormData(impl->url(), formData, isPasswordForm);
 }
 
@@ -1746,18 +1751,17 @@ void ewk_view_form_password_data_fill(Evas_Object* ewkView)
     if (!passwordFormData.size())
         return;
 
-    String passwordFormAutofill = String::fromUTF8("try { function passwordFormAutofill() { var inputFields;");
+    String passwordFormAutofill = "try { function passwordFormAutofill() { var inputFields;";
     for (size_t i = 0; i < passwordFormData.size(); i++) {
-        passwordFormAutofill += String::fromUTF8(" inputFields = document.getElementsByName(\"");
-        passwordFormAutofill += passwordFormData[i].first;
-        passwordFormAutofill += String::fromUTF8("\");");
-        passwordFormAutofill += String::fromUTF8(" for (var i = 0; i < inputFields.length; i++)");
-        passwordFormAutofill += String::fromUTF8(" if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\"))");
-        passwordFormAutofill += String::fromUTF8(" inputFields[i].value = \"");
-        passwordFormAutofill += passwordFormData[i].second;
-        passwordFormAutofill += String::fromUTF8("\";");
+        passwordFormAutofill += String::format(" inputFields = document.getElementsByName(\"%s\");"
+            " for (var i = 0; i < inputFields.length; i++)"
+            " if (inputFields[i].tagName.toLowerCase() == \"input\" && (inputFields[i].type.toLowerCase() == \"text\" || inputFields[i].type.toLowerCase() == \"password\" || inputFields[i].type.toLowerCase() == \"email\")"
+            " && inputFields[i].autocomplete.toLowerCase() != \"off\")"
+            " inputFields[i].value = \"",passwordFormData[i].first.utf8().data());
+            passwordFormAutofill.append(passwordFormData[i].second);
+            passwordFormAutofill += "\";";
     }
-    passwordFormAutofill += String::fromUTF8("} passwordFormAutofill(); } catch(e) { }");
+    passwordFormAutofill += "} passwordFormAutofill(); } catch(e) { }";
     ewk_view_script_execute(ewkView, passwordFormAutofill.utf8().data(), 0, 0);
 }
 
index f1afdb6..ba5ad9e 100755 (executable)
@@ -272,7 +272,7 @@ void ewk_view_popup_menu_update(Evas_Object* ewkView, WebCore::TextDirection tex
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
 void ewk_view_form_password_data_fill(Evas_Object* ewkView);
-void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm);
+void ewk_view_form_data_add(Evas_Object* ewkView, WKDictionaryRef& formData, bool isPasswordForm, bool isAutoComplete);
 void ewk_view_form_candidate_data_get(Evas_Object* ewkView, const String& name, Vector<String>& candidates);
 void ewk_view_text_change_in_textfield(Evas_Object* ewkView, const String& name, const String& value);
 #endif
index 63cceea..7b71d0b 100644 (file)
@@ -34,7 +34,7 @@
 namespace WebKit {
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-bool WebFormClient::willSubmitForm(WebPageProxy* page, WebFrameProxy* frame, WebFrameProxy* sourceFrame, const Vector<std::pair<String, String> >& textFieldValues, bool containsPasswordData, APIObject* userData, WebFormSubmissionListenerProxy* listener)
+bool WebFormClient::willSubmitForm(WebPageProxy* page, WebFrameProxy* frame, WebFrameProxy* sourceFrame, const Vector<std::pair<String, String> >& textFieldValues, bool containsPasswordData, bool isAutoComplete, APIObject* userData, WebFormSubmissionListenerProxy* listener)
 #else
 bool WebFormClient::willSubmitForm(WebPageProxy* page, WebFrameProxy* frame, WebFrameProxy* sourceFrame, const Vector<std::pair<String, String> >& textFieldValues, APIObject* userData, WebFormSubmissionListenerProxy* listener)
 #endif
@@ -48,7 +48,7 @@ bool WebFormClient::willSubmitForm(WebPageProxy* page, WebFrameProxy* frame, Web
     RefPtr<ImmutableDictionary> textFieldsMap = ImmutableDictionary::adopt(map);
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-    m_client.willSubmitForm(toAPI(page), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), containsPasswordData, toAPI(userData), toAPI(listener), m_client.clientInfo);
+    m_client.willSubmitForm(toAPI(page), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), containsPasswordData, isAutoComplete, toAPI(userData), toAPI(listener), m_client.clientInfo);
 #else
     m_client.willSubmitForm(toAPI(page), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), toAPI(userData), toAPI(listener), m_client.clientInfo);
 #endif
index 23c7d7d..c71388e 100644 (file)
@@ -42,7 +42,7 @@ class WebFormSubmissionListenerProxy;
 class WebFormClient : public APIClient<WKPageFormClient, kWKPageFormClientCurrentVersion> {
 public:
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-    bool willSubmitForm(WebPageProxy*, WebFrameProxy*, WebFrameProxy*, const Vector<std::pair<String, String> >& textFieldValues, bool containsPasswordData, APIObject* userData, WebFormSubmissionListenerProxy*);
+    bool willSubmitForm(WebPageProxy*, WebFrameProxy*, WebFrameProxy*, const Vector<std::pair<String, String> >& textFieldValues, bool containsPasswordData, bool isAutoComplete, APIObject* userData, WebFormSubmissionListenerProxy*);
 #else
     bool willSubmitForm(WebPageProxy*, WebFrameProxy*, WebFrameProxy*, const Vector<std::pair<String, String> >& textFieldValues, APIObject* userData, WebFormSubmissionListenerProxy*); 
 #endif
index c94ae70..861959a 100755 (executable)
@@ -2558,7 +2558,7 @@ void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const ResourceError
 // FormClient
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, bool containsPasswordData, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
+void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, bool containsPasswordData, bool isAutoComplete, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
 #else
 void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
 #endif
@@ -2576,7 +2576,7 @@ void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, cons
 
     RefPtr<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-    if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues.stringPairVector(), containsPasswordData, userData.get(), listener.get()))
+    if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues.stringPairVector(), containsPasswordData, isAutoComplete, userData.get(), listener.get()))
 #else
     if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues.stringPairVector(), userData.get(), listener.get()))
 #endif
index 148310c..55c3b41 100755 (executable)
@@ -1129,7 +1129,7 @@ private:
     void unableToImplementPolicy(uint64_t frameID, const WebCore::ResourceError&, CoreIPC::ArgumentDecoder* arguments);
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-    void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, bool containsPasswordData, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
+    void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, bool containsPasswordData, bool isAutoComplete, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
 #else
     void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
 #endif
index 78b95a2..cd21189 100755 (executable)
@@ -221,7 +221,7 @@ messages -> WebPageProxy {
 
     # Forms messages
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-    WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, bool containsPasswordData, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData)
+    WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, bool containsPasswordData, bool isAutoComplete, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData)
 #endif
 #if !ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
     WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData)
index 07bb50f..1bab147 100755 (executable)
@@ -38,12 +38,12 @@ static inline FormClientEfl* toFormClientEfl(const void* clientInfo)
 }
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-void FormClientEfl::willSubmitForm(WKPageRef, WKFrameRef, WKFrameRef sourceFrame, WKDictionaryRef values, bool containsPasswordData, WKTypeRef, WKFormSubmissionListenerRef listener, const void* clientInfo)
+void FormClientEfl::willSubmitForm(WKPageRef, WKFrameRef, WKFrameRef sourceFrame, WKDictionaryRef values, bool containsPasswordData, bool isAutoComplete, WKTypeRef, WKFormSubmissionListenerRef listener, const void* clientInfo)
 {
     FormClientEfl* formClient = toFormClientEfl(clientInfo);
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-    ewk_view_form_data_add(formClient->m_viewImpl->view(), values, containsPasswordData);
+    ewk_view_form_data_add(formClient->m_viewImpl->view(), values, containsPasswordData, isAutoComplete);
 #endif
 
     RefPtr<Ewk_Form_Submission_Request> request = Ewk_Form_Submission_Request::create(values, listener);
index 65d2cc3..2024c1f 100755 (executable)
@@ -44,7 +44,7 @@ private:
     explicit FormClientEfl(EwkViewImpl*);
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-    static void willSubmitForm(WKPageRef, WKFrameRef, WKFrameRef, WKDictionaryRef, bool, WKTypeRef, WKFormSubmissionListenerRef, const void*);
+    static void willSubmitForm(WKPageRef, WKFrameRef, WKFrameRef, WKDictionaryRef, bool, bool, WKTypeRef, WKFormSubmissionListenerRef, const void*);
 #else
     static void willSubmitForm(WKPageRef, WKFrameRef, WKFrameRef, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef, const void* clientInfo);
 #endif
index 9ad4c86..8acd3e0 100755 (executable)
@@ -819,7 +819,12 @@ void WebFrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction function,
     StringPairVector valuesVector(values);
 
 #if ENABLE(TIZEN_WEBKIT2_FORM_DATABASE)
-    webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), valuesVector, formState->containsPasswordData(), listenerID, InjectedBundleUserMessageEncoder(userData.get())));
+    bool isAutoComplete = true;
+
+    if (form)
+        isAutoComplete = form->isAutoCompletePasswordField();
+
+    webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), valuesVector, formState->containsPasswordData(), isAutoComplete, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
 #else
     webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), valuesVector, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
 #endif