No longer register app window placement preference keys on
[chromium-blink-merge.git] / chrome / browser / ui / auto_login_infobar_delegate.h
blobd5f5b30a0d2c6d7a442cf5817868db8d081bc452
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_
8 #include <string>
9 #include "components/auto_login_parser/auto_login_parser.h"
10 #include "components/infobars/core/confirm_infobar_delegate.h"
11 #include "components/signin/core/browser/signin_manager.h"
13 class PrefService;
14 class Profile;
16 namespace content {
17 class NavigationController;
18 class WebContents;
21 // This is the actual infobar displayed to prompt the user to auto-login.
22 class AutoLoginInfoBarDelegate : public ConfirmInfoBarDelegate,
23 public SigninManagerBase::Observer {
24 public:
25 struct Params {
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.
32 std::string username;
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);
40 protected:
41 // Enum values used for UMA histograms.
42 enum Actions {
43 SHOWN, // The infobar was shown to the user.
44 ACCEPTED, // The user pressed the accept button.
45 REJECTED, // The user pressed the reject button.
46 DISMISSED, // The user pressed the close button.
47 IGNORED, // The user ignored the infobar.
48 LEARN_MORE, // The user clicked on the learn more link.
49 HISTOGRAM_BOUNDING_VALUE
52 AutoLoginInfoBarDelegate(const Params& params, Profile* profile);
53 virtual ~AutoLoginInfoBarDelegate();
55 void RecordHistogramAction(Actions action);
57 private:
58 // ConfirmInfoBarDelegate:
59 virtual void InfoBarDismissed() OVERRIDE;
60 virtual int GetIconID() const OVERRIDE;
61 virtual Type GetInfoBarType() const OVERRIDE;
62 virtual AutoLoginInfoBarDelegate* AsAutoLoginInfoBarDelegate() OVERRIDE;
63 virtual base::string16 GetMessageText() const OVERRIDE;
64 virtual base::string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
65 virtual bool Accept() OVERRIDE;
66 virtual bool Cancel() OVERRIDE;
68 // SigninManagerBase::Observer:
69 virtual void GoogleSignedOut(const std::string& account_id,
70 const std::string& username) OVERRIDE;
72 const Params params_;
74 Profile* profile_;
76 // Whether any UI controls in the infobar were pressed or not.
77 bool button_pressed_;
79 DISALLOW_COPY_AND_ASSIGN(AutoLoginInfoBarDelegate);
82 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_INFOBAR_DELEGATE_H_