1 // Copyright (c) 2012 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 "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
18 class NavigationController
;
21 // This is the actual infobar displayed to prompt the user to auto-login.
22 class AutoLoginInfoBarDelegate
: public ConfirmInfoBarDelegate
,
23 public content::NotificationObserver
{
26 // Information from a parsed header.
27 auto_login_parser::HeaderData header
;
29 // Username to display in the infobar indicating user to be logged in as.
30 // This is initially fetched from sign-in on non-Android platforms. Note
31 // that on Android this field is not used.
35 // Creates an autologin infobar and delegate and adds the infobar to the
36 // infobar service for |web_contents|. Returns whether the infobar was
37 // successfully added.
38 static bool Create(content::WebContents
* web_contents
, const Params
& params
);
41 AutoLoginInfoBarDelegate(const Params
& params
, Profile
* profile
);
42 virtual ~AutoLoginInfoBarDelegate();
45 // Enum values used for UMA histograms.
47 SHOWN
, // The infobar was shown to the user.
48 ACCEPTED
, // The user pressed the accept button.
49 REJECTED
, // The user pressed the reject button.
50 DISMISSED
, // The user pressed the close button.
51 IGNORED
, // The user ignored the infobar.
52 LEARN_MORE
, // The user clicked on the learn more link.
53 HISTOGRAM_BOUNDING_VALUE
56 // ConfirmInfoBarDelegate:
57 virtual void InfoBarDismissed() OVERRIDE
;
58 virtual int GetIconID() const OVERRIDE
;
59 virtual Type
GetInfoBarType() const OVERRIDE
;
60 virtual AutoLoginInfoBarDelegate
* AsAutoLoginInfoBarDelegate() OVERRIDE
;
61 virtual base::string16
GetMessageText() const OVERRIDE
;
62 virtual base::string16
GetButtonLabel(InfoBarButton button
) const OVERRIDE
;
63 virtual bool Accept() OVERRIDE
;
64 virtual bool Cancel() OVERRIDE
;
66 // content::NotificationObserver:
67 virtual void Observe(int type
,
68 const content::NotificationSource
& source
,
69 const content::NotificationDetails
& details
) OVERRIDE
;
71 void RecordHistogramAction(Actions action
);
75 // Whether any UI controls in the infobar were pressed or not.
78 // For listening to the user signing out.
79 content::NotificationRegistrar registrar_
;
81 DISALLOW_COPY_AND_ASSIGN(AutoLoginInfoBarDelegate
);
84 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_INFOBAR_DELEGATE_H_