|
OLD | NEW |
---|---|
(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 tab_helper_(tab_helper), | |
18 pending_error_code_(net::OK) { | |
cbentzel
2012/05/18 03:23:16
DHCECK that tab_helper_ is non-NULL.
mmenke
2012/05/18 06:12:53
Done.
| |
19 } | |
20 | |
21 CaptivePortalTabObserver::~CaptivePortalTabObserver() { | |
22 } | |
23 | |
24 void CaptivePortalTabObserver::DidStartProvisionalLoadForFrame( | |
cbentzel
2012/05/18 03:23:16
One thought I had - let's say the main page is for
mmenke
2012/05/18 06:12:53
On safe browsing pages I'm pretty sure we will ind
| |
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 // Ignore subframes. | |
31 if (!is_main_frame) | |
32 return; | |
33 | |
34 // If loading an error page for a previous failure, treat this as part of | |
35 // the previous load. The second check is needed because Link Doctor pages | |
36 // result in two error page provisional loads in a row. Currently, the | |
37 // second load is treated as a normal load, rather than reusing old error | |
38 // codes. | |
39 if (is_error_page && pending_error_code_ != net::OK) | |
40 return; | |
41 | |
42 // Makes the second load for Link Doctor pages act as a normal load. | |
43 // TODO(mmenke): Figure out if this affects any other cases. | |
44 pending_error_code_ = net::OK; | |
45 | |
46 tab_helper_->OnLoadStart(validated_url.SchemeIsSecure()); | |
47 } | |
48 | |
49 void CaptivePortalTabObserver::DidCommitProvisionalLoadForFrame( | |
50 int64 frame_id, | |
51 bool is_main_frame, | |
52 const GURL& url, | |
53 content::PageTransition transition_type, | |
54 content::RenderViewHost* render_view_host) { | |
55 // Ignore subframes. | |
56 if (!is_main_frame) | |
57 return; | |
58 | |
59 tab_helper_->OnLoadCommitted(pending_error_code_); | |
60 pending_error_code_ = net::OK; | |
61 } | |
62 | |
63 void CaptivePortalTabObserver::DidFailProvisionalLoad( | |
64 int64 frame_id, | |
65 bool is_main_frame, | |
66 const GURL& validated_url, | |
67 int error_code, | |
68 const string16& error_description, | |
69 content::RenderViewHost* render_view_host) { | |
70 // Ignore subframes. | |
cbentzel
2012/05/18 03:23:16
So, I don't know enough about how the error page s
mmenke
2012/05/18 06:12:53
Yes. And it is indeed a net error page. The same
| |
71 if (!is_main_frame) | |
72 return; | |
73 | |
74 // Aborts generally aren't followed by loading an error page, so go ahead and | |
75 // reset the state. now, to prevent any captive portal checks from triggering. | |
cbentzel
2012/05/18 03:23:16
Nit: unneeded period.
mmenke
2012/05/18 06:12:53
Removed
| |
76 if (error_code == net::ERR_ABORTED) { | |
77 // May have been aborting the load of an error page. | |
78 pending_error_code_ = net::OK; | |
79 | |
80 tab_helper_->OnAbort(); | |
81 return; | |
82 } | |
83 | |
84 pending_error_code_ = error_code; | |
85 } | |
86 | |
87 void CaptivePortalTabObserver::DidStopLoading() { | |
88 tab_helper_->OnStopLoading(); | |
89 } | |
90 | |
91 } // namespace captive_portal | |
OLD | NEW |