Chromium Code Reviews| Index: chrome/browser/captive_portal/captive_portal_tab_observer.h |
| =================================================================== |
| --- chrome/browser/captive_portal/captive_portal_tab_observer.h (revision 0) |
| +++ chrome/browser/captive_portal/captive_portal_tab_observer.h (revision 0) |
| @@ -0,0 +1,74 @@ |
| +// 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. |
| + |
| +#ifndef CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_OBSERVER_H_ |
| +#define CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_OBSERVER_H_ |
| +#pragma once |
| + |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "content/public/browser/web_contents_observer.h" |
| + |
| +namespace captive_portal { |
| + |
| +class CaptivePortalTabHelper; |
| + |
| +// A WebContentsObserver that simplifies the messages a CaptivePortalTabHelper |
| +// receives. It filters non-main-frame resource loads, and treats the commit |
| +// of an error page as a single event, rather than as 3 (ProvisionalLoadFail, |
| +// DidStartProvisionalLoad, DidCommit). |
| +// |
| +// TODO(mmenke): Support redirects. Needed for HSTS, which simulates redirects |
| +// at the network layer. Also should reduce the number of |
|
cbentzel
2012/05/18 03:23:16
Why does this reduce the number of unnecessary che
mmenke
2012/05/18 06:12:53
Thinking false positives are more likely in the ca
|
| +// unnecessary captive portal checks. |
| +class CaptivePortalTabObserver : public content::WebContentsObserver { |
| + public: |
| + CaptivePortalTabObserver(CaptivePortalTabHelper* tab_helper, |
| + content::WebContents* web_contents); |
| + virtual ~CaptivePortalTabObserver(); |
| + |
| + // content::WebContentsObserver: |
| + virtual void DidStartProvisionalLoadForFrame( |
| + int64 frame_id, |
| + bool is_main_frame, |
| + const GURL& validated_url, |
| + bool is_error_page, |
| + content::RenderViewHost* render_view_host) OVERRIDE; |
| + |
| + virtual void DidCommitProvisionalLoadForFrame( |
| + int64 frame_id, |
| + bool is_main_frame, |
| + const GURL& url, |
| + content::PageTransition transition_type, |
| + content::RenderViewHost* render_view_host) OVERRIDE; |
| + |
| + virtual void DidFailProvisionalLoad( |
| + int64 frame_id, |
| + bool is_main_frame, |
| + const GURL& validated_url, |
| + int error_code, |
| + const string16& error_description, |
| + content::RenderViewHost* render_view_host) OVERRIDE; |
| + |
| + virtual void DidStopLoading() OVERRIDE; |
|
cbentzel
2012/05/18 03:23:16
I'm unsure if this should use DidStopLoading or Di
mmenke
2012/05/18 06:12:53
Went with DidStopLoading because I can imagine a c
mmenke
2012/05/18 08:08:10
Oh, and also, if logging it takes you to a redirec
|
| + |
| + content::WebContents* web_contents() const { |
| + return content::WebContentsObserver::web_contents(); |
| + } |
| + |
| + private: |
| + // The TabHelper messages are passed to. |
| + CaptivePortalTabHelper* tab_helper_; |
| + |
| + // If a provisional load has failed, and the tab is loading an error page, the |
| + // error code associated with the error page we're loading. |
| + // net::OK, otherwise. |
| + int pending_error_code_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CaptivePortalTabObserver); |
| +}; |
| + |
| +} // namespace captive_portal |
| + |
| +#endif // CHROME_BROWSER_CAPTIVE_PORTAL_CAPTIVE_PORTAL_TAB_OBSERVER_H_ |
| Property changes on: chrome\browser\captive_portal\captive_portal_tab_observer.h |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |