| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_ | 5 #ifndef CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_ |
| 6 #define CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_ | 6 #define CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 |
| 9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/ui/auto_login_info_bar_delegate.h" |
| 10 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 12 | 14 |
| 13 class GURL; | 15 class GURL; |
| 14 | 16 |
| 15 namespace content { | 17 namespace content { |
| 16 class WebContents; | 18 class WebContents; |
| 17 } | 19 } |
| 18 | 20 |
| 19 namespace net { | 21 namespace net { |
| 20 class URLRequest; | 22 class URLRequest; |
| 21 } | 23 } |
| 22 | 24 |
| 23 // This class displays an infobar that allows the user to automatically login to | 25 // This class displays an infobar that allows the user to automatically login to |
| 24 // the currently loaded page with one click. This is used when the browser | 26 // the currently loaded page with one click. This is used when the browser |
| 25 // detects that the user has navigated to a login page and that there are stored | 27 // detects that the user has navigated to a login page and that there are stored |
| 26 // tokens that would allow a one-click login. | 28 // tokens that would allow a one-click login. |
| 27 class AutoLoginPrompter : public content::NotificationObserver { | 29 class AutoLoginPrompter : public content::NotificationObserver { |
| 28 public: | 30 public: |
| 31 typedef AutoLoginInfoBarDelegate::Params Params; |
| 32 |
| 29 // Looks for the X-Auto-Login response header in the request, and if found, | 33 // Looks for the X-Auto-Login response header in the request, and if found, |
| 30 // tries to display an infobar in the tab contents identified by the | 34 // tries to display an infobar in the tab contents identified by the |
| 31 // child/route id. | 35 // child/route id. |
| 32 static void ShowInfoBarIfPossible(net::URLRequest* request, | 36 static void ShowInfoBarIfPossible(net::URLRequest* request, |
| 33 int child_id, | 37 int child_id, |
| 34 int route_id); | 38 int route_id); |
| 35 | 39 |
| 36 private: | 40 private: |
| 37 AutoLoginPrompter(content::WebContents* web_contents, | 41 friend class AutoLoginPrompterTest; |
| 38 const std::string& username, | 42 |
| 39 const std::string& args); | 43 AutoLoginPrompter(content::WebContents* web_contents, const Params& params); |
| 40 | 44 |
| 41 virtual ~AutoLoginPrompter(); | 45 virtual ~AutoLoginPrompter(); |
| 42 | 46 |
| 43 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. | 47 static void ShowInfoBarUIThread(Params params, |
| 44 static void ShowInfoBarUIThread(const std::string& account, | 48 const GURL& url, |
| 45 const std::string& args, | |
| 46 const GURL& original_url, | |
| 47 int child_id, | 49 int child_id, |
| 48 int route_id); | 50 int route_id); |
| 49 | 51 |
| 50 // content::NotificationObserver override. | 52 // content::NotificationObserver override. |
| 51 virtual void Observe(int type, | 53 virtual void Observe(int type, |
| 52 const content::NotificationSource& source, | 54 const content::NotificationSource& source, |
| 53 const content::NotificationDetails& details) OVERRIDE; | 55 const content::NotificationDetails& details) OVERRIDE; |
| 54 | 56 |
| 57 // Returns whether parsing succeeded. |
| 58 static bool ParseAutoLoginHeader(const std::string& input, Params* output); |
| 59 |
| 55 content::WebContents* web_contents_; | 60 content::WebContents* web_contents_; |
| 56 const std::string username_; | 61 const Params params_; |
| 57 const std::string args_; | |
| 58 content::NotificationRegistrar registrar_; | 62 content::NotificationRegistrar registrar_; |
| 59 | 63 |
| 60 DISALLOW_COPY_AND_ASSIGN(AutoLoginPrompter); | 64 DISALLOW_COPY_AND_ASSIGN(AutoLoginPrompter); |
| 61 }; | 65 }; |
| 62 | 66 |
| 63 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_ | 67 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_ |
| OLD | NEW |