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