| 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_TAB_CONTENTS_INTERSTITIAL_PAGE_H_ | 5 #ifndef CHROME_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_ |
| 6 #define CHROME_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_ | 6 #define CHROME_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 10 #include "chrome/browser/renderer_host/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 { | 29 enum ResourceRequestAction; |
| 30 BLOCK, | |
| 31 RESUME, | |
| 32 CANCEL | |
| 33 }; | |
| 34 | 30 |
| 35 class InterstitialPage : public NotificationObserver, | 31 class InterstitialPage : public NotificationObserver, |
| 36 public RenderViewHostDelegate { | 32 public RenderViewHostDelegate { |
| 37 public: | 33 public: |
| 38 // 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 |
| 39 // 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 |
| 40 // 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 |
| 41 // 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 |
| 42 // new navigation entry). |new_navigation| should be false when the | 38 // new navigation entry). |new_navigation| should be false when the |
| 43 // 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. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 139 |
| 144 // Whether the Proceed or DontProceed have been called yet. | 140 // Whether the Proceed or DontProceed have been called yet. |
| 145 bool action_taken_; | 141 bool action_taken_; |
| 146 | 142 |
| 147 // Notification magic. | 143 // Notification magic. |
| 148 NotificationRegistrar notification_registrar_; | 144 NotificationRegistrar notification_registrar_; |
| 149 | 145 |
| 150 // The RenderViewHost displaying the interstitial contents. | 146 // The RenderViewHost displaying the interstitial contents. |
| 151 RenderViewHost* render_view_host_; | 147 RenderViewHost* render_view_host_; |
| 152 | 148 |
| 149 // The IDs for the RenderViewHost hidden by this interstitial. |
| 150 int original_rvh_process_id_; |
| 151 int original_rvh_id_; |
| 152 |
| 153 // Whether or not we should change the title of the tab when hidden (to revert | 153 // Whether or not we should change the title of the tab when hidden (to revert |
| 154 // it to its original value). | 154 // it to its original value). |
| 155 bool should_revert_tab_title_; | 155 bool should_revert_tab_title_; |
| 156 | 156 |
| 157 // Whether the ResourceDispatcherHost has been notified to cancel/resume the |
| 158 // resource requests blocked for the RenderViewHost. |
| 159 bool resource_dispatcher_host_notified_; |
| 160 |
| 157 // The original title of the tab that should be reverted to when the | 161 // The original title of the tab that should be reverted to when the |
| 158 // interstitial is hidden. | 162 // interstitial is hidden. |
| 159 std::wstring original_tab_title_; | 163 std::wstring original_tab_title_; |
| 160 | 164 |
| 161 MessageLoop* ui_loop_; | 165 MessageLoop* ui_loop_; |
| 162 | 166 |
| 163 // We keep a map of the various blocking pages shown as the UI tests need to | 167 // We keep a map of the various blocking pages shown as the UI tests need to |
| 164 // be able to retrieve them. | 168 // be able to retrieve them. |
| 165 typedef std::map<WebContents*,InterstitialPage*> InterstitialPageMap; | 169 typedef std::map<WebContents*,InterstitialPage*> InterstitialPageMap; |
| 166 static InterstitialPageMap* tab_to_interstitial_page_; | 170 static InterstitialPageMap* tab_to_interstitial_page_; |
| 167 | 171 |
| 168 DISALLOW_COPY_AND_ASSIGN(InterstitialPage); | 172 DISALLOW_COPY_AND_ASSIGN(InterstitialPage); |
| 169 }; | 173 }; |
| 170 | 174 |
| 171 #endif // #ifndef CHROME_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_ | 175 #endif // #ifndef CHROME_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_ |
| 172 | 176 |
| OLD | NEW |