| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_WEB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 public content::NotificationObserver, | 35 public content::NotificationObserver, |
| 36 public content::RenderViewHostDelegate { | 36 public content::RenderViewHostDelegate { |
| 37 public: | 37 public: |
| 38 // The different state of actions the user can take in an interstitial. | 38 // The different state of actions the user can take in an interstitial. |
| 39 enum ActionState { | 39 enum ActionState { |
| 40 NO_ACTION, // No action has been taken yet. | 40 NO_ACTION, // No action has been taken yet. |
| 41 PROCEED_ACTION, // "Proceed" was selected. | 41 PROCEED_ACTION, // "Proceed" was selected. |
| 42 DONT_PROCEED_ACTION // "Don't proceed" was selected. | 42 DONT_PROCEED_ACTION // "Don't proceed" was selected. |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 InterstitialPageImpl(content::WebContents* tab, | 45 InterstitialPageImpl(content::WebContents* web_contents, |
| 46 bool new_navigation, | 46 bool new_navigation, |
| 47 const GURL& url, | 47 const GURL& url, |
| 48 content::InterstitialPageDelegate* delegate); | 48 content::InterstitialPageDelegate* delegate); |
| 49 virtual ~InterstitialPageImpl(); | 49 virtual ~InterstitialPageImpl(); |
| 50 | 50 |
| 51 // InterstitialPage implementation: | 51 // InterstitialPage implementation: |
| 52 virtual void Show() OVERRIDE; | 52 virtual void Show() OVERRIDE; |
| 53 virtual void Hide() OVERRIDE; | 53 virtual void Hide() OVERRIDE; |
| 54 virtual void DontProceed() OVERRIDE; | 54 virtual void DontProceed() OVERRIDE; |
| 55 virtual void Proceed() OVERRIDE; | 55 virtual void Proceed() OVERRIDE; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 content::BrowserContext* browser_context) const OVERRIDE; | 97 content::BrowserContext* browser_context) const OVERRIDE; |
| 98 virtual WebPreferences GetWebkitPrefs() OVERRIDE; | 98 virtual WebPreferences GetWebkitPrefs() OVERRIDE; |
| 99 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 99 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 100 bool* is_keyboard_shortcut) OVERRIDE; | 100 bool* is_keyboard_shortcut) OVERRIDE; |
| 101 virtual void HandleKeyboardEvent( | 101 virtual void HandleKeyboardEvent( |
| 102 const NativeWebKeyboardEvent& event) OVERRIDE; | 102 const NativeWebKeyboardEvent& event) OVERRIDE; |
| 103 virtual content::ViewType GetRenderViewType() const OVERRIDE; | 103 virtual content::ViewType GetRenderViewType() const OVERRIDE; |
| 104 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; | 104 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE; |
| 105 | 105 |
| 106 bool enabled() const { return enabled_; } | 106 bool enabled() const { return enabled_; } |
| 107 content::WebContents* tab() const; | 107 content::WebContents* web_contents() const; |
| 108 const GURL& url() const { return url_; } | 108 const GURL& url() const { return url_; } |
| 109 | 109 |
| 110 // Creates the RenderViewHost containing the interstitial content. | 110 // Creates the RenderViewHost containing the interstitial content. |
| 111 // Overriden in unit tests. | 111 // Overriden in unit tests. |
| 112 virtual content::RenderViewHost* CreateRenderViewHost(); | 112 virtual content::RenderViewHost* CreateRenderViewHost(); |
| 113 | 113 |
| 114 // Creates the WebContentsView that shows the interstitial RVH. | 114 // Creates the WebContentsView that shows the interstitial RVH. |
| 115 // Overriden in unit tests. | 115 // Overriden in unit tests. |
| 116 virtual content::WebContentsView* CreateWebContentsView(); | 116 virtual content::WebContentsView* CreateWebContentsView(); |
| 117 | 117 |
| 118 // Notification magic. | 118 // Notification magic. |
| 119 content::NotificationRegistrar notification_registrar_; | 119 content::NotificationRegistrar notification_registrar_; |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 class InterstitialPageRVHViewDelegate; | 122 class InterstitialPageRVHViewDelegate; |
| 123 | 123 |
| 124 // Disable the interstitial: | 124 // Disable the interstitial: |
| 125 // - if it is not yet showing, then it won't be shown. | 125 // - if it is not yet showing, then it won't be shown. |
| 126 // - any command sent by the RenderViewHost will be ignored. | 126 // - any command sent by the RenderViewHost will be ignored. |
| 127 void Disable(); | 127 void Disable(); |
| 128 | 128 |
| 129 // Executes the passed action on the ResourceDispatcher (on the IO thread). | 129 // Executes the passed action on the ResourceDispatcher (on the IO thread). |
| 130 // Used to block/resume/cancel requests for the RenderViewHost hidden by this | 130 // Used to block/resume/cancel requests for the RenderViewHost hidden by this |
| 131 // interstitial. | 131 // interstitial. |
| 132 void TakeActionOnResourceDispatcher(ResourceRequestAction action); | 132 void TakeActionOnResourceDispatcher(ResourceRequestAction action); |
| 133 | 133 |
| 134 // The contents in which we are displayed. | 134 // The contents in which we are displayed. |
| 135 WebContentsImpl* tab_; | 135 WebContentsImpl* web_contents_; |
| 136 | 136 |
| 137 // The URL that is shown when the interstitial is showing. | 137 // The URL that is shown when the interstitial is showing. |
| 138 GURL url_; | 138 GURL url_; |
| 139 | 139 |
| 140 // Whether this interstitial is shown as a result of a new navigation (in | 140 // Whether this interstitial is shown as a result of a new navigation (in |
| 141 // which case a transient navigation entry is created). | 141 // which case a transient navigation entry is created). |
| 142 bool new_navigation_; | 142 bool new_navigation_; |
| 143 | 143 |
| 144 // Whether we should discard the pending navigation entry when not proceeding. | 144 // Whether we should discard the pending navigation entry when not proceeding. |
| 145 // This is to deal with cases where |new_navigation_| is true but a new | 145 // This is to deal with cases where |new_navigation_| is true but a new |
| (...skipping 13 matching lines...) Expand all Loading... |
| 159 // Whether the Proceed or DontProceed methods have been called yet. | 159 // Whether the Proceed or DontProceed methods have been called yet. |
| 160 ActionState action_taken_; | 160 ActionState action_taken_; |
| 161 | 161 |
| 162 // The RenderViewHost displaying the interstitial contents. | 162 // The RenderViewHost displaying the interstitial contents. |
| 163 content::RenderViewHostImpl* render_view_host_; | 163 content::RenderViewHostImpl* render_view_host_; |
| 164 | 164 |
| 165 // The IDs for the Render[View|Process]Host hidden by this interstitial. | 165 // The IDs for the Render[View|Process]Host hidden by this interstitial. |
| 166 int original_child_id_; | 166 int original_child_id_; |
| 167 int original_rvh_id_; | 167 int original_rvh_id_; |
| 168 | 168 |
| 169 // Whether or not we should change the title of the tab when hidden (to revert | 169 // Whether or not we should change the title of the contents when hidden (to |
| 170 // it to its original value). | 170 // revert it to its original value). |
| 171 bool should_revert_tab_title_; | 171 bool should_revert_web_contents_title_; |
| 172 | 172 |
| 173 // Whether or not the tab was loading resources when the interstitial was | 173 // Whether or not the contents was loading resources when the interstitial was |
| 174 // shown. We restore this state if the user proceeds from the interstitial. | 174 // shown. We restore this state if the user proceeds from the interstitial. |
| 175 bool tab_was_loading_; | 175 bool web_contents_was_loading_; |
| 176 | 176 |
| 177 // Whether the ResourceDispatcherHost has been notified to cancel/resume the | 177 // Whether the ResourceDispatcherHost has been notified to cancel/resume the |
| 178 // resource requests blocked for the RenderViewHost. | 178 // resource requests blocked for the RenderViewHost. |
| 179 bool resource_dispatcher_host_notified_; | 179 bool resource_dispatcher_host_notified_; |
| 180 | 180 |
| 181 // The original title of the tab that should be reverted to when the | 181 // The original title of the contents that should be reverted to when the |
| 182 // interstitial is hidden. | 182 // interstitial is hidden. |
| 183 string16 original_tab_title_; | 183 string16 original_web_contents_title_; |
| 184 | 184 |
| 185 // Our RenderViewHostViewDelegate, necessary for accelerators to work. | 185 // Our RenderViewHostViewDelegate, necessary for accelerators to work. |
| 186 scoped_ptr<InterstitialPageRVHViewDelegate> rvh_view_delegate_; | 186 scoped_ptr<InterstitialPageRVHViewDelegate> rvh_view_delegate_; |
| 187 | 187 |
| 188 // Settings passed to the renderer. | 188 // Settings passed to the renderer. |
| 189 mutable content::RendererPreferences renderer_preferences_; | 189 mutable content::RendererPreferences renderer_preferences_; |
| 190 | 190 |
| 191 bool create_view_; | 191 bool create_view_; |
| 192 | 192 |
| 193 scoped_ptr<content::InterstitialPageDelegate> delegate_; | 193 scoped_ptr<content::InterstitialPageDelegate> delegate_; |
| 194 | 194 |
| 195 DISALLOW_COPY_AND_ASSIGN(InterstitialPageImpl); | 195 DISALLOW_COPY_AND_ASSIGN(InterstitialPageImpl); |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 #endif // CONTENT_BROWSER_WEB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ | 198 #endif // CONTENT_BROWSER_WEB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ |
| OLD | NEW |