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_UI_AUTO_LOGIN_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_UI_AUTO_LOGIN_INFOBAR_DELEGATE_H_
9 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
10 #include "components/auto_login_parser/auto_login_parser.h"
11 #include "components/signin/core/browser/signin_manager.h"
17 class NavigationController
;
20 // This is the actual infobar displayed to prompt the user to auto-login.
21 class AutoLoginInfoBarDelegate
: public ConfirmInfoBarDelegate
,
22 public SigninManagerBase::Observer
{
25 // Information from a parsed header.
26 auto_login_parser::HeaderData header
;
28 // Username to display in the infobar indicating user to be logged in as.
29 // This is initially fetched from sign-in on non-Android platforms. Note
30 // that on Android this field is not used.
34 // Creates an autologin infobar and delegate and adds the infobar to the
35 // infobar service for |web_contents|. Returns whether the infobar was
36 // successfully added.
37 static bool Create(content::WebContents
* web_contents
, const Params
& params
);
40 AutoLoginInfoBarDelegate(const Params
& params
, Profile
* profile
);
41 virtual ~AutoLoginInfoBarDelegate();
44 // Enum values used for UMA histograms.
46 SHOWN
, // The infobar was shown to the user.
47 ACCEPTED
, // The user pressed the accept button.
48 REJECTED
, // The user pressed the reject button.
49 DISMISSED
, // The user pressed the close button.
50 IGNORED
, // The user ignored the infobar.
51 LEARN_MORE
, // The user clicked on the learn more link.
52 HISTOGRAM_BOUNDING_VALUE
55 // ConfirmInfoBarDelegate:
56 virtual void InfoBarDismissed() OVERRIDE
;
57 virtual int GetIconID() const OVERRIDE
;
58 virtual Type
GetInfoBarType() const OVERRIDE
;
59 virtual AutoLoginInfoBarDelegate
* AsAutoLoginInfoBarDelegate() OVERRIDE
;
60 virtual base::string16
GetMessageText() const OVERRIDE
;
61 virtual base::string16
GetButtonLabel(InfoBarButton button
) const OVERRIDE
;
62 virtual bool Accept() OVERRIDE
;
63 virtual bool Cancel() OVERRIDE
;
65 // SigninManagerBase::Observer:
66 virtual void GoogleSignedOut(const std::string
& username
) OVERRIDE
;
68 void RecordHistogramAction(Actions action
);
74 // Whether any UI controls in the infobar were pressed or not.
77 DISALLOW_COPY_AND_ASSIGN(AutoLoginInfoBarDelegate
);
80 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_INFOBAR_DELEGATE_H_