Index: chrome/browser/captive_portal/captive_portal_tab_observer.cc |
=================================================================== |
--- chrome/browser/captive_portal/captive_portal_tab_observer.cc (revision 0) |
+++ chrome/browser/captive_portal/captive_portal_tab_observer.cc (revision 0) |
@@ -0,0 +1,91 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/captive_portal/captive_portal_tab_observer.h" |
+ |
+#include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
+#include "googleurl/src/gurl.h" |
+#include "net/base/net_errors.h" |
+ |
+namespace captive_portal { |
+ |
+CaptivePortalTabObserver::CaptivePortalTabObserver( |
+ CaptivePortalTabHelper* tab_helper, |
+ content::WebContents* web_contents) |
+ : content::WebContentsObserver(web_contents), |
+ tab_helper_(tab_helper), |
+ 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.
|
+} |
+ |
+CaptivePortalTabObserver::~CaptivePortalTabObserver() { |
+} |
+ |
+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
|
+ int64 frame_id, |
+ bool is_main_frame, |
+ const GURL& validated_url, |
+ bool is_error_page, |
+ content::RenderViewHost* render_view_host) { |
+ // Ignore subframes. |
+ if (!is_main_frame) |
+ return; |
+ |
+ // If loading an error page for a previous failure, treat this as part of |
+ // the previous load. The second check is needed because Link Doctor pages |
+ // result in two error page provisional loads in a row. Currently, the |
+ // second load is treated as a normal load, rather than reusing old error |
+ // codes. |
+ if (is_error_page && pending_error_code_ != net::OK) |
+ return; |
+ |
+ // Makes the second load for Link Doctor pages act as a normal load. |
+ // TODO(mmenke): Figure out if this affects any other cases. |
+ pending_error_code_ = net::OK; |
+ |
+ tab_helper_->OnLoadStart(validated_url.SchemeIsSecure()); |
+} |
+ |
+void CaptivePortalTabObserver::DidCommitProvisionalLoadForFrame( |
+ int64 frame_id, |
+ bool is_main_frame, |
+ const GURL& url, |
+ content::PageTransition transition_type, |
+ content::RenderViewHost* render_view_host) { |
+ // Ignore subframes. |
+ if (!is_main_frame) |
+ return; |
+ |
+ tab_helper_->OnLoadCommitted(pending_error_code_); |
+ pending_error_code_ = net::OK; |
+} |
+ |
+void CaptivePortalTabObserver::DidFailProvisionalLoad( |
+ int64 frame_id, |
+ bool is_main_frame, |
+ const GURL& validated_url, |
+ int error_code, |
+ const string16& error_description, |
+ content::RenderViewHost* render_view_host) { |
+ // 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
|
+ if (!is_main_frame) |
+ return; |
+ |
+ // Aborts generally aren't followed by loading an error page, so go ahead and |
+ // 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
|
+ if (error_code == net::ERR_ABORTED) { |
+ // May have been aborting the load of an error page. |
+ pending_error_code_ = net::OK; |
+ |
+ tab_helper_->OnAbort(); |
+ return; |
+ } |
+ |
+ pending_error_code_ = error_code; |
+} |
+ |
+void CaptivePortalTabObserver::DidStopLoading() { |
+ tab_helper_->OnStopLoading(); |
+} |
+ |
+} // namespace captive_portal |
Property changes on: chrome\browser\captive_portal\captive_portal_tab_observer.cc |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |