| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_AUTO_LOGIN_INFO_BAR_DELEGATE_H_ | |
| 6 #define CHROME_BROWSER_UI_AUTO_LOGIN_INFO_BAR_DELEGATE_H_ | |
| 7 | |
| 8 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | |
| 9 #include "components/auto_login_parser/auto_login_parser.h" | |
| 10 #include "content/public/browser/notification_observer.h" | |
| 11 #include "content/public/browser/notification_registrar.h" | |
| 12 | |
| 13 class PrefService; | |
| 14 class TokenService; | |
| 15 | |
| 16 namespace content { | |
| 17 class NavigationController; | |
| 18 } // namespace content | |
| 19 | |
| 20 // This is the actual infobar displayed to prompt the user to auto-login. | |
| 21 class AutoLoginInfoBarDelegate : public ConfirmInfoBarDelegate, | |
| 22 public content::NotificationObserver { | |
| 23 public: | |
| 24 struct Params { | |
| 25 Params(); | |
| 26 ~Params(); | |
| 27 | |
| 28 // Information from a parsed header. | |
| 29 components::auto_login::HeaderData header; | |
| 30 | |
| 31 // Username to display in the infobar indicating user to be logged in as. | |
| 32 // This is initially fetched from sign-in on non-Android platforms. Note | |
| 33 // that on Android this field is not used. | |
| 34 std::string username; | |
| 35 }; | |
| 36 | |
| 37 // Creates an autologin delegate and adds it to |infobar_service|. | |
| 38 static void Create(InfoBarService* infobar_service, const Params& params); | |
| 39 | |
| 40 // ConfirmInfoBarDelegate: | |
| 41 virtual void InfoBarDismissed() OVERRIDE; | |
| 42 virtual gfx::Image* GetIcon() const OVERRIDE; | |
| 43 virtual Type GetInfoBarType() const OVERRIDE; | |
| 44 virtual AutoLoginInfoBarDelegate* AsAutoLoginInfoBarDelegate() OVERRIDE; | |
| 45 virtual string16 GetMessageText() const OVERRIDE; | |
| 46 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | |
| 47 virtual bool Accept() OVERRIDE; | |
| 48 virtual bool Cancel() OVERRIDE; | |
| 49 | |
| 50 // content::NotificationObserver overrides. | |
| 51 virtual void Observe(int type, | |
| 52 const content::NotificationSource& source, | |
| 53 const content::NotificationDetails& details) OVERRIDE; | |
| 54 | |
| 55 // All the methods below are used by the Android implementation of the | |
| 56 // AutoLogin bar on the app side. | |
| 57 string16 GetMessageText(const std::string& username) const; | |
| 58 | |
| 59 const std::string& realm() const { return params_.header.realm; } | |
| 60 const std::string& account() const { return params_.header.account; } | |
| 61 const std::string& args() const { return params_.header.args; } | |
| 62 | |
| 63 private: | |
| 64 AutoLoginInfoBarDelegate(InfoBarService* owner, const Params& params); | |
| 65 virtual ~AutoLoginInfoBarDelegate(); | |
| 66 | |
| 67 void RecordHistogramAction(int action); | |
| 68 | |
| 69 const Params params_; | |
| 70 | |
| 71 // Whether any UI controls in the infobar were pressed or not. | |
| 72 bool button_pressed_; | |
| 73 | |
| 74 // For listening to the user signing out. | |
| 75 content::NotificationRegistrar registrar_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(AutoLoginInfoBarDelegate); | |
| 78 }; | |
| 79 | |
| 80 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_INFO_BAR_DELEGATE_H_ | |
| OLD | NEW |