OLD | NEW |
---|---|
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 Loading... | |
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 } | |
Garrett Casto
2013/08/28 00:08:33
Note, there should be no reason to do this, the pa
npentrel
2013/08/28 08:48:44
Done.
| |
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 | |
109 bool PasswordFormManager::IsBlacklisted() { | 133 bool PasswordFormManager::IsBlacklisted() { |
110 DCHECK_EQ(state_, POST_MATCHING_PHASE); | 134 DCHECK_EQ(state_, POST_MATCHING_PHASE); |
111 if (preferred_match_ && preferred_match_->blacklisted_by_user) | 135 if (preferred_match_ && preferred_match_->blacklisted_by_user) |
112 return true; | 136 return true; |
113 return false; | 137 return false; |
114 } | 138 } |
115 | 139 |
116 void PasswordFormManager::PermanentlyBlacklist() { | 140 void PasswordFormManager::PermanentlyBlacklist() { |
117 DCHECK_EQ(state_, POST_MATCHING_PHASE); | 141 DCHECK_EQ(state_, POST_MATCHING_PHASE); |
118 | 142 |
119 // Configure the form about to be saved for blacklist status. | 143 // Configure the form about to be saved for blacklist status. |
120 pending_credentials_.preferred = true; | 144 pending_credentials_.preferred = true; |
121 pending_credentials_.blacklisted_by_user = true; | 145 pending_credentials_.blacklisted_by_user = true; |
122 pending_credentials_.username_value.clear(); | |
123 pending_credentials_.password_value.clear(); | |
124 | 146 |
125 // Retroactively forget existing matches for this form, so we NEVER prompt or | 147 // Retroactively forget existing matches for this form, so we NEVER prompt or |
126 // autofill it again. | 148 // autofill it again. |
127 if (!best_matches_.empty()) { | 149 if (!best_matches_.empty()) { |
128 PasswordFormMap::const_iterator iter; | 150 PasswordFormMap::const_iterator iter; |
129 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( | 151 PasswordStore* password_store = PasswordStoreFactory::GetForProfile( |
130 profile_, Profile::EXPLICIT_ACCESS).get(); | 152 profile_, Profile::EXPLICIT_ACCESS).get(); |
131 if (!password_store) { | 153 if (!password_store) { |
132 NOTREACHED(); | 154 NOTREACHED(); |
133 return; | 155 return; |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 | 612 |
591 void PasswordFormManager::SubmitFailed() { | 613 void PasswordFormManager::SubmitFailed() { |
592 submit_result_ = kSubmitResultFailed; | 614 submit_result_ = kSubmitResultFailed; |
593 } | 615 } |
594 | 616 |
595 void PasswordFormManager::SendNotBlacklistedToRenderer() { | 617 void PasswordFormManager::SendNotBlacklistedToRenderer() { |
596 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); | 618 content::RenderViewHost* host = web_contents_->GetRenderViewHost(); |
597 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), | 619 host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), |
598 observed_form_)); | 620 observed_form_)); |
599 } | 621 } |
OLD | NEW |