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 "chrome/browser/autofill/autofill_manager.h" | 10 #include "chrome/browser/autofill/autofill_manager.h" |
10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 11 #include "chrome/browser/infobars/infobar_tab_helper.h" |
11 #include "chrome/browser/password_manager/password_form_manager.h" | 12 #include "chrome/browser/password_manager/password_form_manager.h" |
12 #include "chrome/browser/password_manager/password_manager.h" | 13 #include "chrome/browser/password_manager/password_manager.h" |
13 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
14 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 15 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
16 #include "chrome/common/autofill_messages.h" | 17 #include "chrome/common/autofill_messages.h" |
17 #include "chrome/common/net/gaia/gaia_urls.h" | 18 #include "chrome/common/net/gaia/gaia_urls.h" |
18 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 disable_popup)); | 133 disable_popup)); |
133 } | 134 } |
134 | 135 |
135 void PasswordManagerDelegateImpl::AddSavePasswordInfoBarIfPermitted( | 136 void PasswordManagerDelegateImpl::AddSavePasswordInfoBarIfPermitted( |
136 PasswordFormManager* form_to_save) { | 137 PasswordFormManager* form_to_save) { |
137 // Don't show the password manager infobar if this form is for a google | 138 // Don't show the password manager infobar if this form is for a google |
138 // account and we are going to show the one-click singin infobar. | 139 // account and we are going to show the one-click singin infobar. |
139 // For now, one-click signin is fully implemented only on windows. | 140 // For now, one-click signin is fully implemented only on windows. |
140 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 141 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
141 GURL realm(form_to_save->realm()); | 142 GURL realm(form_to_save->realm()); |
142 if (realm == GURL(GaiaUrls::GetInstance()->gaia_login_form_realm()) && | 143 // TODO(mathp): Checking only against associated_username() causes a bug |
143 OneClickSigninHelper::CanOffer(tab_contents_->web_contents(), true)) { | 144 // referenced here: crbug.com/133275 |
| 145 if ((realm == GURL(GaiaUrls::GetInstance()->gaia_login_form_realm()) || |
| 146 realm == GURL("https://www.google.com/")) && |
| 147 OneClickSigninHelper::CanOffer(tab_contents_->web_contents(), |
| 148 UTF16ToUTF8(form_to_save->associated_username()), true)) { |
144 return; | 149 return; |
145 } | 150 } |
146 #endif | 151 #endif |
147 | 152 |
148 tab_contents_->infobar_tab_helper()->AddInfoBar( | 153 tab_contents_->infobar_tab_helper()->AddInfoBar( |
149 new SavePasswordInfoBarDelegate( | 154 new SavePasswordInfoBarDelegate( |
150 tab_contents_->infobar_tab_helper(), form_to_save)); | 155 tab_contents_->infobar_tab_helper(), form_to_save)); |
151 } | 156 } |
152 | 157 |
153 Profile* PasswordManagerDelegateImpl::GetProfile() { | 158 Profile* PasswordManagerDelegateImpl::GetProfile() { |
154 return tab_contents_->profile(); | 159 return tab_contents_->profile(); |
155 } | 160 } |
156 | 161 |
157 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { | 162 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { |
158 content::NavigationEntry* entry = | 163 content::NavigationEntry* entry = |
159 tab_contents_->web_contents()->GetController().GetActiveEntry(); | 164 tab_contents_->web_contents()->GetController().GetActiveEntry(); |
160 if (!entry) { | 165 if (!entry) { |
161 NOTREACHED(); | 166 NOTREACHED(); |
162 return false; | 167 return false; |
163 } | 168 } |
164 | 169 |
165 return net::IsCertStatusError(entry->GetSSL().cert_status); | 170 return net::IsCertStatusError(entry->GetSSL().cert_status); |
166 } | 171 } |
OLD | NEW |