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

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 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 NEVER_REMEMBER_PASSWORD, 59 NEVER_REMEMBER_PASSWORD,
59 INFOBAR_DISMISSED, 60 INFOBAR_DISMISSED,
60 NUM_RESPONSE_TYPES, 61 NUM_RESPONSE_TYPES,
61 }; 62 };
62 63
63 SavePasswordInfoBarDelegate(InfoBarService* infobar_service, 64 SavePasswordInfoBarDelegate(PasswordFormManager* form_to_save,
64 PasswordFormManager* form_to_save,
65 const std::string& uma_histogram_suffix); 65 const std::string& uma_histogram_suffix);
66 virtual ~SavePasswordInfoBarDelegate(); 66 virtual ~SavePasswordInfoBarDelegate();
67 67
68 // ConfirmInfoBarDelegate 68 // ConfirmInfoBarDelegate
69 virtual int GetIconID() const OVERRIDE; 69 virtual int GetIconID() const OVERRIDE;
70 virtual Type GetInfoBarType() const OVERRIDE; 70 virtual Type GetInfoBarType() const OVERRIDE;
71 virtual string16 GetMessageText() const OVERRIDE; 71 virtual string16 GetMessageText() const OVERRIDE;
72 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 72 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
73 virtual bool Accept() OVERRIDE; 73 virtual bool Accept() OVERRIDE;
74 virtual bool Cancel() OVERRIDE; 74 virtual bool Cancel() OVERRIDE;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // TODO(mathp): Checking only against associated_username() causes a bug 106 // TODO(mathp): Checking only against associated_username() causes a bug
107 // referenced here: crbug.com/133275 107 // referenced here: crbug.com/133275
108 if (((realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) || 108 if (((realm == GaiaUrls::GetInstance()->gaia_login_form_realm()) ||
109 (realm == GURL("https://www.google.com/"))) && 109 (realm == GURL("https://www.google.com/"))) &&
110 OneClickSigninHelper::CanOffer( 110 OneClickSigninHelper::CanOffer(
111 web_contents, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY, 111 web_contents, OneClickSigninHelper::CAN_OFFER_FOR_INTERSTITAL_ONLY,
112 UTF16ToUTF8(form_to_save->associated_username()), NULL)) 112 UTF16ToUTF8(form_to_save->associated_username()), NULL))
113 return; 113 return;
114 #endif 114 #endif
115 115
116 InfoBarService* infobar_service = 116 InfoBarService::FromWebContents(web_contents)->AddInfoBar(
117 InfoBarService::FromWebContents(web_contents); 117 ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
118 infobar_service->AddInfoBar( 118 new SavePasswordInfoBarDelegate(form_to_save,
119 scoped_ptr<InfoBarDelegate>(new SavePasswordInfoBarDelegate( 119 uma_histogram_suffix))));
120 infobar_service, form_to_save, uma_histogram_suffix)));
121 } 120 }
122 121
123 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( 122 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate(
124 InfoBarService* infobar_service,
125 PasswordFormManager* form_to_save, 123 PasswordFormManager* form_to_save,
126 const std::string& uma_histogram_suffix) 124 const std::string& uma_histogram_suffix)
127 : ConfirmInfoBarDelegate(infobar_service), 125 : ConfirmInfoBarDelegate(),
128 form_to_save_(form_to_save), 126 form_to_save_(form_to_save),
129 infobar_response_(NO_RESPONSE), 127 infobar_response_(NO_RESPONSE),
130 uma_histogram_suffix_(uma_histogram_suffix) { 128 uma_histogram_suffix_(uma_histogram_suffix) {
131 if (!uma_histogram_suffix_.empty()) { 129 if (!uma_histogram_suffix_.empty()) {
132 password_manager_metrics_util::LogUMAHistogramBoolean( 130 password_manager_metrics_util::LogUMAHistogramBoolean(
133 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, 131 "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_,
134 true); 132 true);
135 } 133 }
136 } 134 }
137 135
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() { 234 bool PasswordManagerDelegateImpl::DidLastPageLoadEncounterSSLErrors() {
237 content::NavigationEntry* entry = 235 content::NavigationEntry* entry =
238 web_contents_->GetController().GetActiveEntry(); 236 web_contents_->GetController().GetActiveEntry();
239 if (!entry) { 237 if (!entry) {
240 NOTREACHED(); 238 NOTREACHED();
241 return false; 239 return false;
242 } 240 }
243 241
244 return net::IsCertStatusError(entry->GetSSL().cert_status); 242 return net::IsCertStatusError(entry->GetSSL().cert_status);
245 } 243 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager_browsertest.cc ('k') | chrome/browser/pepper_broker_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698