Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Side by Side Diff: chrome/browser/ui/auto_login_prompter.h

Issue 10690006: Upstream changes needed by Android auto-login. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Peter's comments Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
44 // Extracted from X-Auto-Login header.
45 std::string realm;
46 std::string account;
47 std::string args;
48 // Fetched through sync on non-Android platforms.
49 std::string username;
50 };
51
37 AutoLoginPrompter(content::WebContents* web_contents, 52 AutoLoginPrompter(content::WebContents* web_contents,
38 const std::string& username, 53 const Params& params);
39 const std::string& args);
40 54
41 virtual ~AutoLoginPrompter(); 55 virtual ~AutoLoginPrompter();
42 56
43 // The portion of ShowInfoBarIfPossible() that needs to run on the UI thread. 57 static void ShowInfoBarUIThread(Params params,
Roger Tawa OOO till Jul 10th 2012/06/28 14:39:56 const ref params?
Philippe 2012/06/28 15:18:27 That's what we had a few patch sets ago :) Peter s
Roger Tawa OOO till Jul 10th 2012/06/28 15:31:51 OK sorry, I didn't see Peter's comment. It just s
44 static void ShowInfoBarUIThread(const std::string& account, 58 const GURL& url,
45 const std::string& args,
46 const GURL& original_url,
47 int child_id, 59 int child_id,
48 int route_id); 60 int route_id);
49 61
50 // content::NotificationObserver override. 62 // content::NotificationObserver override.
51 virtual void Observe(int type, 63 virtual void Observe(int type,
52 const content::NotificationSource& source, 64 const content::NotificationSource& source,
53 const content::NotificationDetails& details) OVERRIDE; 65 const content::NotificationDetails& details) OVERRIDE;
54 66
67 // Returns whether parsing succeeded.
68 static bool ParseAutoLoginHeader(const std::string& input, Params* output);
69
55 content::WebContents* web_contents_; 70 content::WebContents* web_contents_;
56 const std::string username_; 71 const Params params_;
57 const std::string args_;
58 content::NotificationRegistrar registrar_; 72 content::NotificationRegistrar registrar_;
59 73
60 DISALLOW_COPY_AND_ASSIGN(AutoLoginPrompter); 74 DISALLOW_COPY_AND_ASSIGN(AutoLoginPrompter);
61 }; 75 };
62 76
63 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_ 77 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698