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

Side by Side Diff: chrome/browser/captive_portal/captive_portal_tab_helper.h

Issue 10020051: Open a login tab on captive portal detection on SSL loads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Sync Created 8 years, 6 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_
6 #define CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "chrome/browser/captive_portal/captive_portal_tab_reloader.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/web_contents_observer.h"
17
18 class Profile;
19
20 namespace captive_portal {
21
22 class CaptivePortalLoginDetector;
23
24 // Along with the classes it owns, responsible for detecting page loads broken
25 // by a captive portal, triggering captive portal checks on navigation events
26 // that may indicate a captive portal is present, or has been removed / logged
27 // in to, and taking any correcting actions.
28 //
29 // It acts as a WebContentsObserver for its CaptivePortalTabReloader and
30 // CaptivePortalTabReloader. It filters out non-main-frame resource loads, and
Avi (use Gerrit) 2012/06/14 15:24:28 acts as a WCO for its X and X. Are those two Xs su
mmenke 2012/06/14 15:37:25 Indeed. Fixed (One should be CaptivePortalLoginDe
31 // treats the commit of an error page as a single event, rather than as 3
32 // (ProvisionalLoadFail, DidStartProvisionalLoad, DidCommit), which simplifies
33 // the CaptivePortalTabReloader. It is also needed by CaptivePortalTabReloaders
34 // to inform the tab's CaptivePortalLoginDetector when the tab is at a captive
35 // portal's login page.
36 //
37 // TODO(mmenke): Support redirects. Needed for HSTS, which simulates redirects
38 // at the network layer. Also may reduce the number of
39 // unnecessary captive portal checks on high latency connections.
40 //
41 // For the design doc, see:
42 // https://docs.google.com/document/d/1k-gP2sswzYNvryu9NcgN7q5XrsMlUdlUdoW9WRaEm fM/edit
43 class CaptivePortalTabHelper : public content::WebContentsObserver,
44 public content::NotificationObserver,
45 public base::NonThreadSafe {
46 public:
47 CaptivePortalTabHelper(Profile* profile,
48 content::WebContents* web_contents);
49 virtual ~CaptivePortalTabHelper();
50
51 // content::WebContentsObserver:
52 virtual void DidStartProvisionalLoadForFrame(
53 int64 frame_id,
54 bool is_main_frame,
55 const GURL& validated_url,
56 bool is_error_page,
57 content::RenderViewHost* render_view_host) OVERRIDE;
58
59 virtual void DidCommitProvisionalLoadForFrame(
60 int64 frame_id,
61 bool is_main_frame,
62 const GURL& url,
63 content::PageTransition transition_type,
64 content::RenderViewHost* render_view_host) OVERRIDE;
65
66 virtual void DidFailProvisionalLoad(
67 int64 frame_id,
68 bool is_main_frame,
69 const GURL& validated_url,
70 int error_code,
71 const string16& error_description,
72 content::RenderViewHost* render_view_host) OVERRIDE;
73
74 virtual void DidStopLoading() OVERRIDE;
75
76 // content::NotificationObserver:
77 virtual void Observe(
78 int type,
79 const content::NotificationSource& source,
80 const content::NotificationDetails& details) OVERRIDE;
81
82 // A "Login Tab" is a tab that was originally at a captive portal login
83 // page. This is set to false when a captive portal is no longer detected.
84 bool IsLoginTab() const;
85
86 private:
87 friend class CaptivePortalBrowserTest;
88 friend class CaptivePortalTabHelperTest;
89
90 // Called to indicate a tab is at, or is navigating to, the captive portal
91 // login page.
92 void SetIsLoginTab();
93
94 // |this| takes ownership of |tab_reloader|.
95 void SetTabReloaderForTest(CaptivePortalTabReloader* tab_reloader);
96
97 CaptivePortalTabReloader* GetTabReloaderForTest();
98
99 // Opens a login tab if the profile's active window doesn't have one already.
100 void OpenLoginTab();
101
102 // Neither of these will ever be NULL.
103 scoped_ptr<CaptivePortalTabReloader> tab_reloader_;
104 scoped_ptr<CaptivePortalLoginDetector> login_detector_;
105
106 Profile* profile_;
107
108 // If a provisional load has failed, and the tab is loading an error page, the
109 // error code associated with the error page we're loading.
110 // net::OK, otherwise.
111 int pending_error_code_;
112
113 content::NotificationRegistrar registrar_;
114
115 DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabHelper);
116 };
117
118 } // namespace captive_portal
119
120 #endif // CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/captive_portal/captive_portal_service.h ('k') | chrome/browser/captive_portal/captive_portal_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698