// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_CAPTIVE_PORTAL_CONTENT_CAPTIVE_PORTAL_TAB_HELPER_H_ #define COMPONENTS_CAPTIVE_PORTAL_CONTENT_CAPTIVE_PORTAL_TAB_HELPER_H_ #include <memory> #include "base/compiler_specific.h" #include "base/memory/raw_ptr.h" #include "components/captive_portal/content/captive_portal_service.h" #include "components/captive_portal/content/captive_portal_tab_reloader.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" namespace content { class NavigationHandle; class WebContents; } // namespace content namespace net { class SSLInfo; } class CaptivePortalBrowserTest; namespace captive_portal { class CaptivePortalLoginDetector; class CaptivePortalTabReloader; // Along with the classes it owns, responsible for detecting page loads broken // by a captive portal, triggering captive portal checks on navigation events // that may indicate a captive portal is present, or has been removed / logged // in to, and taking any correcting actions. Lives on the UI thread. // // It acts as a WebContentsObserver for its CaptivePortalLoginDetector and // CaptivePortalTabReloader. It filters out non-main-frame navigations. It is // also needed by CaptivePortalTabReloaders to inform the tab's // CaptivePortalLoginDetector when the tab is at a captive portal's login page. // // The TabHelper assumes that a WebContents can only have one main frame // navigation at a time. This assumption can be violated in rare cases, for // example, a same-site navigation interrupted by a cross-process navigation // started from the omnibox, may commit before it can be cancelled. In these // cases, this class may pass incorrect messages to the TabReloader, which // will, at worst, result in not opening up a login tab until a second load // fails or not automatically reloading a tab after logging in. // TODO(clamy): See if this class can be made to handle these edge-cases // following the refactor of navigation signaling to WebContentsObservers. // // For the design doc, see: // https://docs.google.com/document/d/1k-gP2sswzYNvryu9NcgN7q5XrsMlUdlUdoW9WRaEmfM/edit class CaptivePortalTabHelper : public content::WebContentsObserver, public content::WebContentsUserData<CaptivePortalTabHelper> { … }; } // namespace captive_portal #endif // COMPONENTS_CAPTIVE_PORTAL_CONTENT_CAPTIVE_PORTAL_TAB_HELPER_H_