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_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "chrome/grit/chromium_strings.h" | 10 #include "chrome/grit/chromium_strings.h" |
11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
12 #include "components/infobars/core/infobar.h" | 12 #include "components/infobars/core/infobar.h" |
13 #include "components/password_manager/core/browser/password_form_manager.h" | 13 #include "components/password_manager/core/browser/password_form_manager.h" |
14 #include "components/signin/core/common/profile_management_switches.h" | |
15 #include "content/public/browser/navigation_entry.h" | 14 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
17 #include "google_apis/gaia/gaia_urls.h" | |
18 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
19 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
20 | 18 |
21 #if defined(ENABLE_ONE_CLICK_SIGNIN) | |
22 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | |
23 #endif | |
24 | |
25 // static | 19 // static |
26 void SavePasswordInfoBarDelegate::Create( | 20 void SavePasswordInfoBarDelegate::Create( |
27 content::WebContents* web_contents, | 21 content::WebContents* web_contents, |
28 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | 22 scoped_ptr<password_manager::PasswordFormManager> form_to_save, |
29 const std::string& uma_histogram_suffix) { | 23 const std::string& uma_histogram_suffix) { |
30 #if defined(ENABLE_ONE_CLICK_SIGNIN) | |
31 // Don't show the password manager infobar if this form is for a google | |
32 // account and we are going to show the one-click signin infobar. | |
33 GURL realm(form_to_save->realm()); | |
34 // TODO(mathp): Checking only against associated_username() causes a bug | |
35 // referenced here: crbug.com/133275 | |
36 // TODO(vabr): The check IsEnableWebBasedSignin is a hack for the time when | |
37 // OneClickSignin is disabled. http://crbug.com/339804 | |
38 if (((realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) || | |
39 (realm == GURL("https://www.google.com/"))) && | |
40 switches::IsEnableWebBasedSignin() && | |
41 OneClickSigninHelper::CanOffer( | |
42 web_contents, | |
43 OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, | |
44 base::UTF16ToUTF8(form_to_save->associated_username()), | |
45 NULL)) | |
46 return; | |
47 #endif | |
48 | |
49 InfoBarService* infobar_service = | 24 InfoBarService* infobar_service = |
50 InfoBarService::FromWebContents(web_contents); | 25 InfoBarService::FromWebContents(web_contents); |
51 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( | 26 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
52 scoped_ptr<ConfirmInfoBarDelegate>(new SavePasswordInfoBarDelegate( | 27 scoped_ptr<ConfirmInfoBarDelegate>(new SavePasswordInfoBarDelegate( |
53 form_to_save.Pass(), uma_histogram_suffix)))); | 28 form_to_save.Pass(), uma_histogram_suffix)))); |
54 } | 29 } |
55 | 30 |
56 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { | 31 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { |
57 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", | 32 UMA_HISTOGRAM_ENUMERATION("PasswordManager.InfoBarResponse", |
58 infobar_response_, | 33 infobar_response_, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 108 |
134 void SavePasswordInfoBarDelegate::InfoBarDismissed() { | 109 void SavePasswordInfoBarDelegate::InfoBarDismissed() { |
135 DCHECK(form_to_save_.get()); | 110 DCHECK(form_to_save_.get()); |
136 infobar_response_ = password_manager::metrics_util::INFOBAR_DISMISSED; | 111 infobar_response_ = password_manager::metrics_util::INFOBAR_DISMISSED; |
137 } | 112 } |
138 | 113 |
139 infobars::InfoBarDelegate::InfoBarAutomationType | 114 infobars::InfoBarDelegate::InfoBarAutomationType |
140 SavePasswordInfoBarDelegate::GetInfoBarAutomationType() const { | 115 SavePasswordInfoBarDelegate::GetInfoBarAutomationType() const { |
141 return PASSWORD_INFOBAR; | 116 return PASSWORD_INFOBAR; |
142 } | 117 } |
OLD | NEW |