diff options
Diffstat (limited to 'chrome/browser/interstitial_page.h')
-rw-r--r-- | chrome/browser/interstitial_page.h | 111 |
1 files changed, 35 insertions, 76 deletions
diff --git a/chrome/browser/interstitial_page.h b/chrome/browser/interstitial_page.h index ab8967f..ce17818 100644 --- a/chrome/browser/interstitial_page.h +++ b/chrome/browser/interstitial_page.h @@ -7,16 +7,16 @@ #include <string> -#include "chrome/browser/web_contents_view_win.h" #include "chrome/common/notification_registrar.h" +#include "chrome/common/notification_service.h" #include "googleurl/src/gurl.h" class NavigationEntry; -class WebContents; +class TabContents; // This class is a base class for interstitial pages, pages that show some // informative message asking for user validation before reaching the target -// page. (Navigating to a page served over bad HTTPS or a page containing +// page. (Navigating to a page served over bad HTTPS or a page contining // malware are typical cases where an interstitial is required.) // // If specified in its constructor, this class creates a navigation entry so @@ -26,27 +26,27 @@ class WebContents; // through a navigation, the WebContents closing them or the tab containing them // being closed. -class InterstitialPage : public NotificationObserver, - public RenderViewHostDelegate { +class InterstitialPage : public NotificationObserver { public: - // Creates an interstitial page to show in |tab|. |new_navigation| should be - // set to true when the interstitial is caused by loading a new page, in which - // case a temporary navigation entry is created with the URL |url| and + // Creates an interstitial page to show in |tab|. If |create_navigation_entry| + // is true, a temporary navigation entry is created with the URL |url| and // added to the navigation controller (so the interstitial page appears as a - // new navigation entry). |new_navigation| should be false when the - // interstitial was triggered by a loading a sub-resource in a page. - InterstitialPage(WebContents* tab, bool new_navigation, const GURL& url); + // new navigation entry). + InterstitialPage(TabContents* tab, + bool create_navigation_entry, + const GURL& url); virtual ~InterstitialPage(); // Shows the interstitial page in the tab. - virtual void Show(); + void Show(); - // Hides the interstitial page. Warning: this deletes the InterstitialPage. - void Hide(); + // Invoked by the tab showing the interstitial to notify that the interstitial
+ // page was closed.
+ virtual void InterstitialClosed();
// Retrieves the InterstitialPage if any associated with the specified // |tab_contents| (used by ui tests). - static InterstitialPage* GetInterstitialPage(WebContents* web_contents); + static InterstitialPage* GetInterstitialPage(TabContents* tab_contents); // Sub-classes should return the HTML that should be displayed in the page. virtual std::string GetHTMLContents() { return std::string(); } @@ -57,34 +57,7 @@ class InterstitialPage : public NotificationObserver, // Warning: 'this' has been deleted when this method returns. virtual void DontProceed(); - // Sub-classes should call this method when the user has chosen to proceed to - // the target URL. - // Warning: 'this' has been deleted when this method returns. - virtual void Proceed(); - - // Sizes the RenderViewHost showing the actual interstitial page contents. - void SetSize(const gfx::Size& size); - protected: - // NotificationObserver method: - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - // RenderViewHostDelegate implementation: - virtual Profile* GetProfile() const; - virtual WebPreferences GetWebkitPrefs() { - return WebPreferences(); - } - virtual void DidNavigate(RenderViewHost* render_view_host, - const ViewHostMsg_FrameNavigate_Params& params); - virtual void RendererGone(RenderViewHost* render_view_host); - virtual void DomOperationResponse(const std::string& json_string, - int automation_id); - virtual void UpdateTitle(RenderViewHost* render_view_host, - int32 page_id, - const std::wstring& title); - // Invoked when the page sent a command through DOMAutomation. virtual void CommandReceived(const std::string& command) { } @@ -95,61 +68,47 @@ class InterstitialPage : public NotificationObserver, // |create_navigation_entry| set to true. virtual void UpdateEntry(NavigationEntry* entry) { } - WebContents* tab() const { return tab_; } - const GURL& url() const { return url_; } - RenderViewHost* render_view_host() const { return render_view_host_; } + // Sub-classes should call this method when the user has chosen to proceed to + // the target URL. + // Warning: 'this' has been deleted when this method returns. + virtual void Proceed(); - // Creates and shows the RenderViewHost containing the interstitial content. - // Overriden in unit tests. - virtual RenderViewHost* CreateRenderViewHost(); + TabContents* tab() const { return tab_; } + const GURL& url() const { return url_; } private: // AutomationProvider needs access to Proceed and DontProceed to simulate // user actions. friend class AutomationProvider; + // NotificationObserver method. + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + // Initializes tab_to_interstitial_page_ in a thread-safe manner. // Should be called before accessing tab_to_interstitial_page_. static void InitInterstitialPageMap(); - // Disable the interstitial: - // - if it is not yet showing, then it won't be shown. - // - any command sent by the RenderViewHost will be ignored. - void Disable(); + // A flag to indicate if we've notified |delegate_| of the user's decision. + bool delegate_has_been_notified_; // The tab in which we are displayed. - WebContents* tab_; + TabContents* tab_; // The URL that is shown when the interstitial is showing. GURL url_; - // Whether this interstitial is shown as a result of a new navigation (in - // which case a transient navigation entry is created). - bool new_navigation_; - - // Whether this interstitial is enabled. See Disable() for more info. - bool enabled_; - - // Whether the Proceed or DontProceed have been called yet. - bool action_taken_; - - // Notification magic.
- NotificationRegistrar notification_registrar_;
- - // The RenderViewHost displaying the interstitial contents. - RenderViewHost* render_view_host_; - - // Whether or not we should change the title of the tab when hidden (to revert - // it to its original value). - bool should_revert_tab_title_; + // Whether a transient navigation entry should be created when the page is + // shown. + bool create_navigation_entry_; - // The original title of the tab that should be reverted to when the - // interstitial is hidden. - std::wstring original_tab_title_; + // Notification magic. + NotificationRegistrar notification_registrar_; // We keep a map of the various blocking pages shown as the UI tests need to // be able to retrieve them. - typedef std::map<WebContents*,InterstitialPage*> InterstitialPageMap; + typedef std::map<TabContents*,InterstitialPage*> InterstitialPageMap; static InterstitialPageMap* tab_to_interstitial_page_; DISALLOW_COPY_AND_ASSIGN(InterstitialPage); |