OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/save_password_infobar_delegate.h" | 5 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/infobars/infobar.h" | 9 #include "chrome/browser/infobars/infobar.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/browser/password_manager/password_form_manager.h" | 11 #include "chrome/browser/password_manager/password_form_manager.h" |
12 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 12 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 13 #include "chrome/common/profile_management_switches.h" |
13 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 14 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
14 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
16 #include "google_apis/gaia/gaia_urls.h" | 17 #include "google_apis/gaia/gaia_urls.h" |
17 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
19 #include "grit/theme_resources.h" | 20 #include "grit/theme_resources.h" |
20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
21 | 22 |
22 // static | 23 // static |
23 void SavePasswordInfoBarDelegate::Create( | 24 void SavePasswordInfoBarDelegate::Create( |
24 content::WebContents* web_contents, | 25 content::WebContents* web_contents, |
25 PasswordFormManager* form_to_save, | 26 PasswordFormManager* form_to_save, |
26 const std::string& uma_histogram_suffix) { | 27 const std::string& uma_histogram_suffix) { |
27 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 28 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
28 // Don't show the password manager infobar if this form is for a google | 29 // Don't show the password manager infobar if this form is for a google |
29 // account and we are going to show the one-click signin infobar. | 30 // account and we are going to show the one-click signin infobar. |
30 GURL realm(form_to_save->realm()); | 31 GURL realm(form_to_save->realm()); |
31 // TODO(mathp): Checking only against associated_username() causes a bug | 32 // TODO(mathp): Checking only against associated_username() causes a bug |
32 // referenced here: crbug.com/133275 | 33 // referenced here: crbug.com/133275 |
| 34 // TODO(vabr): The check IsEnableWebBasedSignin is a hack for the time when |
| 35 // OneClickSignin is disabled. http://crbug.com/339804 |
33 if (((realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) || | 36 if (((realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) || |
34 (realm == GURL("https://www.google.com/"))) && | 37 (realm == GURL("https://www.google.com/"))) && |
| 38 switches::IsEnableWebBasedSignin() && |
35 OneClickSigninHelper::CanOffer( | 39 OneClickSigninHelper::CanOffer( |
36 web_contents, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, | 40 web_contents, |
37 base::UTF16ToUTF8(form_to_save->associated_username()), NULL)) | 41 OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, |
| 42 base::UTF16ToUTF8(form_to_save->associated_username()), |
| 43 NULL)) |
38 return; | 44 return; |
39 #endif | 45 #endif |
40 | 46 |
41 InfoBarService::FromWebContents(web_contents)->AddInfoBar( | 47 InfoBarService::FromWebContents(web_contents)->AddInfoBar( |
42 SavePasswordInfoBarDelegate::CreateInfoBar( | 48 SavePasswordInfoBarDelegate::CreateInfoBar( |
43 scoped_ptr<SavePasswordInfoBarDelegate>( | 49 scoped_ptr<SavePasswordInfoBarDelegate>( |
44 new SavePasswordInfoBarDelegate(form_to_save, | 50 new SavePasswordInfoBarDelegate(form_to_save, |
45 uma_histogram_suffix)))); | 51 uma_histogram_suffix)))); |
46 } | 52 } |
47 | 53 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 148 |
143 void SavePasswordInfoBarDelegate::InfoBarDismissed() { | 149 void SavePasswordInfoBarDelegate::InfoBarDismissed() { |
144 DCHECK(form_to_save_.get()); | 150 DCHECK(form_to_save_.get()); |
145 infobar_response_ = INFOBAR_DISMISSED; | 151 infobar_response_ = INFOBAR_DISMISSED; |
146 } | 152 } |
147 | 153 |
148 InfoBarDelegate::InfoBarAutomationType | 154 InfoBarDelegate::InfoBarAutomationType |
149 SavePasswordInfoBarDelegate::GetInfoBarAutomationType() const { | 155 SavePasswordInfoBarDelegate::GetInfoBarAutomationType() const { |
150 return PASSWORD_INFOBAR; | 156 return PASSWORD_INFOBAR; |
151 } | 157 } |
OLD | NEW |