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

Unified 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 side-by-side diff with in-line comments
Download patch
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,87 @@
+// 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),
+ pending_error_code_(net::OK),
+ tab_helper_(tab_helper) {
+}
+
+CaptivePortalTabObserver::~CaptivePortalTabObserver() {
+}
+
+void CaptivePortalTabObserver::DidStartProvisionalLoadForFrame(
+ int64 frame_id,
+ bool is_main_frame,
+ const GURL& validated_url,
+ bool is_error_page,
+ content::RenderViewHost* render_view_host) {
+ // We don't care about subframes.
+ if (!is_main_frame)
+ return;
+
+ // If we're loading an error page for a previous failure, we treat this
+ // as part of the previous load.
+ if (is_error_page) {
+ DCHECK_NE(net::OK, pending_error_code_);
+ return;
+ }
+
+ // TODO(mmenke): Figure out if this is needed.
+ 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) {
+ // We don't care about 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) {
+ // We don't care about subframes.
+ 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.
+ if (error_code == net::ERR_ABORTED) {
+ // We 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

Powered by Google App Engine
This is Rietveld 408576698