| 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_TAB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ |
| 6 #define CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ | 6 #define CONTENT_BROWSER_TAB_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" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "content/public/browser/interstitial_page.h" | 12 #include "content/public/browser/interstitial_page.h" |
| 13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/render_view_host_delegate.h" | 15 #include "content/public/browser/render_view_host_delegate.h" |
| 16 #include "content/public/common/renderer_preferences.h" | 16 #include "content/public/common/renderer_preferences.h" |
| 17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 | 18 |
| 19 class RenderViewHostImpl; | |
| 20 class TabContents; | 19 class TabContents; |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| 23 class NavigationEntry; | 22 class NavigationEntry; |
| 23 class RenderViewHostImpl; |
| 24 class WebContentsView; | 24 class WebContentsView; |
| 25 } | 25 } |
| 26 | 26 |
| 27 enum ResourceRequestAction { | 27 enum ResourceRequestAction { |
| 28 BLOCK, | 28 BLOCK, |
| 29 RESUME, | 29 RESUME, |
| 30 CANCEL | 30 CANCEL |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 class CONTENT_EXPORT InterstitialPageImpl | 33 class CONTENT_EXPORT InterstitialPageImpl |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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; |
| 56 virtual RenderViewHost* GetRenderViewHostForTesting() const OVERRIDE; | 56 virtual content::RenderViewHost* GetRenderViewHostForTesting() const OVERRIDE; |
| 57 virtual content::InterstitialPageDelegate* GetDelegateForTesting() OVERRIDE; | 57 virtual content::InterstitialPageDelegate* GetDelegateForTesting() OVERRIDE; |
| 58 virtual void DontCreateViewForTesting() OVERRIDE; | 58 virtual void DontCreateViewForTesting() OVERRIDE; |
| 59 virtual void SetSize(const gfx::Size& size) OVERRIDE; | 59 virtual void SetSize(const gfx::Size& size) OVERRIDE; |
| 60 virtual void Focus() OVERRIDE; | 60 virtual void Focus() OVERRIDE; |
| 61 | 61 |
| 62 // Allows the user to navigate away by disabling the interstitial, canceling | 62 // Allows the user to navigate away by disabling the interstitial, canceling |
| 63 // the pending request, and unblocking the hidden renderer. The interstitial | 63 // the pending request, and unblocking the hidden renderer. The interstitial |
| 64 // will stay visible until the navigation completes. | 64 // will stay visible until the navigation completes. |
| 65 void CancelForNavigation(); | 65 void CancelForNavigation(); |
| 66 | 66 |
| 67 // Focus the first (last if reverse is true) element in the interstitial page. | 67 // Focus the first (last if reverse is true) element in the interstitial page. |
| 68 // Called when tab traversing. | 68 // Called when tab traversing. |
| 69 void FocusThroughTabTraversal(bool reverse); | 69 void FocusThroughTabTraversal(bool reverse); |
| 70 | 70 |
| 71 // See description above field. | 71 // See description above field. |
| 72 void set_reload_on_dont_proceed(bool value) { | 72 void set_reload_on_dont_proceed(bool value) { |
| 73 reload_on_dont_proceed_ = value; | 73 reload_on_dont_proceed_ = value; |
| 74 } | 74 } |
| 75 bool reload_on_dont_proceed() const { return reload_on_dont_proceed_; } | 75 bool reload_on_dont_proceed() const { return reload_on_dont_proceed_; } |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 // content::NotificationObserver method: | 78 // content::NotificationObserver method: |
| 79 virtual void Observe(int type, | 79 virtual void Observe(int type, |
| 80 const content::NotificationSource& source, | 80 const content::NotificationSource& source, |
| 81 const content::NotificationDetails& details) OVERRIDE; | 81 const content::NotificationDetails& details) OVERRIDE; |
| 82 | 82 |
| 83 // RenderViewHostDelegate implementation: | 83 // RenderViewHostDelegate implementation: |
| 84 virtual View* GetViewDelegate() OVERRIDE; | 84 virtual View* GetViewDelegate() OVERRIDE; |
| 85 virtual const GURL& GetURL() const OVERRIDE; | 85 virtual const GURL& GetURL() const OVERRIDE; |
| 86 virtual void RenderViewGone(RenderViewHost* render_view_host, | 86 virtual void RenderViewGone(content::RenderViewHost* render_view_host, |
| 87 base::TerminationStatus status, | 87 base::TerminationStatus status, |
| 88 int error_code) OVERRIDE; | 88 int error_code) OVERRIDE; |
| 89 virtual void DidNavigate( | 89 virtual void DidNavigate( |
| 90 RenderViewHost* render_view_host, | 90 content::RenderViewHost* render_view_host, |
| 91 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; | 91 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; |
| 92 virtual void UpdateTitle(RenderViewHost* render_view_host, | 92 virtual void UpdateTitle(content::RenderViewHost* render_view_host, |
| 93 int32 page_id, | 93 int32 page_id, |
| 94 const string16& title, | 94 const string16& title, |
| 95 base::i18n::TextDirection title_direction) OVERRIDE; | 95 base::i18n::TextDirection title_direction) OVERRIDE; |
| 96 virtual content::RendererPreferences GetRendererPrefs( | 96 virtual content::RendererPreferences GetRendererPrefs( |
| 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* tab() 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 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; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 153 // The default is false. | 153 // The default is false. |
| 154 bool reload_on_dont_proceed_; | 154 bool reload_on_dont_proceed_; |
| 155 | 155 |
| 156 // Whether this interstitial is enabled. See Disable() for more info. | 156 // Whether this interstitial is enabled. See Disable() for more info. |
| 157 bool enabled_; | 157 bool enabled_; |
| 158 | 158 |
| 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 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 tab when hidden (to revert |
| 170 // it to its original value). | 170 // it to its original value). |
| 171 bool should_revert_tab_title_; | 171 bool should_revert_tab_title_; |
| 172 | 172 |
| 173 // Whether or not the tab was loading resources when the interstitial was | 173 // Whether or not the tab was loading resources when the interstitial was |
| (...skipping 15 matching lines...) Expand all Loading... |
| 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_TAB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ | 198 #endif // CONTENT_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_IMPL_H_ |
| OLD | NEW |