Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / auto_login_prompter.h
blob27f28d79bdc84143c81ae5fc84e8d9491432b3fe
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.
5 #ifndef CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_
6 #define CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/ui/auto_login_infobar_delegate.h"
12 #include "content/public/browser/web_contents_observer.h"
13 #include "url/gurl.h"
15 namespace content {
16 class RenderViewHost;
17 class WebContents;
20 namespace net {
21 class URLRequest;
24 // This class displays an infobar that allows the user to automatically login to
25 // the currently loaded page with one click. This is used when the browser
26 // detects that the user has navigated to a login page and that there are stored
27 // tokens that would allow a one-click login.
28 class AutoLoginPrompter : public content::WebContentsObserver {
29 public:
30 typedef AutoLoginInfoBarDelegate::Params Params;
32 // Looks for the X-Auto-Login response header in the request, and if found,
33 // tries to display an infobar in the tab contents identified by the
34 // child/route id.
35 static void ShowInfoBarIfPossible(net::URLRequest* request,
36 int child_id,
37 int route_id);
39 private:
40 friend class AutoLoginPrompterTest;
42 AutoLoginPrompter(content::WebContents* web_contents,
43 const Params& params,
44 const GURL& url);
46 virtual ~AutoLoginPrompter();
48 static void ShowInfoBarUIThread(Params params,
49 const GURL& url,
50 int child_id,
51 int route_id);
53 virtual void DidStopLoading(
54 content::RenderViewHost* render_view_host) OVERRIDE;
56 virtual void WebContentsDestroyed(
57 content::WebContents* web_contents) OVERRIDE;
59 // Add the infobar to the WebContents, if it's still needed.
60 void AddInfoBarToWebContents();
62 const Params params_;
63 const GURL url_;
64 bool infobar_shown_;
66 DISALLOW_COPY_AND_ASSIGN(AutoLoginPrompter);
69 #endif // CHROME_BROWSER_UI_AUTO_LOGIN_PROMPTER_H_