Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/password_manager/password_manager_delegate_impl.cc

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/timer/elapsed_timer.h" 10 #include "base/timer/elapsed_timer.h"
11 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 11 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
12 #include "chrome/browser/infobars/infobar.h"
12 #include "chrome/browser/infobars/infobar_service.h" 13 #include "chrome/browser/infobars/infobar_service.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/password_manager/password_manager_metrics_util.h" 16 #include "chrome/browser/password_manager/password_manager_metrics_util.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/sync/one_click_signin_helper.h" 18 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
18 #include "components/autofill/content/browser/autofill_driver_impl.h" 19 #include "components/autofill/content/browser/autofill_driver_impl.h"
19 #include "components/autofill/core/browser/autofill_manager.h" 20 #include "components/autofill/core/browser/autofill_manager.h"
20 #include "components/autofill/core/common/autofill_messages.h" 21 #include "components/autofill/core/common/autofill_messages.h"
21 #include "components/autofill/core/common/password_form.h" 22 #include "components/autofill/core/common/password_form.h"
(...skipping 13 matching lines...) Expand all
35 36
36 // After a successful *new* login attempt, we take the PasswordFormManager in 37 // After a successful *new* login attempt, we take the PasswordFormManager in
37 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while 38 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while
38 // the user makes up their mind with the "save password" infobar. Note if the 39 // the user makes up their mind with the "save password" infobar. Note if the
39 // login is one we already know about, the end of the line is 40 // login is one we already know about, the end of the line is
40 // provisional_save_manager_ because we just update it on success and so such 41 // provisional_save_manager_ because we just update it on success and so such
41 // forms never end up in an infobar. 42 // forms never end up in an infobar.
42 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { 43 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate {
43 public: 44 public:
44 // If we won't be showing the one-click signin infobar, creates a save 45 // If we won't be showing the one-click signin infobar, creates a save
45 // password infobar delegate and adds it to the InfoBarService for 46 // password infobar and delegate and adds the infobar to the InfoBarService
46 // |web_contents|. |uma_histogram_suffix| is empty, or one of the "group_X" 47 // for |web_contents|. |uma_histogram_suffix| is empty, or one of the
47 // suffixes used in the histogram names for infobar usage reporting; if empty, 48 // "group_X" suffixes used in the histogram names for infobar usage reporting;
48 // the usage is not reported, otherwise the suffix is used to choose the right 49 // if empty, the usage is not reported, otherwise the suffix is used to choose
49 // histogram. 50 // the right histogram.
50 static void Create(content::WebContents* web_contents, 51 static void Create(content::WebContents* web_contents,
51 PasswordFormManager* form_to_save, 52 PasswordFormManager* form_to_save,
52 const std::string& uma_histogram_suffix); 53 const std::string& uma_histogram_suffix);
53 54
54 private: 55 private:
55 enum ResponseType { 56 enum ResponseType {
56 NO_RESPONSE = 0, 57 NO_RESPONSE = 0,
57 REMEMBER_PASSWORD, 58 REMEMBER_PASSWORD,
58 DONT_REMEMBER_PASSWORD, 59 DONT_REMEMBER_PASSWORD,
59 NUM_RESPONSE_TYPES, 60 NUM_RESPONSE_TYPES,
60 }; 61 };
61 62
62 SavePasswordInfoBarDelegate(InfoBarService* infobar_service, 63 SavePasswordInfoBarDelegate(PasswordFormManager* form_to_save,
63 PasswordFormManager* form_to_save,
64 const std::string& uma_histogram_suffix); 64 const std::string& uma_histogram_suffix);
65 virtual ~SavePasswordInfoBarDelegate(); 65 virtual ~SavePasswordInfoBarDelegate();
66 66
67 // ConfirmInfoBarDelegate 67 // ConfirmInfoBarDelegate
68 virtual int GetIconID() const OVERRIDE; 68 virtual int GetIconID() const OVERRIDE;
69 virtual Type GetInfoBarType() const OVERRIDE; 69 virtual Type GetInfoBarType() const OVERRIDE;
70 virtual string16 GetMessageText() const OVERRIDE; 70 virtual string16 GetMessageText() const OVERRIDE;
71 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 71 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
72 virtual bool Accept() OVERRIDE; 72 virtual bool Accept() OVERRIDE;
73 virtual bool Cancel() OVERRIDE; 73 virtual bool Cancel() OVERRIDE;
(...skipping 30 matching lines...) Expand all
104 // TODO(mathp): Checking only against associated_username() causes a bug 104 // TODO(mathp): Checking only against associated_username() causes a bug
105 // referenced here: crbug.com/133275 105 // referenced here: crbug.com/133275
106 if (((realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) || 106 if (((realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) ||
107 (realm == GURL("https://www.google.com/"))) && 107 (realm == GURL("https://www.google.com/"))) &&
108 OneClickSigninHelper::CanOffer( 108 OneClickSigninHelper::CanOffer(
109 web_contents, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, 109 web_contents, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY,
110 UTF16ToUTF8(form_to_save->associated_username()), NULL)) 110 UTF16ToUTF8(form_to_save->associated_username()), NULL))
111 return; 111 return;
112 #endif 112 #endif
113 113
114 InfoBarService* infobar_service = 114 InfoBarService::FromWebContents(web_contents)->AddInfoBar(
115 InfoBarService::FromWebContents(web_contents); 115 ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
116 infobar_service->AddInfoBar( 116 new SavePasswordInfoBarDelegate(form_to_save,
117 scoped_ptr<InfoBarDelegate>(new SavePasswordInfoBarDelegate( 117 uma_histogram_suffix))));
118 infobar_service, form_to_save, uma_histogram_suffix)));
119 } 118 }
120 119
121 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( 120 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate(
122 InfoBarService* infobar_service,
123 PasswordFormManager* form_to_save, 121 PasswordFormManager* form_to_save,
124 const std::string& uma_histogram_suffix) 122 const std::string& uma_histogram_suffix)
125 : ConfirmInfoBarDelegate(infobar_service), 123 : ConfirmInfoBarDelegate(),
126 form_to_save_(form_to_save), 124 form_to_save_(form_to_save),
127 infobar_response_(NO_RESPONSE), 125 infobar_response_(NO_RESPONSE),
128 uma_histogram_suffix_(uma_histogram_suffix) { 126 uma_histogram_suffix_(uma_histogram_suffix) {
129 if (!uma_histogram_suffix_.empty()) { 127 if (!uma_histogram_suffix_.empty()) {
130 password_manager_metrics_util::LogUMAHistogramBoolean( 128 password_manager_metrics_util::LogUMAHistogramBoolean(
131 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, 129 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_,
132 true); 130 true);
133 } 131 }
134 } 132 }
135 133
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { 227 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() {
230 content::NavigationEntry* entry = 228 content::NavigationEntry* entry =
231 web_contents_->GetController().GetActiveEntry(); 229 web_contents_->GetController().GetActiveEntry();
232 if (!entry) { 230 if (!entry) {
233 NOTREACHED(); 231 NOTREACHED();
234 return false; 232 return false;
235 } 233 }
236 234
237 return net::IsCertStatusError(entry->GetSSL().cert_status); 235 return net::IsCertStatusError(entry->GetSSL().cert_status);
238 } 236 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698