| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_INTERSTITIAL_PAGE_H_ | 5 #ifndef CHROME_BROWSER_INTERSTITIAL_PAGE_H_ |
| 6 #define CHROME_BROWSER_INTERSTITIAL_PAGE_H_ | 6 #define CHROME_BROWSER_INTERSTITIAL_PAGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/render_view_host_delegate.h" | 10 #include "chrome/browser/render_view_host_delegate.h" |
| 11 #include "chrome/common/notification_registrar.h" | 11 #include "chrome/common/notification_registrar.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 | 13 |
| 14 class NavigationEntry; | 14 class NavigationEntry; |
| 15 class WebContents; | 15 class WebContents; |
| 16 | 16 |
| 17 // This class is a base class for interstitial pages, pages that show some | 17 // This class is a base class for interstitial pages, pages that show some |
| 18 // informative message asking for user validation before reaching the target | 18 // informative message asking for user validation before reaching the target |
| 19 // page. (Navigating to a page served over bad HTTPS or a page containing | 19 // page. (Navigating to a page served over bad HTTPS or a page containing |
| 20 // malware are typical cases where an interstitial is required.) | 20 // malware are typical cases where an interstitial is required.) |
| 21 // | 21 // |
| 22 // If specified in its constructor, this class creates a navigation entry so | 22 // If specified in its constructor, this class creates a navigation entry so |
| 23 // that when the interstitial shows, the current entry is the target URL. | 23 // that when the interstitial shows, the current entry is the target URL. |
| 24 // | 24 // |
| 25 // InterstitialPage instances take care of deleting themselves when closed | 25 // InterstitialPage instances take care of deleting themselves when closed |
| 26 // through a navigation, the WebContents closing them or the tab containing them | 26 // through a navigation, the WebContents closing them or the tab containing them |
| 27 // being closed. | 27 // being closed. |
| 28 | 28 |
| 29 enum ResourceRequestAction; |
| 30 |
| 29 class InterstitialPage : public NotificationObserver, | 31 class InterstitialPage : public NotificationObserver, |
| 30 public RenderViewHostDelegate { | 32 public RenderViewHostDelegate { |
| 31 public: | 33 public: |
| 32 // Creates an interstitial page to show in |tab|. |new_navigation| should be | 34 // Creates an interstitial page to show in |tab|. |new_navigation| should be |
| 33 // set to true when the interstitial is caused by loading a new page, in which | 35 // set to true when the interstitial is caused by loading a new page, in which |
| 34 // case a temporary navigation entry is created with the URL |url| and | 36 // case a temporary navigation entry is created with the URL |url| and |
| 35 // added to the navigation controller (so the interstitial page appears as a | 37 // added to the navigation controller (so the interstitial page appears as a |
| 36 // new navigation entry). |new_navigation| should be false when the | 38 // new navigation entry). |new_navigation| should be false when the |
| 37 // interstitial was triggered by a loading a sub-resource in a page. | 39 // interstitial was triggered by a loading a sub-resource in a page. |
| 38 InterstitialPage(WebContents* tab, bool new_navigation, const GURL& url); | 40 InterstitialPage(WebContents* tab, bool new_navigation, const GURL& url); |
| 39 virtual ~InterstitialPage(); | 41 virtual ~InterstitialPage(); |
| 40 | 42 |
| 41 // Shows the interstitial page in the tab. | 43 // Shows the interstitial page in the tab. |
| 42 virtual void Show(); | 44 virtual void Show(); |
| 43 | 45 |
| 44 // Hides the interstitial page. Warning: this deletes the InterstitialPage. | 46 // Hides the interstitial page. Warning: this deletes the InterstitialPage. |
| 45 void Hide(); | 47 void Hide(); |
| 46 | 48 |
| 47 // Retrieves the InterstitialPage if any associated with the specified | 49 // Retrieves the InterstitialPage if any associated with the specified |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 112 |
| 111 // Initializes tab_to_interstitial_page_ in a thread-safe manner. | 113 // Initializes tab_to_interstitial_page_ in a thread-safe manner. |
| 112 // Should be called before accessing tab_to_interstitial_page_. | 114 // Should be called before accessing tab_to_interstitial_page_. |
| 113 static void InitInterstitialPageMap(); | 115 static void InitInterstitialPageMap(); |
| 114 | 116 |
| 115 // Disable the interstitial: | 117 // Disable the interstitial: |
| 116 // - if it is not yet showing, then it won't be shown. | 118 // - if it is not yet showing, then it won't be shown. |
| 117 // - any command sent by the RenderViewHost will be ignored. | 119 // - any command sent by the RenderViewHost will be ignored. |
| 118 void Disable(); | 120 void Disable(); |
| 119 | 121 |
| 122 // Executes the passed action on the ResourceDispatcher (on the IO thread). |
| 123 // Used to block/resume/cancel requests for the RenderViewHost hidden by this |
| 124 // interstitial. |
| 125 void TakeActionOnResourceDispatcher(ResourceRequestAction action); |
| 126 |
| 120 // The tab in which we are displayed. | 127 // The tab in which we are displayed. |
| 121 WebContents* tab_; | 128 WebContents* tab_; |
| 122 | 129 |
| 123 // The URL that is shown when the interstitial is showing. | 130 // The URL that is shown when the interstitial is showing. |
| 124 GURL url_; | 131 GURL url_; |
| 125 | 132 |
| 126 // Whether this interstitial is shown as a result of a new navigation (in | 133 // Whether this interstitial is shown as a result of a new navigation (in |
| 127 // which case a transient navigation entry is created). | 134 // which case a transient navigation entry is created). |
| 128 bool new_navigation_; | 135 bool new_navigation_; |
| 129 | 136 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 140 RenderViewHost* render_view_host_; | 147 RenderViewHost* render_view_host_; |
| 141 | 148 |
| 142 // Whether or not we should change the title of the tab when hidden (to revert | 149 // Whether or not we should change the title of the tab when hidden (to revert |
| 143 // it to its original value). | 150 // it to its original value). |
| 144 bool should_revert_tab_title_; | 151 bool should_revert_tab_title_; |
| 145 | 152 |
| 146 // The original title of the tab that should be reverted to when the | 153 // The original title of the tab that should be reverted to when the |
| 147 // interstitial is hidden. | 154 // interstitial is hidden. |
| 148 std::wstring original_tab_title_; | 155 std::wstring original_tab_title_; |
| 149 | 156 |
| 157 MessageLoop* ui_loop_; |
| 158 |
| 150 // We keep a map of the various blocking pages shown as the UI tests need to | 159 // We keep a map of the various blocking pages shown as the UI tests need to |
| 151 // be able to retrieve them. | 160 // be able to retrieve them. |
| 152 typedef std::map<WebContents*,InterstitialPage*> InterstitialPageMap; | 161 typedef std::map<WebContents*,InterstitialPage*> InterstitialPageMap; |
| 153 static InterstitialPageMap* tab_to_interstitial_page_; | 162 static InterstitialPageMap* tab_to_interstitial_page_; |
| 154 | 163 |
| 155 DISALLOW_COPY_AND_ASSIGN(InterstitialPage); | 164 DISALLOW_COPY_AND_ASSIGN(InterstitialPage); |
| 156 }; | 165 }; |
| 157 | 166 |
| 158 #endif // #ifndef CHROME_BROWSER_INTERSTITIAL_PAGE_H_ | 167 #endif // #ifndef CHROME_BROWSER_INTERSTITIAL_PAGE_H_ |
| 159 | 168 |
| OLD | NEW |