Chromium Code Reviews| 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/string_piece.h" | |
| 9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
| 11 #include "chrome/browser/autofill/autofill_manager.h" | 12 #include "chrome/browser/autofill/autofill_manager.h" |
| 12 #include "chrome/browser/infobars/infobar_tab_helper.h" | 13 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 13 #include "chrome/browser/password_manager/password_form_manager.h" | 14 #include "chrome/browser/password_manager/password_form_manager.h" |
| 14 #include "chrome/browser/password_manager/password_manager.h" | 15 #include "chrome/browser/password_manager/password_manager.h" |
| 15 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 16 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 17 #include "chrome/common/autofill_messages.h" | 18 #include "chrome/common/autofill_messages.h" |
| 18 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| 19 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/common/ssl_status.h" | 22 #include "content/public/common/ssl_status.h" |
| 22 #include "google_apis/gaia/gaia_urls.h" | 23 #include "google_apis/gaia/gaia_urls.h" |
| 23 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
| 24 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
| 25 #include "grit/theme_resources.h" | 26 #include "grit/theme_resources.h" |
| 26 #include "net/base/cert_status_flags.h" | 27 #include "net/base/cert_status_flags.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "webkit/forms/password_form.h" | 30 #include "webkit/forms/password_form.h" |
| 30 | 31 |
| 32 namespace { | |
| 33 | |
| 34 const char kSpdyProxyRealm[] = "/SpdyProxy"; | |
| 35 | |
| 36 } // namespace | |
| 37 | |
| 31 // After a successful *new* login attempt, we take the PasswordFormManager in | 38 // After a successful *new* login attempt, we take the PasswordFormManager in |
| 32 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while | 39 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while |
| 33 // the user makes up their mind with the "save password" infobar. Note if the | 40 // the user makes up their mind with the "save password" infobar. Note if the |
| 34 // login is one we already know about, the end of the line is | 41 // login is one we already know about, the end of the line is |
| 35 // provisional_save_manager_ because we just update it on success and so such | 42 // provisional_save_manager_ because we just update it on success and so such |
| 36 // forms never end up in an infobar. | 43 // forms never end up in an infobar. |
| 37 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { | 44 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 38 public: | 45 public: |
| 39 SavePasswordInfoBarDelegate(InfoBarTabHelper* infobar_helper, | 46 SavePasswordInfoBarDelegate(InfoBarTabHelper* infobar_helper, |
| 40 PasswordFormManager* form_to_save); | 47 PasswordFormManager* form_to_save); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 // TODO(mathp): Checking only against associated_username() causes a bug | 150 // TODO(mathp): Checking only against associated_username() causes a bug |
| 144 // referenced here: crbug.com/133275 | 151 // referenced here: crbug.com/133275 |
| 145 if ((realm == GURL(GaiaUrls::GetInstance()->gaia_login_form_realm()) || | 152 if ((realm == GURL(GaiaUrls::GetInstance()->gaia_login_form_realm()) || |
| 146 realm == GURL("https://www.google.com/")) && | 153 realm == GURL("https://www.google.com/")) && |
| 147 OneClickSigninHelper::CanOffer(tab_contents_->web_contents(), | 154 OneClickSigninHelper::CanOffer(tab_contents_->web_contents(), |
| 148 UTF16ToUTF8(form_to_save->associated_username()), true)) { | 155 UTF16ToUTF8(form_to_save->associated_username()), true)) { |
| 149 return; | 156 return; |
| 150 } | 157 } |
| 151 #endif | 158 #endif |
| 152 | 159 |
| 160 // Don't show the password manager infobar if this form corresponds to | |
| 161 // SpdyProxy authentication, as indicated by the realm. | |
| 162 if (base::StringPiece(form_to_save->realm()).ends_with(kSpdyProxyRealm)) | |
|
Ilya Sherman
2012/09/25 22:31:07
nit: Please use the EndsWith() function from base/
Michael Piatek
2012/09/26 23:08:34
Done.
| |
| 163 return; | |
| 164 | |
| 153 tab_contents_->infobar_tab_helper()->AddInfoBar( | 165 tab_contents_->infobar_tab_helper()->AddInfoBar( |
| 154 new SavePasswordInfoBarDelegate( | 166 new SavePasswordInfoBarDelegate( |
| 155 tab_contents_->infobar_tab_helper(), form_to_save)); | 167 tab_contents_->infobar_tab_helper(), form_to_save)); |
| 156 } | 168 } |
| 157 | 169 |
| 158 Profile* PasswordManagerDelegateImpl::GetProfile() { | 170 Profile* PasswordManagerDelegateImpl::GetProfile() { |
| 159 return tab_contents_->profile(); | 171 return tab_contents_->profile(); |
| 160 } | 172 } |
| 161 | 173 |
| 162 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { | 174 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { |
| 163 content::NavigationEntry* entry = | 175 content::NavigationEntry* entry = |
| 164 tab_contents_->web_contents()->GetController().GetActiveEntry(); | 176 tab_contents_->web_contents()->GetController().GetActiveEntry(); |
| 165 if (!entry) { | 177 if (!entry) { |
| 166 NOTREACHED(); | 178 NOTREACHED(); |
| 167 return false; | 179 return false; |
| 168 } | 180 } |
| 169 | 181 |
| 170 return net::IsCertStatusError(entry->GetSSL().cert_status); | 182 return net::IsCertStatusError(entry->GetSSL().cert_status); |
| 171 } | 183 } |
| OLD | NEW |