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_impl.h" | 5 #include "content/browser/frame_host/interstitial_page_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 controller_(static_cast<NavigationControllerImpl*>( | 147 controller_(static_cast<NavigationControllerImpl*>( |
148 &web_contents->GetController())), | 148 &web_contents->GetController())), |
149 render_widget_host_delegate_(render_widget_host_delegate), | 149 render_widget_host_delegate_(render_widget_host_delegate), |
150 url_(url), | 150 url_(url), |
151 new_navigation_(new_navigation), | 151 new_navigation_(new_navigation), |
152 should_discard_pending_nav_entry_(new_navigation), | 152 should_discard_pending_nav_entry_(new_navigation), |
153 reload_on_dont_proceed_(false), | 153 reload_on_dont_proceed_(false), |
154 enabled_(true), | 154 enabled_(true), |
155 action_taken_(NO_ACTION), | 155 action_taken_(NO_ACTION), |
156 render_view_host_(NULL), | 156 render_view_host_(NULL), |
| 157 // TODO(creis): Is it sane for an interstitial page to have a RVHM? |
| 158 // Do we need to be its delegate? |
| 159 frame_tree_(this, this, NULL), |
157 original_child_id_(web_contents->GetRenderProcessHost()->GetID()), | 160 original_child_id_(web_contents->GetRenderProcessHost()->GetID()), |
158 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), | 161 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), |
159 should_revert_web_contents_title_(false), | 162 should_revert_web_contents_title_(false), |
160 web_contents_was_loading_(false), | 163 web_contents_was_loading_(false), |
161 resource_dispatcher_host_notified_(false), | 164 resource_dispatcher_host_notified_(false), |
162 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)), | 165 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)), |
163 create_view_(true), | 166 create_view_(true), |
164 delegate_(delegate), | 167 delegate_(delegate), |
165 weak_ptr_factory_(this) { | 168 weak_ptr_factory_(this) { |
166 InitInterstitialPageMap(); | 169 InitInterstitialPageMap(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 entry->set_page_type(PAGE_TYPE_INTERSTITIAL); | 225 entry->set_page_type(PAGE_TYPE_INTERSTITIAL); |
223 | 226 |
224 // Give delegates a chance to set some states on the navigation entry. | 227 // Give delegates a chance to set some states on the navigation entry. |
225 delegate_->OverrideEntry(entry); | 228 delegate_->OverrideEntry(entry); |
226 | 229 |
227 controller_->SetTransientEntry(entry); | 230 controller_->SetTransientEntry(entry); |
228 } | 231 } |
229 | 232 |
230 DCHECK(!render_view_host_); | 233 DCHECK(!render_view_host_); |
231 render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost()); | 234 render_view_host_ = static_cast<RenderViewHostImpl*>(CreateRenderViewHost()); |
232 render_view_host_->AttachToFrameTree(); | |
233 CreateWebContentsView(); | 235 CreateWebContentsView(); |
234 | 236 |
235 std::string data_url = "data:text/html;charset=utf-8," + | 237 std::string data_url = "data:text/html;charset=utf-8," + |
236 net::EscapePath(delegate_->GetHTMLContents()); | 238 net::EscapePath(delegate_->GetHTMLContents()); |
237 render_view_host_->NavigateToURL(GURL(data_url)); | 239 render_view_host_->NavigateToURL(GURL(data_url)); |
238 | 240 |
239 notification_registrar_.Add(this, NOTIFICATION_NAV_ENTRY_PENDING, | 241 notification_registrar_.Add(this, NOTIFICATION_NAV_ENTRY_PENDING, |
240 Source<NavigationController>(controller_)); | 242 Source<NavigationController>(controller_)); |
241 notification_registrar_.Add( | 243 notification_registrar_.Add( |
242 this, NOTIFICATION_DOM_OPERATION_RESPONSE, | 244 this, NOTIFICATION_DOM_OPERATION_RESPONSE, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 278 } |
277 | 279 |
278 // Shutdown the RVH asynchronously, as we may have been called from a RVH | 280 // Shutdown the RVH asynchronously, as we may have been called from a RVH |
279 // delegate method, and we can't delete the RVH out from under itself. | 281 // delegate method, and we can't delete the RVH out from under itself. |
280 base::MessageLoop::current()->PostNonNestableTask( | 282 base::MessageLoop::current()->PostNonNestableTask( |
281 FROM_HERE, | 283 FROM_HERE, |
282 base::Bind(&InterstitialPageImpl::Shutdown, | 284 base::Bind(&InterstitialPageImpl::Shutdown, |
283 weak_ptr_factory_.GetWeakPtr(), | 285 weak_ptr_factory_.GetWeakPtr(), |
284 render_view_host_)); | 286 render_view_host_)); |
285 render_view_host_ = NULL; | 287 render_view_host_ = NULL; |
286 frame_tree_.SwapMainFrame(NULL); | 288 //frame_tree_.SwapMainFrame(NULL); |
287 controller_->delegate()->DetachInterstitialPage(); | 289 controller_->delegate()->DetachInterstitialPage(); |
288 // Let's revert to the original title if necessary. | 290 // Let's revert to the original title if necessary. |
289 NavigationEntry* entry = controller_->GetVisibleEntry(); | 291 NavigationEntry* entry = controller_->GetVisibleEntry(); |
290 if (!new_navigation_ && should_revert_web_contents_title_) { | 292 if (!new_navigation_ && should_revert_web_contents_title_) { |
291 entry->SetTitle(original_web_contents_title_); | 293 entry->SetTitle(original_web_contents_title_); |
292 controller_->delegate()->NotifyNavigationStateChanged( | 294 controller_->delegate()->NotifyNavigationStateChanged( |
293 INVALIDATE_TYPE_TITLE); | 295 INVALIDATE_TYPE_TITLE); |
294 } | 296 } |
295 | 297 |
296 InterstitialPageMap::iterator iter = | 298 InterstitialPageMap::iterator iter = |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 | 836 |
835 web_contents->GetDelegateView()->TakeFocus(reverse); | 837 web_contents->GetDelegateView()->TakeFocus(reverse); |
836 } | 838 } |
837 | 839 |
838 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( | 840 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( |
839 int request_id, int number_of_matches, const gfx::Rect& selection_rect, | 841 int request_id, int number_of_matches, const gfx::Rect& selection_rect, |
840 int active_match_ordinal, bool final_update) { | 842 int active_match_ordinal, bool final_update) { |
841 } | 843 } |
842 | 844 |
843 } // namespace content | 845 } // namespace content |
OLD | NEW |