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

Side by Side Diff: chrome/browser/captive_portal/captive_portal_tab_observer.cc

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: Created 8 years, 8 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
(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 #include "chrome/browser/captive_portal/captive_portal_tab_observer.h"
6
7 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h"
8 #include "googleurl/src/gurl.h"
9 #include "net/base/net_errors.h"
10
11 namespace captive_portal {
12
13 CaptivePortalTabObserver::CaptivePortalTabObserver(
14 CaptivePortalTabHelper* tab_helper,
15 content::WebContents* web_contents)
16 : content::WebContentsObserver(web_contents),
17 pending_error_code_(net::OK),
18 tab_helper_(tab_helper) {
19 }
20
21 CaptivePortalTabObserver::~CaptivePortalTabObserver() {
22 }
23
24 void CaptivePortalTabObserver::DidStartProvisionalLoadForFrame(
25 int64 frame_id,
26 bool is_main_frame,
27 const GURL& validated_url,
28 bool is_error_page,
29 content::RenderViewHost* render_view_host) {
30 // We don't care about subframes.
31 if (!is_main_frame)
32 return;
33
34 // If we're loading an error page for a previous failure, we treat this
35 // as part of the previous load.
36 if (is_error_page) {
37 DCHECK_NE(net::OK, pending_error_code_);
38 return;
39 }
40
41 // TODO(mmenke): Figure out if this is needed.
42 pending_error_code_ = net::OK;
43
44 tab_helper_->OnLoadStart(validated_url.SchemeIsSecure());
45 }
46
47 void CaptivePortalTabObserver::DidCommitProvisionalLoadForFrame(
48 int64 frame_id,
49 bool is_main_frame,
50 const GURL& url,
51 content::PageTransition transition_type) {
52 // We don't care about subframes.
53 if (!is_main_frame)
54 return;
55
56 tab_helper_->OnLoadCommitted(pending_error_code_);
57 pending_error_code_ = net::OK;
58 }
59
60 void CaptivePortalTabObserver::DidFailProvisionalLoad(
61 int64 frame_id,
62 bool is_main_frame,
63 const GURL& validated_url,
64 int error_code,
65 const string16& error_description) {
66 // We don't care about subframes.
67 if (!is_main_frame)
68 return;
69
70 // Aborts generally aren't followed by loading an error page, so go ahead and
71 // reset the state. now, to prevent any captive portal checks from triggering.
72 if (error_code == net::ERR_ABORTED) {
73 // We may have been aborting the load of an error page.
74 pending_error_code_ = net::OK;
75
76 tab_helper_->OnAbort();
77 return;
78 }
79
80 pending_error_code_ = error_code;
81 }
82
83 void CaptivePortalTabObserver::DidStopLoading() {
84 tab_helper_->OnStopLoading();
85 }
86
87 } // namespace captive_portal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698