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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/timer/elapsed_timer.h" | 10 #include "base/timer/elapsed_timer.h" |
| 11 #include "chrome/browser/password_manager/password_manager_infobar_delegate.h" |
11 #include "components/infobars/core/confirm_infobar_delegate.h" | 12 #include "components/infobars/core/confirm_infobar_delegate.h" |
12 #include "components/password_manager/core/browser/password_form_manager.h" | 13 #include "components/password_manager/core/browser/password_form_manager.h" |
13 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 14 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
14 #include "ui/gfx/range/range.h" | 15 #include "ui/gfx/range/range.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 class WebContents; | 18 class WebContents; |
18 } | 19 } |
19 | 20 |
20 namespace password_manager { | 21 namespace password_manager { |
21 enum class CredentialSourceType; | 22 enum class CredentialSourceType; |
22 } | 23 } |
23 | 24 |
24 // After a successful *new* login attempt, we take the PasswordFormManager in | 25 // After a successful *new* login attempt, we take the PasswordFormManager in |
25 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while | 26 // provisional_save_manager_ and move it to a SavePasswordInfoBarDelegate while |
26 // the user makes up their mind with the "save password" infobar. Note if the | 27 // the user makes up their mind with the "save password" infobar. Note if the |
27 // login is one we already know about, the end of the line is | 28 // login is one we already know about, the end of the line is |
28 // provisional_save_manager_ because we just update it on success and so such | 29 // provisional_save_manager_ because we just update it on success and so such |
29 // forms never end up in an infobar. | 30 // forms never end up in an infobar. |
30 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { | 31 class SavePasswordInfoBarDelegate : public PasswordManagerInfoBarDelegate { |
31 public: | 32 public: |
32 // If we won't be showing the one-click signin infobar, creates a save | 33 // If we won't be showing the one-click signin infobar, creates a save |
33 // password infobar and delegate and adds the infobar to the InfoBarService | 34 // password infobar and delegate and adds the infobar to the InfoBarService |
34 // for |web_contents|. |uma_histogram_suffix| is empty, or one of the | 35 // for |web_contents|. |uma_histogram_suffix| is empty, or one of the |
35 // "group_X" suffixes used in the histogram names for infobar usage reporting; | 36 // "group_X" suffixes used in the histogram names for infobar usage reporting; |
36 // if empty, the usage is not reported, otherwise the suffix is used to choose | 37 // if empty, the usage is not reported, otherwise the suffix is used to choose |
37 // the right histogram. | 38 // the right histogram. |
38 static void Create( | 39 static void Create( |
39 content::WebContents* web_contents, | 40 content::WebContents* web_contents, |
40 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | 41 scoped_ptr<password_manager::PasswordFormManager> form_to_save, |
41 const std::string& uma_histogram_suffix, | 42 const std::string& uma_histogram_suffix, |
42 password_manager::CredentialSourceType source_type); | 43 password_manager::CredentialSourceType source_type); |
43 | 44 |
44 ~SavePasswordInfoBarDelegate() override; | 45 ~SavePasswordInfoBarDelegate() override; |
45 | 46 |
46 const gfx::Range& message_link_range() const { return message_link_range_; } | |
47 | |
48 base::string16 GetFirstRunExperienceMessage(); | 47 base::string16 GetFirstRunExperienceMessage(); |
49 | 48 |
50 // ConfirmInfoBarDelegate: | 49 // ConfirmInfoBarDelegate: |
51 Type GetInfoBarType() const override; | |
52 InfoBarAutomationType GetInfoBarAutomationType() const override; | |
53 int GetIconId() const override; | |
54 bool ShouldExpire(const NavigationDetails& details) const override; | |
55 void InfoBarDismissed() override; | 50 void InfoBarDismissed() override; |
56 base::string16 GetMessageText() const override; | |
57 base::string16 GetButtonLabel(InfoBarButton button) const override; | 51 base::string16 GetButtonLabel(InfoBarButton button) const override; |
58 bool LinkClicked(WindowOpenDisposition disposition) override; | |
59 bool Accept() override; | 52 bool Accept() override; |
60 bool Cancel() override; | 53 bool Cancel() override; |
61 | 54 |
62 protected: | 55 protected: |
63 // Makes a ctor available in tests. | 56 // Makes a ctor available in tests. |
64 SavePasswordInfoBarDelegate( | 57 SavePasswordInfoBarDelegate( |
65 content::WebContents* web_contents, | 58 content::WebContents* web_contents, |
66 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | 59 scoped_ptr<password_manager::PasswordFormManager> form_to_save, |
67 const std::string& uma_histogram_suffix, | 60 const std::string& uma_histogram_suffix, |
68 password_manager::CredentialSourceType source_type, | 61 password_manager::CredentialSourceType source_type, |
(...skipping 13 matching lines...) Expand all Loading... |
82 base::ElapsedTimer timer_; | 75 base::ElapsedTimer timer_; |
83 | 76 |
84 // 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 |
85 // form is on a monitored domain. Otherwise, an empty string. | 78 // form is on a monitored domain. Otherwise, an empty string. |
86 const std::string uma_histogram_suffix_; | 79 const std::string uma_histogram_suffix_; |
87 | 80 |
88 // Records source from where infobar was triggered. | 81 // Records source from where infobar was triggered. |
89 // Infobar appearance (message, buttons) depends on value of this parameter. | 82 // Infobar appearance (message, buttons) depends on value of this parameter. |
90 password_manager::CredentialSourceType source_type_; | 83 password_manager::CredentialSourceType source_type_; |
91 | 84 |
92 // Infobar message: branded as a part of Google Smart Lock for signed users. | |
93 base::string16 message_; | |
94 | |
95 // If set, describes the location of the link to the help center article for | |
96 // Smart Lock. | |
97 gfx::Range message_link_range_; | |
98 | |
99 bool should_show_first_run_experience_; | 85 bool should_show_first_run_experience_; |
100 | 86 |
101 content::WebContents* web_contents_; | 87 content::WebContents* web_contents_; |
102 | 88 |
103 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); | 89 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); |
104 }; | 90 }; |
105 | 91 |
106 // Creates the platform-specific SavePassword InfoBar. This function is defined | 92 // Creates the platform-specific SavePassword InfoBar. This function is defined |
107 // in platform-specific .cc (or .mm) files. | 93 // in platform-specific .cc (or .mm) files. |
108 scoped_ptr<infobars::InfoBar> CreateSavePasswordInfoBar( | 94 scoped_ptr<infobars::InfoBar> CreateSavePasswordInfoBar( |
109 scoped_ptr<SavePasswordInfoBarDelegate> delegate); | 95 scoped_ptr<SavePasswordInfoBarDelegate> delegate); |
110 | 96 |
111 #endif // CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ | 97 #endif // CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_ |
OLD | NEW |