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

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

Issue 6368011: Clean up WebNavigationObserver by taking out password specific callbacks, and... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_manager.h" 5 #include "chrome/browser/password_manager/password_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/metrics/user_metrics.h" 12 #include "chrome/browser/metrics/user_metrics.h"
13 #include "chrome/browser/password_manager/password_form_manager.h" 13 #include "chrome/browser/password_manager/password_form_manager.h"
14 #include "chrome/browser/password_manager/password_manager_delegate.h" 14 #include "chrome/browser/password_manager/password_manager_delegate.h"
15 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/notification_registrar.h" 17 #include "chrome/common/notification_registrar.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "chrome/common/render_messages.h"
19 #include "chrome/common/render_messages_params.h" 20 #include "chrome/common/render_messages_params.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 22
22 using webkit_glue::PasswordForm; 23 using webkit_glue::PasswordForm;
23 using webkit_glue::PasswordFormMap; 24 using webkit_glue::PasswordFormMap;
24 25
25 // static 26 // static
26 void PasswordManager::RegisterUserPrefs(PrefService* prefs) { 27 void PasswordManager::RegisterUserPrefs(PrefService* prefs) {
27 prefs->RegisterBooleanPref(prefs::kPasswordManagerEnabled, true); 28 prefs->RegisterBooleanPref(prefs::kPasswordManagerEnabled, true);
28 prefs->RegisterBooleanPref(prefs::kPasswordManagerAllowShowPasswords, true); 29 prefs->RegisterBooleanPref(prefs::kPasswordManagerAllowShowPasswords, true);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 152 }
152 } 153 }
153 154
154 void PasswordManager::DidNavigateAnyFramePostCommit( 155 void PasswordManager::DidNavigateAnyFramePostCommit(
155 const NavigationController::LoadCommittedDetails& details, 156 const NavigationController::LoadCommittedDetails& details,
156 const ViewHostMsg_FrameNavigate_Params& params) { 157 const ViewHostMsg_FrameNavigate_Params& params) {
157 if (params.password_form.origin.is_valid()) 158 if (params.password_form.origin.is_valid())
158 ProvisionallySavePassword(params.password_form); 159 ProvisionallySavePassword(params.password_form);
159 } 160 }
160 161
161 void PasswordManager::PasswordFormsFound( 162 bool PasswordManager::OnMessageReceived(const IPC::Message& message) {
163 bool handled = true;
164 IPC_BEGIN_MESSAGE_MAP(PasswordManager, message)
165 IPC_MESSAGE_HANDLER(ViewHostMsg_PasswordFormsFound, OnPasswordFormsFound)
166 IPC_MESSAGE_HANDLER(ViewHostMsg_PasswordFormsVisible,
167 OnPasswordFormsVisible)
168 IPC_MESSAGE_UNHANDLED(handled = false)
169 IPC_END_MESSAGE_MAP()
170 return handled;
171 }
172
173 void PasswordManager::OnPasswordFormsFound(
162 const std::vector<PasswordForm>& forms) { 174 const std::vector<PasswordForm>& forms) {
163 if (!delegate_->GetProfileForPasswordManager()) 175 if (!delegate_->GetProfileForPasswordManager())
164 return; 176 return;
165 if (!*password_manager_enabled_) 177 if (!*password_manager_enabled_)
166 return; 178 return;
167 179
168 // Ask the SSLManager for current security. 180 // Ask the SSLManager for current security.
169 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors(); 181 bool had_ssl_error = delegate_->DidLastPageLoadEncounterSSLErrors();
170 182
171 std::vector<PasswordForm>::const_iterator iter; 183 std::vector<PasswordForm>::const_iterator iter;
172 for (iter = forms.begin(); iter != forms.end(); iter++) { 184 for (iter = forms.begin(); iter != forms.end(); iter++) {
173 bool ssl_valid = iter->origin.SchemeIsSecure() && !had_ssl_error; 185 bool ssl_valid = iter->origin.SchemeIsSecure() && !had_ssl_error;
174 PasswordFormManager* manager = 186 PasswordFormManager* manager =
175 new PasswordFormManager(delegate_->GetProfileForPasswordManager(), 187 new PasswordFormManager(delegate_->GetProfileForPasswordManager(),
176 this, *iter, ssl_valid); 188 this, *iter, ssl_valid);
177 pending_login_managers_.push_back(manager); 189 pending_login_managers_.push_back(manager);
178 manager->FetchMatchingLoginsFromPasswordStore(); 190 manager->FetchMatchingLoginsFromPasswordStore();
179 } 191 }
180 } 192 }
181 193
182 void PasswordManager::PasswordFormsVisible( 194 void PasswordManager::OnPasswordFormsVisible(
183 const std::vector<PasswordForm>& visible_forms) { 195 const std::vector<PasswordForm>& visible_forms) {
184 if (!provisional_save_manager_.get()) 196 if (!provisional_save_manager_.get())
185 return; 197 return;
186 std::vector<PasswordForm>::const_iterator iter; 198 std::vector<PasswordForm>::const_iterator iter;
187 for (iter = visible_forms.begin(); iter != visible_forms.end(); iter++) { 199 for (iter = visible_forms.begin(); iter != visible_forms.end(); iter++) {
188 if (provisional_save_manager_->DoesManage(*iter)) { 200 if (provisional_save_manager_->DoesManage(*iter)) {
189 // The form trying to be saved has immediately re-appeared. Assume login 201 // The form trying to be saved has immediately re-appeared. Assume login
190 // failure and abort this save, by clearing provisional_save_manager_. 202 // failure and abort this save, by clearing provisional_save_manager_.
191 // Don't delete the login managers since the user may try again 203 // Don't delete the login managers since the user may try again
192 // and we want to be able to save in that case. 204 // and we want to be able to save in that case.
(...skipping 24 matching lines...) Expand all
217 return; 229 return;
218 } 230 }
219 default: 231 default:
220 if (observer_) { 232 if (observer_) {
221 observer_->OnAutofillDataAvailable( 233 observer_->OnAutofillDataAvailable(
222 UTF16ToWideHack(preferred_match->username_value), 234 UTF16ToWideHack(preferred_match->username_value),
223 UTF16ToWideHack(preferred_match->password_value)); 235 UTF16ToWideHack(preferred_match->password_value));
224 } 236 }
225 } 237 }
226 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager.h ('k') | chrome/browser/password_manager/password_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698