OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "content/browser/frame_host/interstitial_page_navigator_impl.h" | 5 #include "content/browser/frame_host/interstitial_page_navigator_impl.h" |
6 | 6 |
7 #include "content/browser/frame_host/interstitial_page_impl.h" | 7 #include "content/browser/frame_host/interstitial_page_impl.h" |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
9 #include "content/browser/frame_host/navigator_delegate.h" | 9 #include "content/browser/frame_host/navigator_delegate.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 InterstitialPageNavigatorImpl::InterstitialPageNavigatorImpl( | 14 InterstitialPageNavigatorImpl::InterstitialPageNavigatorImpl( |
15 InterstitialPageImpl* interstitial, | 15 InterstitialPageImpl* interstitial, |
16 NavigationControllerImpl* navigation_controller) | 16 NavigationControllerImpl* navigation_controller) |
17 : interstitial_(interstitial), | 17 : interstitial_(interstitial), |
18 controller_(navigation_controller) {} | 18 controller_(navigation_controller), |
| 19 enabled_(true) {} |
19 | 20 |
20 InterstitialPageNavigatorImpl::~InterstitialPageNavigatorImpl() {} | 21 InterstitialPageNavigatorImpl::~InterstitialPageNavigatorImpl() {} |
21 | 22 |
22 NavigatorDelegate* InterstitialPageNavigatorImpl::GetDelegate() { | 23 NavigatorDelegate* InterstitialPageNavigatorImpl::GetDelegate() { |
23 return interstitial_; | 24 return interstitial_; |
24 } | 25 } |
25 | 26 |
26 NavigationController* InterstitialPageNavigatorImpl::GetController() { | 27 NavigationController* InterstitialPageNavigatorImpl::GetController() { |
27 return controller_; | 28 return controller_; |
28 } | 29 } |
29 | 30 |
30 void InterstitialPageNavigatorImpl::DidStartProvisionalLoad( | 31 void InterstitialPageNavigatorImpl::DidStartProvisionalLoad( |
31 RenderFrameHostImpl* render_frame_host, | 32 RenderFrameHostImpl* render_frame_host, |
32 const GURL& url, | 33 const GURL& url, |
33 const std::vector<GURL>& redirect_chain, | 34 const std::vector<GURL>& redirect_chain, |
34 const base::TimeTicks& navigation_start) { | 35 const base::TimeTicks& navigation_start) { |
| 36 // Do not proceed if the interstitial itself has been disabled. |
| 37 if (!enabled_) |
| 38 return; |
| 39 |
35 // The interstitial page should only navigate once. | 40 // The interstitial page should only navigate once. |
36 DCHECK(!render_frame_host->navigation_handle()); | 41 DCHECK(!render_frame_host->navigation_handle()); |
37 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create( | 42 render_frame_host->SetNavigationHandle(NavigationHandleImpl::Create( |
38 url, redirect_chain, render_frame_host->frame_tree_node(), | 43 url, redirect_chain, render_frame_host->frame_tree_node(), |
39 false, /* is_renderer_initiated */ | 44 false, /* is_renderer_initiated */ |
40 false, /* is_synchronous */ | 45 false, /* is_synchronous */ |
41 navigation_start, /* navigation_state */ | 46 navigation_start, /* navigation_state */ |
42 0, /* pending_nav_entry_id */ | 47 0, /* pending_nav_entry_id */ |
43 false, /* started_in_context_menu */ | 48 false, /* started_in_context_menu */ |
44 CSPDisposition::CHECK, /* should_check_main_world_csp */ | 49 CSPDisposition::CHECK, /* should_check_main_world_csp */ |
45 false /* is_form_submission */ | 50 false /* is_form_submission */ |
46 )); | 51 )); |
47 } | 52 } |
48 | 53 |
49 void InterstitialPageNavigatorImpl::DidNavigate( | 54 void InterstitialPageNavigatorImpl::DidNavigate( |
50 RenderFrameHostImpl* render_frame_host, | 55 RenderFrameHostImpl* render_frame_host, |
51 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params, | 56 const FrameHostMsg_DidCommitProvisionalLoad_Params& input_params, |
52 std::unique_ptr<NavigationHandleImpl> navigation_handle) { | 57 std::unique_ptr<NavigationHandleImpl> navigation_handle) { |
| 58 // Do not proceed if the interstitial itself has been disabled. |
| 59 if (!enabled_) |
| 60 return; |
| 61 |
53 navigation_handle->DidCommitNavigation( | 62 navigation_handle->DidCommitNavigation( |
54 input_params, true, false, GURL(), NAVIGATION_TYPE_NEW_PAGE, | 63 input_params, true, false, GURL(), NAVIGATION_TYPE_NEW_PAGE, |
55 render_frame_host); | 64 render_frame_host); |
56 navigation_handle.reset(); | 65 navigation_handle.reset(); |
57 | 66 |
58 // TODO(nasko): Move implementation here, but for the time being call out | 67 // TODO(nasko): Move implementation here, but for the time being call out |
59 // to the interstitial page code. | 68 // to the interstitial page code. |
60 interstitial_->DidNavigate(render_frame_host->render_view_host(), | 69 interstitial_->DidNavigate(render_frame_host->render_view_host(), |
61 input_params); | 70 input_params); |
62 } | 71 } |
63 | 72 |
| 73 void InterstitialPageNavigatorImpl::Disable() { |
| 74 enabled_ = false; |
| 75 |
| 76 // This is no longer safe to access. |
| 77 controller_ = nullptr; |
| 78 } |
| 79 |
64 } // namespace content | 80 } // namespace content |
OLD | NEW |