Chromium Code Reviews| 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" |
| 10 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 12 | 13 |
| 13 class GURL; | 14 class GURL; |
| 14 | 15 |
| 15 namespace content { | 16 namespace content { |
| 16 class WebContents; | 17 class WebContents; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 class URLRequest; | 21 class URLRequest; |
| 21 } | 22 } |
| 22 | 23 |
| 23 // This class displays an infobar that allows the user to automatically login to | 24 // 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 | 25 // 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 | 26 // detects that the user has navigated to a login page and that there are stored |
| 26 // tokens that would allow a one-click login. | 27 // tokens that would allow a one-click login. |
| 27 class AutoLoginPrompter : public content::NotificationObserver { | 28 class AutoLoginPrompter : public content::NotificationObserver { |
| 28 public: | 29 public: |
| 29 // Looks for the X-Auto-Login response header in the request, and if found, | 30 // 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 | 31 // tries to display an infobar in the tab contents identified by the |
| 31 // child/route id. | 32 // child/route id. |
| 32 static void ShowInfoBarIfPossible(net::URLRequest* request, | 33 static void ShowInfoBarIfPossible(net::URLRequest* request, |
| 33 int child_id, | 34 int child_id, |
| 34 int route_id); | 35 int route_id); |
| 35 | 36 |
| 36 private: | 37 private: |
| 38 friend class AutoLoginPrompterTest; | |
| 39 | |
| 40 struct Params { | |
| 41 Params(); | |
| 42 ~Params(); | |
| 43 // Extracted from X-Auto-Login header. | |
|
Peter Kasting
2012/06/27 17:39:05
Nit: Blank line above
Philippe
2012/06/28 09:24:00
Done.
| |
| 44 std::string realm; | |
| 45 std::string account; | |
| 46 std::string args; | |
| 47 // Fetched through sync on non-Android platforms. | |
| 48 std::string username; | |
| 49 }; | |
| 50 | |
| 37 AutoLoginPrompter(content::WebContents* web_contents, | 51 AutoLoginPrompter(content::WebContents* web_contents, |
| 38 const std::string& username, | 52 const Params& params); |
| 39 const std::string& args); | |
| 40 | 53 |
| 41 virtual ~AutoLoginPrompter(); | 54 virtual ~AutoLoginPrompter(); |
| 42 | 55 |
| 43 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. | 56 static void ShowInfoBarUIThread(const Params& params, |
| 44 static void ShowInfoBarUIThread(const std::string& account, | 57 const GURL& url, |
| 45 const std::string& args, | |
| 46 const GURL& original_url, | |
| 47 int child_id, | 58 int child_id, |
| 48 int route_id); | 59 int route_id); |
| 49 | 60 |
| 50 // content::NotificationObserver override. | 61 // content::NotificationObserver override. |
| 51 virtual void Observe(int type, | 62 virtual void Observe(int type, |
| 52 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
| 53 const content::NotificationDetails& details) OVERRIDE; | 64 const content::NotificationDetails& details) OVERRIDE; |
| 54 | 65 |
| 66 // Returns whether parsing succeeded. | |
| 67 static bool ParseAutoLoginHeader(const std::string& input, Params* output); | |
| 68 | |
| 55 content::WebContents* web_contents_; | 69 content::WebContents* web_contents_; |
| 56 const std::string username_; | 70 const Params params_; |
| 57 const std::string args_; | |
| 58 content::NotificationRegistrar registrar_; | 71 content::NotificationRegistrar registrar_; |
| 59 | 72 |
| 60 DISALLOW_COPY_AND_ASSIGN(AutoLoginPrompter); | 73 DISALLOW_COPY_AND_ASSIGN(AutoLoginPrompter); |
| 61 }; | 74 }; |
| 62 | 75 |
| 63 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_ | 76 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_ |
| OLD | NEW |