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

Side by Side Diff: chrome/browser/password_manager/password_form_manager.cc

Issue 22975006: Save password functionality added to the save password bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor changes Created 7 years, 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/password_manager/password_form_manager.h" 5 #include "chrome/browser/password_manager/password_form_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 form.origin.spec().end(), 99 form.origin.spec().end(),
100 after_scheme2, 100 after_scheme2,
101 observed_form_.origin.spec().end()) 101 observed_form_.origin.spec().end())
102 != form.origin.spec().end(); 102 != form.origin.spec().end();
103 } 103 }
104 return false; 104 return false;
105 } 105 }
106 return true; 106 return true;
107 } 107 }
108 108
109 void PasswordFormManager::SavePassword() {
110 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
111 profile_, Profile::EXPLICIT_ACCESS).get();
112 if (!password_store) {
113 NOTREACHED();
114 return;
115 }
116 DCHECK_EQ(state_, POST_MATCHING_PHASE);
117
118 // Configure the form about to be saved for non-blacklisted status.
119 // This is done as the user can choose to blacklist the password and then
120 // undo the previously selected and save the password.
121 pending_credentials_.preferred = true;
122 pending_credentials_.blacklisted_by_user = false;
123
124 // Save the pending_credentials_ entry marked as not-blacklisted.
125 DCHECK(!profile_->IsOffTheRecord());
126 if (IsNewLogin()) {
127 SaveAsNewLogin(true);
128 } else {
129 UpdateLogin();
130 }
131 }
132
133 void PasswordFormManager::DeleteSavedPassword() {
134 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
135 profile_, Profile::EXPLICIT_ACCESS).get();
136 if (!password_store) {
137 NOTREACHED();
138 return;
139 }
140 password_store->RemoveLogin(pending_credentials_);
141 }
142
109 bool PasswordFormManager::IsBlacklisted() { 143 bool PasswordFormManager::IsBlacklisted() {
110 DCHECK_EQ(state_, POST_MATCHING_PHASE); 144 DCHECK_EQ(state_, POST_MATCHING_PHASE);
111 if (preferred_match_ && preferred_match_->blacklisted_by_user) 145 if (preferred_match_ && preferred_match_->blacklisted_by_user)
112 return true; 146 return true;
113 return false; 147 return false;
114 } 148 }
115 149
116 void PasswordFormManager::PermanentlyBlacklist() { 150 void PasswordFormManager::PermanentlyBlacklist() {
117 DCHECK_EQ(state_, POST_MATCHING_PHASE); 151 DCHECK_EQ(state_, POST_MATCHING_PHASE);
118 152
119 // Configure the form about to be saved for blacklist status. 153 // Configure the form about to be saved for blacklist status.
120 pending_credentials_.preferred = true; 154 pending_credentials_.preferred = true;
121 pending_credentials_.blacklisted_by_user = true; 155 pending_credentials_.blacklisted_by_user = true;
122 pending_credentials_.username_value.clear();
123 pending_credentials_.password_value.clear();
124 156
125 // Retroactively forget existing matches for this form, so we NEVER prompt or 157 // Retroactively forget existing matches for this form, so we NEVER prompt or
126 // autofill it again. 158 // autofill it again.
127 if (!best_matches_.empty()) { 159 if (!best_matches_.empty()) {
128 PasswordFormMap::const_iterator iter; 160 PasswordFormMap::const_iterator iter;
129 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( 161 PasswordStore* password_store = PasswordStoreFactory::GetForProfile(
130 profile_, Profile::EXPLICIT_ACCESS).get(); 162 profile_, Profile::EXPLICIT_ACCESS).get();
131 if (!password_store) { 163 if (!password_store) {
132 NOTREACHED(); 164 NOTREACHED();
133 return; 165 return;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 622
591 void PasswordFormManager::SubmitFailed() { 623 void PasswordFormManager::SubmitFailed() {
592 submit_result_ = kSubmitResultFailed; 624 submit_result_ = kSubmitResultFailed;
593 } 625 }
594 626
595 void PasswordFormManager::SendNotBlacklistedToRenderer() { 627 void PasswordFormManager::SendNotBlacklistedToRenderer() {
596 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); 628 content::RenderViewHost* host = web_contents_->GetRenderViewHost();
597 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), 629 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(),
598 observed_form_)); 630 observed_form_));
599 } 631 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698