Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / components / password_manager / core / browser / password_form_manager.cc
index 8ce07fa..ed2981c 100644 (file)
@@ -23,6 +23,8 @@ using autofill::PasswordForm;
 using autofill::PasswordFormMap;
 using base::Time;
 
+namespace password_manager {
+
 namespace {
 
 enum PasswordGenerationSubmissionEvent {
@@ -407,6 +409,7 @@ void PasswordFormManager::OnRequestDone(
 
   // Check to see if the user told us to ignore this site in the past.
   if (preferred_match_->blacklisted_by_user) {
+    client_->PasswordAutofillWasBlocked(best_matches_);
     manager_action_ = kManagerActionBlacklisted;
     return;
   }
@@ -630,18 +633,21 @@ void PasswordFormManager::CheckForAccountCreationForm(
 int PasswordFormManager::ScoreResult(const PasswordForm& candidate) const {
   DCHECK_EQ(state_, MATCHING_PHASE);
   // For scoring of candidate login data:
-  // The most important element that should match is the origin, followed by
-  // the action, the password name, the submit button name, and finally the
-  // username input field name.
+  // The most important element that should match is the signon_realm followed
+  // by the origin, the action, the password name, the submit button name, and
+  // finally the username input field name.
+  // If public suffix origin match was not used, it gives an addition of
+  // 128 (1 << 7).
   // Exact origin match gives an addition of 64 (1 << 6) + # of matching url
   // dirs.
   // Partial match gives an addition of 32 (1 << 5) + # matching url dirs
   // That way, a partial match cannot trump an exact match even if
   // the partial one matches all other attributes (action, elements) (and
   // regardless of the matching depth in the URL path).
-  // If public suffix origin match was not used, it gives an addition of
-  // 16 (1 << 4).
   int score = 0;
+  if (!candidate.IsPublicSuffixMatch()) {
+    score += 1 << 7;
+  }
   if (candidate.origin == observed_form_.origin) {
     // This check is here for the most common case which
     // is we have a single match in the db for the given host,
@@ -665,8 +671,6 @@ int PasswordFormManager::ScoreResult(const PasswordForm& candidate) const {
     score += (depth > 0) ? 1 << 5 : 0;
   }
   if (observed_form_.scheme == PasswordForm::SCHEME_HTML) {
-    if (!candidate.IsPublicSuffixMatch())
-      score += 1 << 4;
     if (candidate.action == observed_form_.action)
       score += 1 << 3;
     if (candidate.password_element == observed_form_.password_element)
@@ -691,3 +695,5 @@ void PasswordFormManager::SubmitFailed() {
   if (has_generated_password_)
     LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMISSION_FAILED);
 }
+
+}  // namespace password_manager