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_manager_delegate_impl.h" | 5 #include "chrome/browser/password_manager/password_manager_delegate_impl.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
12 #include "chrome/browser/infobars/infobar.h" | 12 #include "chrome/browser/infobars/infobar.h" |
13 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
14 #include "chrome/browser/password_manager/password_form_manager.h" | 14 #include "chrome/browser/password_manager/password_form_manager.h" |
15 #include "chrome/browser/password_manager/password_manager.h" | 15 #include "chrome/browser/password_manager/password_manager.h" |
16 #include "chrome/browser/password_manager/password_manager_metrics_util.h" | 16 #include "chrome/browser/password_manager/password_manager_metrics_util.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 18 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
19 #include "components/autofill/content/browser/autofill_driver_impl.h" | |
20 #include "components/autofill/content/common/autofill_messages.h" | |
21 #include "components/autofill/core/browser/autofill_manager.h" | |
22 #include "components/autofill/core/common/password_form.h" | |
23 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
24 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
25 #include "content/public/browser/render_view_host.h" | |
26 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
27 #include "content/public/common/page_transition_types.h" | |
28 #include "content/public/common/ssl_status.h" | |
29 #include "google_apis/gaia/gaia_urls.h" | 22 #include "google_apis/gaia/gaia_urls.h" |
30 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
31 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
32 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
33 #include "net/cert/cert_status_flags.h" | |
34 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
35 | 27 |
36 | 28 |
37 // SavePasswordInfoBarDelegate ------------------------------------------------ | 29 // SavePasswordInfoBarDelegate ------------------------------------------------ |
38 | 30 |
39 // After a successful *new* login attempt, we take the PasswordFormManager in | 31 // After a successful *new* login attempt, we take the PasswordFormManager in |
40 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while | 32 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while |
41 // the user makes up their mind with the "save password" infobar. Note if the | 33 // the user makes up their mind with the "save password" infobar. Note if the |
42 // login is one we already know about, the end of the line is | 34 // login is one we already know about, the end of the line is |
43 // provisional_save_manager_ because we just update it on success and so such | 35 // provisional_save_manager_ because we just update it on success and so such |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return PASSWORD_INFOBAR; | 201 return PASSWORD_INFOBAR; |
210 } | 202 } |
211 | 203 |
212 | 204 |
213 // PasswordManagerDelegateImpl ------------------------------------------------ | 205 // PasswordManagerDelegateImpl ------------------------------------------------ |
214 | 206 |
215 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PasswordManagerDelegateImpl); | 207 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PasswordManagerDelegateImpl); |
216 | 208 |
217 PasswordManagerDelegateImpl::PasswordManagerDelegateImpl( | 209 PasswordManagerDelegateImpl::PasswordManagerDelegateImpl( |
218 content::WebContents* web_contents) | 210 content::WebContents* web_contents) |
219 : web_contents_(web_contents) { | 211 : web_contents_(web_contents), |
| 212 driver_(web_contents) { |
220 } | 213 } |
221 | 214 |
222 PasswordManagerDelegateImpl::~PasswordManagerDelegateImpl() { | 215 PasswordManagerDelegateImpl::~PasswordManagerDelegateImpl() { |
223 } | 216 } |
224 | 217 |
225 void PasswordManagerDelegateImpl::FillPasswordForm( | 218 void PasswordManagerDelegateImpl::FillPasswordForm( |
226 const autofill::PasswordFormFillData& form_data) { | 219 const autofill::PasswordFormFillData& form_data) { |
227 web_contents_->GetRenderViewHost()->Send( | 220 driver_.FillPasswordForm(form_data); |
228 new AutofillMsg_FillPasswordForm( | |
229 web_contents_->GetRenderViewHost()->GetRoutingID(), | |
230 form_data)); | |
231 } | 221 } |
232 | 222 |
233 void PasswordManagerDelegateImpl::AddSavePasswordInfoBarIfPermitted( | 223 void PasswordManagerDelegateImpl::AddSavePasswordInfoBarIfPermitted( |
234 PasswordFormManager* form_to_save) { | 224 PasswordFormManager* form_to_save) { |
235 std::string uma_histogram_suffix( | 225 std::string uma_histogram_suffix( |
236 password_manager_metrics_util::GroupIdToString( | 226 password_manager_metrics_util::GroupIdToString( |
237 password_manager_metrics_util::MonitoredDomainGroupId( | 227 password_manager_metrics_util::MonitoredDomainGroupId( |
238 form_to_save->realm(), GetProfile()->GetPrefs()))); | 228 form_to_save->realm(), GetProfile()->GetPrefs()))); |
239 SavePasswordInfoBarDelegate::Create( | 229 SavePasswordInfoBarDelegate::Create( |
240 web_contents_, form_to_save, uma_histogram_suffix); | 230 web_contents_, form_to_save, uma_histogram_suffix); |
241 } | 231 } |
242 | 232 |
243 Profile* PasswordManagerDelegateImpl::GetProfile() { | 233 Profile* PasswordManagerDelegateImpl::GetProfile() { |
244 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 234 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
245 } | 235 } |
246 | 236 |
247 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { | 237 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { |
248 content::NavigationEntry* entry = | 238 return driver_.DidLastPageLoadEncounterSSLErrors(); |
249 web_contents_->GetController().GetActiveEntry(); | |
250 if (!entry) { | |
251 NOTREACHED(); | |
252 return false; | |
253 } | |
254 | |
255 return net::IsCertStatusError(entry->GetSSL().cert_status); | |
256 } | 239 } |
OLD | NEW |