| 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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 10 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/password_manager/password_form_manager.h" | 12 #include "chrome/browser/password_manager/password_form_manager.h" |
| 13 #include "chrome/browser/password_manager/password_manager.h" | 13 #include "chrome/browser/password_manager/password_manager.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 15 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 16 #include "components/autofill/browser/autofill_manager.h" | 16 #include "components/autofill/browser/autofill_manager.h" |
| 17 #include "components/autofill/common/autofill_messages.h" | 17 #include "components/autofill/common/autofill_messages.h" |
| 18 #include "content/public/browser/navigation_entry.h" | 18 #include "content/public/browser/navigation_entry.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/common/password_form.h" | 21 #include "content/public/common/password_form.h" |
| 22 #include "content/public/common/ssl_status.h" | 22 #include "content/public/common/ssl_status.h" |
| 23 #include "google_apis/gaia/gaia_urls.h" | 23 #include "google_apis/gaia/gaia_urls.h" |
| 24 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
| 25 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 26 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
| 27 #include "net/cert/cert_status_flags.h" | 27 #include "net/cert/cert_status_flags.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | |
| 30 | 29 |
| 31 | 30 |
| 32 // SavePasswordInfoBarDelegate ------------------------------------------------ | 31 // SavePasswordInfoBarDelegate ------------------------------------------------ |
| 33 | 32 |
| 34 // After a successful *new* login attempt, we take the PasswordFormManager in | 33 // After a successful *new* login attempt, we take the PasswordFormManager in |
| 35 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while | 34 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while |
| 36 // the user makes up their mind with the "save password" infobar. Note if the | 35 // the user makes up their mind with the "save password" infobar. Note if the |
| 37 // login is one we already know about, the end of the line is | 36 // login is one we already know about, the end of the line is |
| 38 // provisional_save_manager_ because we just update it on success and so such | 37 // provisional_save_manager_ because we just update it on success and so such |
| 39 // forms never end up in an infobar. | 38 // forms never end up in an infobar. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 50 REMEMBER_PASSWORD, | 49 REMEMBER_PASSWORD, |
| 51 DONT_REMEMBER_PASSWORD, | 50 DONT_REMEMBER_PASSWORD, |
| 52 NUM_RESPONSE_TYPES, | 51 NUM_RESPONSE_TYPES, |
| 53 }; | 52 }; |
| 54 | 53 |
| 55 SavePasswordInfoBarDelegate(InfoBarService* infobar_service, | 54 SavePasswordInfoBarDelegate(InfoBarService* infobar_service, |
| 56 PasswordFormManager* form_to_save); | 55 PasswordFormManager* form_to_save); |
| 57 virtual ~SavePasswordInfoBarDelegate(); | 56 virtual ~SavePasswordInfoBarDelegate(); |
| 58 | 57 |
| 59 // ConfirmInfoBarDelegate | 58 // ConfirmInfoBarDelegate |
| 60 virtual gfx::Image* GetIcon() const OVERRIDE; | 59 virtual int GetIconID() const OVERRIDE; |
| 61 virtual Type GetInfoBarType() const OVERRIDE; | 60 virtual Type GetInfoBarType() const OVERRIDE; |
| 62 virtual string16 GetMessageText() const OVERRIDE; | 61 virtual string16 GetMessageText() const OVERRIDE; |
| 63 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 62 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 64 virtual bool Accept() OVERRIDE; | 63 virtual bool Accept() OVERRIDE; |
| 65 virtual bool Cancel() OVERRIDE; | 64 virtual bool Cancel() OVERRIDE; |
| 66 | 65 |
| 67 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; | 66 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; |
| 68 | 67 |
| 69 // The PasswordFormManager managing the form we're asking the user about, | 68 // The PasswordFormManager managing the form we're asking the user about, |
| 70 // and should update as per her decision. | 69 // and should update as per her decision. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 : ConfirmInfoBarDelegate(infobar_service), | 107 : ConfirmInfoBarDelegate(infobar_service), |
| 109 form_to_save_(form_to_save), | 108 form_to_save_(form_to_save), |
| 110 infobar_response_(NO_RESPONSE) { | 109 infobar_response_(NO_RESPONSE) { |
| 111 } | 110 } |
| 112 | 111 |
| 113 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { | 112 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { |
| 114 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", | 113 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", |
| 115 infobar_response_, NUM_RESPONSE_TYPES); | 114 infobar_response_, NUM_RESPONSE_TYPES); |
| 116 } | 115 } |
| 117 | 116 |
| 118 gfx::Image* SavePasswordInfoBarDelegate::GetIcon() const { | 117 int SavePasswordInfoBarDelegate::GetIconID() const { |
| 119 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 118 return IDR_INFOBAR_SAVE_PASSWORD; |
| 120 IDR_INFOBAR_SAVE_PASSWORD); | |
| 121 } | 119 } |
| 122 | 120 |
| 123 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { | 121 InfoBarDelegate::Type SavePasswordInfoBarDelegate::GetInfoBarType() const { |
| 124 return PAGE_ACTION_TYPE; | 122 return PAGE_ACTION_TYPE; |
| 125 } | 123 } |
| 126 | 124 |
| 127 string16 SavePasswordInfoBarDelegate::GetMessageText() const { | 125 string16 SavePasswordInfoBarDelegate::GetMessageText() const { |
| 128 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT); | 126 return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT); |
| 129 } | 127 } |
| 130 | 128 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { | 190 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { |
| 193 content::NavigationEntry* entry = | 191 content::NavigationEntry* entry = |
| 194 web_contents_->GetController().GetActiveEntry(); | 192 web_contents_->GetController().GetActiveEntry(); |
| 195 if (!entry) { | 193 if (!entry) { |
| 196 NOTREACHED(); | 194 NOTREACHED(); |
| 197 return false; | 195 return false; |
| 198 } | 196 } |
| 199 | 197 |
| 200 return net::IsCertStatusError(entry->GetSSL().cert_status); | 198 return net::IsCertStatusError(entry->GetSSL().cert_status); |
| 201 } | 199 } |
| OLD | NEW |