| 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 <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/timer/elapsed_timer.h" | 11 #include "base/timer/elapsed_timer.h" |
| 11 #include "chrome/browser/password_manager/password_manager_infobar_delegate.h" | 12 #include "chrome/browser/password_manager/password_manager_infobar_delegate.h" |
| 12 #include "components/infobars/core/confirm_infobar_delegate.h" | 13 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 13 #include "components/password_manager/core/browser/password_form_manager.h" | 14 #include "components/password_manager/core/browser/password_form_manager.h" |
| 14 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 15 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
| 15 #include "ui/gfx/range/range.h" | 16 #include "ui/gfx/range/range.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 class WebContents; | 19 class WebContents; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace password_manager { | 22 namespace password_manager { |
| 22 enum class CredentialSourceType; | 23 enum class CredentialSourceType; |
| 23 } | 24 } |
| 24 | 25 |
| 25 // After a successful *new* login attempt, we take the PasswordFormManager in | 26 // After a successful *new* login attempt, we take the PasswordFormManager in |
| 26 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while | 27 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while |
| 27 // the user makes up their mind with the "save password" infobar. Note if the | 28 // the user makes up their mind with the "save password" infobar. Note if the |
| 28 // login is one we already know about, the end of the line is | 29 // login is one we already know about, the end of the line is |
| 29 // provisional_save_manager_ because we just update it on success and so such | 30 // provisional_save_manager_ because we just update it on success and so such |
| 30 // forms never end up in an infobar. | 31 // forms never end up in an infobar. |
| 31 class SavePasswordInfoBarDelegate : public PasswordManagerInfoBarDelegate { | 32 class SavePasswordInfoBarDelegate : public PasswordManagerInfoBarDelegate { |
| 32 public: | 33 public: |
| 33 // If we won't be showing the one-click signin infobar, creates a save | 34 // If we won't be showing the one-click signin infobar, creates a save |
| 34 // password infobar and delegate and adds the infobar to the InfoBarService | 35 // password infobar and delegate and adds the infobar to the InfoBarService |
| 35 // for |web_contents|. | 36 // for |web_contents|. |
| 36 static void Create( | 37 static void Create( |
| 37 content::WebContents* web_contents, | 38 content::WebContents* web_contents, |
| 38 scoped_ptr<password_manager::PasswordFormManager> form_to_save); | 39 std::unique_ptr<password_manager::PasswordFormManager> form_to_save); |
| 39 | 40 |
| 40 ~SavePasswordInfoBarDelegate() override; | 41 ~SavePasswordInfoBarDelegate() override; |
| 41 | 42 |
| 42 base::string16 GetFirstRunExperienceMessage(); | 43 base::string16 GetFirstRunExperienceMessage(); |
| 43 | 44 |
| 44 // ConfirmInfoBarDelegate: | 45 // ConfirmInfoBarDelegate: |
| 45 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; | 46 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; |
| 46 void InfoBarDismissed() override; | 47 void InfoBarDismissed() override; |
| 47 base::string16 GetButtonLabel(InfoBarButton button) const override; | 48 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 48 bool Accept() override; | 49 bool Accept() override; |
| 49 bool Cancel() override; | 50 bool Cancel() override; |
| 50 | 51 |
| 51 protected: | 52 protected: |
| 52 // Makes a ctor available in tests. | 53 // Makes a ctor available in tests. |
| 53 SavePasswordInfoBarDelegate( | 54 SavePasswordInfoBarDelegate( |
| 54 content::WebContents* web_contents, | 55 content::WebContents* web_contents, |
| 55 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | 56 std::unique_ptr<password_manager::PasswordFormManager> form_to_save, |
| 56 bool is_smartlock_branding_enabled, | 57 bool is_smartlock_branding_enabled, |
| 57 bool should_show_first_run_experience); | 58 bool should_show_first_run_experience); |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 // The PasswordFormManager managing the form we're asking the user about, | 61 // The PasswordFormManager managing the form we're asking the user about, |
| 61 // and should update as per her decision. | 62 // and should update as per her decision. |
| 62 scoped_ptr<password_manager::PasswordFormManager> form_to_save_; | 63 std::unique_ptr<password_manager::PasswordFormManager> form_to_save_; |
| 63 | 64 |
| 64 // Used to track the results we get from the info bar. | 65 // Used to track the results we get from the info bar. |
| 65 password_manager::metrics_util::UIDismissalReason infobar_response_; | 66 password_manager::metrics_util::UIDismissalReason infobar_response_; |
| 66 | 67 |
| 67 // Measures the "Save password?" prompt lifetime. Used to report an UMA | 68 // Measures the "Save password?" prompt lifetime. Used to report an UMA |
| 68 // signal. | 69 // signal. |
| 69 base::ElapsedTimer timer_; | 70 base::ElapsedTimer timer_; |
| 70 | 71 |
| 71 // Records source from where infobar was triggered. | 72 // Records source from where infobar was triggered. |
| 72 // Infobar appearance (message, buttons) depends on value of this parameter. | 73 // Infobar appearance (message, buttons) depends on value of this parameter. |
| 73 password_manager::CredentialSourceType source_type_; | 74 password_manager::CredentialSourceType source_type_; |
| 74 | 75 |
| 75 bool should_show_first_run_experience_; | 76 bool should_show_first_run_experience_; |
| 76 | 77 |
| 77 content::WebContents* web_contents_; | 78 content::WebContents* web_contents_; |
| 78 | 79 |
| 79 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); | 80 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 // Creates the platform-specific SavePassword InfoBar. This function is defined | 83 // Creates the platform-specific SavePassword InfoBar. This function is defined |
| 83 // in platform-specific .cc (or .mm) files. | 84 // in platform-specific .cc (or .mm) files. |
| 84 scoped_ptr<infobars::InfoBar> CreateSavePasswordInfoBar( | 85 std::unique_ptr<infobars::InfoBar> CreateSavePasswordInfoBar( |
| 85 scoped_ptr<SavePasswordInfoBarDelegate> delegate); | 86 std::unique_ptr<SavePasswordInfoBarDelegate> delegate); |
| 86 | 87 |
| 87 #endif // CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ | 88 #endif // CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ |
| OLD | NEW |