Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
| 12 #include "components/infobars/core/confirm_infobar_delegate.h" | 11 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 13 #include "components/infobars/core/infobar_delegate.h" | |
| 14 #include "components/password_manager/core/browser/password_form_manager.h" | 12 #include "components/password_manager/core/browser/password_form_manager.h" |
| 15 #include "components/password_manager/core/browser/password_manager_metrics_util .h" | 13 #include "components/password_manager/core/browser/password_manager_metrics_util .h" |
| 16 | 14 |
| 17 namespace content { | 15 namespace content { |
| 18 class WebContents; | 16 class WebContents; |
| 19 } | 17 } |
| 20 | 18 |
| 19 namespace password_manager { | |
| 20 enum class CredentialSourceType; | |
| 21 } | |
| 22 | |
| 21 // After a successful *new* login attempt, we take the PasswordFormManager in | 23 // After a successful *new* login attempt, we take the PasswordFormManager in |
| 22 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while | 24 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while |
| 23 // the user makes up their mind with the "save password" infobar. Note if the | 25 // the user makes up their mind with the "save password" infobar. Note if the |
| 24 // login is one we already know about, the end of the line is | 26 // login is one we already know about, the end of the line is |
| 25 // provisional_save_manager_ because we just update it on success and so such | 27 // provisional_save_manager_ because we just update it on success and so such |
| 26 // forms never end up in an infobar. | 28 // forms never end up in an infobar. |
| 27 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { | 29 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 28 public: | 30 public: |
| 29 // If we won't be showing the one-click signin infobar, creates a save | 31 // If we won't be showing the one-click signin infobar, creates a save |
| 30 // password infobar and delegate and adds the infobar to the InfoBarService | 32 // password infobar and delegate and adds the infobar to the InfoBarService |
| 31 // for |web_contents|. |uma_histogram_suffix| is empty, or one of the | 33 // for |web_contents|. |uma_histogram_suffix| is empty, or one of the |
| 32 // "group_X" suffixes used in the histogram names for infobar usage reporting; | 34 // "group_X" suffixes used in the histogram names for infobar usage reporting; |
| 33 // if empty, the usage is not reported, otherwise the suffix is used to choose | 35 // if empty, the usage is not reported, otherwise the suffix is used to choose |
| 34 // the right histogram. | 36 // the right histogram. |
| 35 static void Create( | 37 static void Create( |
| 36 content::WebContents* web_contents, | 38 content::WebContents* web_contents, |
| 37 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | 39 scoped_ptr<password_manager::PasswordFormManager> form_to_save, |
| 38 const std::string& uma_histogram_suffix); | 40 const std::string& uma_histogram_suffix, |
| 39 | 41 password_manager::CredentialSourceType source_type); |
| 40 private: | |
| 41 SavePasswordInfoBarDelegate( | |
| 42 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | |
| 43 const std::string& uma_histogram_suffix); | |
| 44 | 42 |
| 45 ~SavePasswordInfoBarDelegate() override; | 43 ~SavePasswordInfoBarDelegate() override; |
| 46 | 44 |
| 45 SavePasswordInfoBarDelegate( | |
|
Bernhard Bauer
2015/03/02 10:28:09
Does this constructor need to be public now?
melandory
2015/03/03 11:55:46
Nope.
Done.
| |
| 46 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | |
| 47 const std::string& uma_histogram_suffix, | |
| 48 password_manager::CredentialSourceType source_type); | |
| 49 | |
| 50 // If infobar was tiggered by Credential management API, then on Android | |
|
Bernhard Bauer
2015/03/02 10:28:09
Nit: "triggered" (Tigger is something else [http:/
melandory
2015/03/03 11:55:46
Done.
| |
| 51 // it should display "More" button. | |
| 52 bool ShouldShowMoreButton(); | |
| 53 | |
| 47 // ConfirmInfoBarDelegate: | 54 // ConfirmInfoBarDelegate: |
| 48 Type GetInfoBarType() const override; | 55 Type GetInfoBarType() const override; |
| 49 InfoBarAutomationType GetInfoBarAutomationType() const override; | 56 InfoBarAutomationType GetInfoBarAutomationType() const override; |
| 50 int GetIconID() const override; | 57 int GetIconID() const override; |
| 51 bool ShouldExpire(const NavigationDetails& details) const override; | 58 bool ShouldExpire(const NavigationDetails& details) const override; |
| 52 void InfoBarDismissed() override; | 59 void InfoBarDismissed() override; |
| 53 base::string16 GetMessageText() const override; | 60 base::string16 GetMessageText() const override; |
| 54 base::string16 GetButtonLabel(InfoBarButton button) const override; | 61 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 55 bool Accept() override; | 62 bool Accept() override; |
| 56 bool Cancel() override; | 63 bool Cancel() override; |
| 57 | 64 |
| 65 private: | |
| 58 // The PasswordFormManager managing the form we're asking the user about, | 66 // The PasswordFormManager managing the form we're asking the user about, |
| 59 // and should update as per her decision. | 67 // and should update as per her decision. |
| 60 scoped_ptr<password_manager::PasswordFormManager> form_to_save_; | 68 scoped_ptr<password_manager::PasswordFormManager> form_to_save_; |
| 61 | 69 |
| 62 // Used to track the results we get from the info bar. | 70 // Used to track the results we get from the info bar. |
| 63 password_manager::metrics_util::ResponseType infobar_response_; | 71 password_manager::metrics_util::ResponseType infobar_response_; |
| 64 | 72 |
| 65 // Measures the "Save password?" prompt lifetime. Used to report an UMA | 73 // Measures the "Save password?" prompt lifetime. Used to report an UMA |
| 66 // signal. | 74 // signal. |
| 67 base::ElapsedTimer timer_; | 75 base::ElapsedTimer timer_; |
| 68 | 76 |
| 69 // The group name corresponding to the domain name of |form_to_save_| if the | 77 // The group name corresponding to the domain name of |form_to_save_| if the |
| 70 // form is on a monitored domain. Otherwise, an empty string. | 78 // form is on a monitored domain. Otherwise, an empty string. |
| 71 const std::string uma_histogram_suffix_; | 79 const std::string uma_histogram_suffix_; |
| 72 | 80 |
| 81 // Determines source from where infobar was triggered. | |
|
Mike West
2015/03/02 11:54:27
Nit: This doesn't "determine", it "records" or som
melandory
2015/03/03 11:55:46
Done.
| |
| 82 // Infobar appearance (title, buttons) depends on value of this parameter. | |
| 83 password_manager::CredentialSourceType source_type_; | |
| 84 | |
| 73 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); | 85 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); |
| 74 }; | 86 }; |
| 75 | 87 |
| 76 #endif // CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ | 88 #endif // CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ |
| OLD | NEW |