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_INFO_BAR_DELEGATE_H_
6 #define CHROME_BROWSER_UI_AUTO_LOGIN_INFO_BAR_DELEGATE_H_
8 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
9 #include "content/public/browser/notification_observer.h"
10 #include "content/public/browser/notification_registrar.h"
12 class InfoBarTabHelper
;
17 class NavigationController
;
18 } // namespace content
20 // This is the actual infobar displayed to prompt the user to auto-login.
21 class AutoLoginInfoBarDelegate
: public ConfirmInfoBarDelegate
,
22 public content::NotificationObserver
{
28 // "realm" string from x-auto-login (e.g. "com.google").
31 // "account" string from x-auto-login.
34 // "args" string from x-auto-login to be passed to MergeSession. This string
35 // should be considered opaque and not be cracked open to look inside.
38 // Username to display in the infobar indicating user to be logged in as.
39 // This is initially fetched from sign-in on non-Android platforms. Note
40 // that on Android this field is not used.
44 AutoLoginInfoBarDelegate(InfoBarTabHelper
* owner
, const Params
& params
);
45 virtual ~AutoLoginInfoBarDelegate();
47 // ConfirmInfoBarDelegate:
48 virtual void InfoBarDismissed() OVERRIDE
;
49 virtual gfx::Image
* GetIcon() const OVERRIDE
;
50 virtual Type
GetInfoBarType() const OVERRIDE
;
51 virtual AutoLoginInfoBarDelegate
* AsAutoLoginInfoBarDelegate() OVERRIDE
;
52 virtual string16
GetMessageText() const OVERRIDE
;
53 virtual string16
GetButtonLabel(InfoBarButton button
) const OVERRIDE
;
54 virtual bool Accept() OVERRIDE
;
55 virtual bool Cancel() OVERRIDE
;
57 // content::NotificationObserver overrides.
58 virtual void Observe(int type
,
59 const content::NotificationSource
& source
,
60 const content::NotificationDetails
& details
) OVERRIDE
;
62 // All the methods below are used by the Android implementation of the
63 // AutoLogin bar on the app side.
64 string16
GetMessageText(const std::string
& username
) const;
66 const std::string
& realm() const { return params_
.realm
; }
67 const std::string
& account() const { return params_
.account
; }
68 const std::string
& args() const { return params_
.args
; }
71 void RecordHistogramAction(int 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_INFO_BAR_DELEGATE_H_