Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / password_manager / save_password_infobar_delegate.h
blob4dd0b4d0684bfc28cbef21d55f54bc27df12a138
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/timer/elapsed_timer.h"
11 #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_manager_metrics_util.h"
15 namespace content {
16 class WebContents;
19 namespace password_manager {
20 enum class CredentialSourceType;
23 // After a successful *new* login attempt, we take the PasswordFormManager in
24 // 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
26 // 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
28 // forms never end up in an infobar.
29 class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate {
30 public:
31 // 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
33 // for |web_contents|. |uma_histogram_suffix| is empty, or one of the
34 // "group_X" suffixes used in the histogram names for infobar usage reporting;
35 // if empty, the usage is not reported, otherwise the suffix is used to choose
36 // the right histogram.
37 static void Create(
38 content::WebContents* web_contents,
39 scoped_ptr<password_manager::PasswordFormManager> form_to_save,
40 const std::string& uma_histogram_suffix,
41 password_manager::CredentialSourceType source_type);
43 ~SavePasswordInfoBarDelegate() override;
45 // If the infobar was triggered by the Credential management API, then on
46 // Android it should display the "More" button.
47 bool ShouldShowMoreButton();
49 // ConfirmInfoBarDelegate:
50 Type GetInfoBarType() const override;
51 InfoBarAutomationType GetInfoBarAutomationType() const override;
52 int GetIconID() const override;
53 bool ShouldExpire(const NavigationDetails& details) const override;
54 void InfoBarDismissed() override;
55 base::string16 GetMessageText() const override;
56 base::string16 GetButtonLabel(InfoBarButton button) const override;
57 bool Accept() override;
58 bool Cancel() override;
60 private:
61 SavePasswordInfoBarDelegate(
62 scoped_ptr<password_manager::PasswordFormManager> form_to_save,
63 const std::string& uma_histogram_suffix,
64 password_manager::CredentialSourceType source_type);
66 // The PasswordFormManager managing the form we're asking the user about,
67 // and should update as per her decision.
68 scoped_ptr<password_manager::PasswordFormManager> form_to_save_;
70 // Used to track the results we get from the info bar.
71 password_manager::metrics_util::ResponseType infobar_response_;
73 // Measures the "Save password?" prompt lifetime. Used to report an UMA
74 // signal.
75 base::ElapsedTimer timer_;
77 // The group name corresponding to the domain name of |form_to_save_| if the
78 // form is on a monitored domain. Otherwise, an empty string.
79 const std::string uma_histogram_suffix_;
81 // Records source from where infobar was triggered.
82 // Infobar appearance (title, buttons) depends on value of this parameter.
83 password_manager::CredentialSourceType source_type_;
85 DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate);
88 #endif // CHROME_BROWSER_PASSWORD_MANAGER_SAVE_PASSWORD_INFOBAR_DELEGATE_H_