| 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 #include "content/browser/tab_contents/interstitial_page.h" | 5 #include "content/browser/tab_contents/interstitial_page.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" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "content/browser/renderer_host/render_process_host_impl.h" | 15 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 16 #include "content/browser/renderer_host/render_view_host.h" | 16 #include "content/browser/renderer_host/render_view_host.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_view.h" | 17 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 18 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 18 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 19 #include "content/browser/site_instance_impl.h" | 19 #include "content/browser/site_instance_impl.h" |
| 20 #include "content/browser/tab_contents/navigation_controller_impl.h" | 20 #include "content/browser/tab_contents/navigation_controller_impl.h" |
| 21 #include "content/browser/tab_contents/navigation_entry_impl.h" | 21 #include "content/browser/tab_contents/navigation_entry_impl.h" |
| 22 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
| 23 #include "content/common/dom_storage_common.h" | 23 #include "content/common/dom_storage_common.h" |
| 24 #include "content/common/view_messages.h" | 24 #include "content/common/view_messages.h" |
| 25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/dom_operation_notification_details.h" | 26 #include "content/public/browser/dom_operation_notification_details.h" |
| 27 #include "content/public/browser/interstitial_page_delegate.h" |
| 27 #include "content/public/browser/invalidate_type.h" | 28 #include "content/public/browser/invalidate_type.h" |
| 28 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/browser/web_contents_view.h" | 31 #include "content/public/browser/web_contents_view.h" |
| 31 #include "content/public/common/bindings_policy.h" | 32 #include "content/public/common/bindings_policy.h" |
| 32 #include "content/public/common/page_transition_types.h" | 33 #include "content/public/common/page_transition_types.h" |
| 33 #include "content/public/common/view_type.h" | 34 #include "content/public/common/view_type.h" |
| 34 #include "net/base/escape.h" | 35 #include "net/base/escape.h" |
| 35 #include "net/url_request/url_request_context_getter.h" | 36 #include "net/url_request/url_request_context_getter.h" |
| 36 | 37 |
| 37 using content::BrowserThread; | 38 using content::BrowserThread; |
| 38 using content::DomOperationNotificationDetails; | 39 using content::DomOperationNotificationDetails; |
| 40 using content::InterstitialPageDelegate; |
| 39 using content::NavigationController; | 41 using content::NavigationController; |
| 40 using content::NavigationEntry; | 42 using content::NavigationEntry; |
| 41 using content::NavigationEntryImpl; | 43 using content::NavigationEntryImpl; |
| 42 using content::RenderViewHostDelegate; | 44 using content::RenderViewHostDelegate; |
| 43 using content::SiteInstance; | 45 using content::SiteInstance; |
| 44 using content::WebContents; | 46 using content::WebContents; |
| 45 using content::WebContentsView; | 47 using content::WebContentsView; |
| 46 using WebKit::WebDragOperation; | 48 using WebKit::WebDragOperation; |
| 47 using WebKit::WebDragOperationsMask; | 49 using WebKit::WebDragOperationsMask; |
| 48 | 50 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 const gfx::Rect& selection_rect, | 112 const gfx::Rect& selection_rect, |
| 111 int active_match_ordinal, | 113 int active_match_ordinal, |
| 112 bool final_update); | 114 bool final_update); |
| 113 | 115 |
| 114 private: | 116 private: |
| 115 InterstitialPage* interstitial_page_; | 117 InterstitialPage* interstitial_page_; |
| 116 | 118 |
| 117 DISALLOW_COPY_AND_ASSIGN(InterstitialPageRVHViewDelegate); | 119 DISALLOW_COPY_AND_ASSIGN(InterstitialPageRVHViewDelegate); |
| 118 }; | 120 }; |
| 119 | 121 |
| 122 InterstitialPage* InterstitialPage::Create(WebContents* tab, |
| 123 bool new_navigation, |
| 124 const GURL& url, |
| 125 InterstitialPageDelegate* delegate) { |
| 126 return new InterstitialPage(tab, new_navigation, url, delegate); |
| 127 } |
| 128 |
| 120 // static | 129 // static |
| 121 InterstitialPage::InterstitialPageMap* | 130 InterstitialPage::InterstitialPageMap* |
| 122 InterstitialPage::tab_to_interstitial_page_ = NULL; | 131 InterstitialPage::tab_to_interstitial_page_ = NULL; |
| 123 | 132 |
| 124 InterstitialPage::InterstitialPage(WebContents* tab, | 133 InterstitialPage::InterstitialPage(WebContents* tab, |
| 125 bool new_navigation, | 134 bool new_navigation, |
| 126 const GURL& url) | 135 const GURL& url, |
| 136 InterstitialPageDelegate* delegate) |
| 127 : tab_(static_cast<TabContents*>(tab)), | 137 : tab_(static_cast<TabContents*>(tab)), |
| 128 url_(url), | 138 url_(url), |
| 129 new_navigation_(new_navigation), | 139 new_navigation_(new_navigation), |
| 130 should_discard_pending_nav_entry_(new_navigation), | 140 should_discard_pending_nav_entry_(new_navigation), |
| 131 reload_on_dont_proceed_(false), | 141 reload_on_dont_proceed_(false), |
| 132 enabled_(true), | 142 enabled_(true), |
| 133 action_taken_(NO_ACTION), | 143 action_taken_(NO_ACTION), |
| 134 render_view_host_(NULL), | 144 render_view_host_(NULL), |
| 135 original_child_id_(tab->GetRenderProcessHost()->GetID()), | 145 original_child_id_(tab->GetRenderProcessHost()->GetID()), |
| 136 original_rvh_id_(tab->GetRenderViewHost()->routing_id()), | 146 original_rvh_id_(tab->GetRenderViewHost()->routing_id()), |
| 137 should_revert_tab_title_(false), | 147 should_revert_tab_title_(false), |
| 138 tab_was_loading_(false), | 148 tab_was_loading_(false), |
| 139 resource_dispatcher_host_notified_(false), | 149 resource_dispatcher_host_notified_(false), |
| 140 ALLOW_THIS_IN_INITIALIZER_LIST(rvh_view_delegate_( | 150 ALLOW_THIS_IN_INITIALIZER_LIST(rvh_view_delegate_( |
| 141 new InterstitialPageRVHViewDelegate(this))) { | 151 new InterstitialPageRVHViewDelegate(this))), |
| 152 create_view_(true), |
| 153 delegate_(delegate) { |
| 142 InitInterstitialPageMap(); | 154 InitInterstitialPageMap(); |
| 143 // It would be inconsistent to create an interstitial with no new navigation | 155 // It would be inconsistent to create an interstitial with no new navigation |
| 144 // (which is the case when the interstitial was triggered by a sub-resource on | 156 // (which is the case when the interstitial was triggered by a sub-resource on |
| 145 // a page) when we have a pending entry (in the process of loading a new top | 157 // a page) when we have a pending entry (in the process of loading a new top |
| 146 // frame). | 158 // frame). |
| 147 DCHECK(new_navigation || !tab->GetController().GetPendingEntry()); | 159 DCHECK(new_navigation || !tab->GetController().GetPendingEntry()); |
| 148 } | 160 } |
| 149 | 161 |
| 150 InterstitialPage::~InterstitialPage() { | 162 InterstitialPage::~InterstitialPage() { |
| 151 InterstitialPageMap::iterator iter = tab_to_interstitial_page_->find(tab_); | |
| 152 DCHECK(iter != tab_to_interstitial_page_->end()); | |
| 153 if (iter != tab_to_interstitial_page_->end()) | |
| 154 tab_to_interstitial_page_->erase(iter); | |
| 155 DCHECK(!render_view_host_); | |
| 156 } | 163 } |
| 157 | 164 |
| 158 void InterstitialPage::Show() { | 165 void InterstitialPage::Show() { |
| 159 // If an interstitial is already showing or about to be shown, close it before | 166 // If an interstitial is already showing or about to be shown, close it before |
| 160 // showing the new one. | 167 // showing the new one. |
| 161 // Be careful not to take an action on the old interstitial more than once. | 168 // Be careful not to take an action on the old interstitial more than once. |
| 162 InterstitialPageMap::const_iterator iter = | 169 InterstitialPageMap::const_iterator iter = |
| 163 tab_to_interstitial_page_->find(tab_); | 170 tab_to_interstitial_page_->find(tab_); |
| 164 if (iter != tab_to_interstitial_page_->end()) { | 171 if (iter != tab_to_interstitial_page_->end()) { |
| 165 InterstitialPage* interstitial = iter->second; | 172 InterstitialPage* interstitial = iter->second; |
| 166 if (interstitial->action_taken_ != NO_ACTION) { | 173 if (interstitial->action_taken_ != NO_ACTION) { |
| 167 interstitial->Hide(); | 174 interstitial->Hide(); |
| 175 delete interstitial; |
| 168 } else { | 176 } else { |
| 169 // If we are currently showing an interstitial page for which we created | 177 // If we are currently showing an interstitial page for which we created |
| 170 // a transient entry and a new interstitial is shown as the result of a | 178 // a transient entry and a new interstitial is shown as the result of a |
| 171 // new browser initiated navigation, then that transient entry has already | 179 // new browser initiated navigation, then that transient entry has already |
| 172 // been discarded and a new pending navigation entry created. | 180 // been discarded and a new pending navigation entry created. |
| 173 // So we should not discard that new pending navigation entry. | 181 // So we should not discard that new pending navigation entry. |
| 174 // See http://crbug.com/9791 | 182 // See http://crbug.com/9791 |
| 175 if (new_navigation_ && interstitial->new_navigation_) | 183 if (new_navigation_ && interstitial->new_navigation_) |
| 176 interstitial->should_discard_pending_nav_entry_= false; | 184 interstitial->should_discard_pending_nav_entry_= false; |
| 177 interstitial->DontProceed(); | 185 interstitial->DontProceed(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 192 iter = tab_to_interstitial_page_->find(tab_); | 200 iter = tab_to_interstitial_page_->find(tab_); |
| 193 DCHECK(iter == tab_to_interstitial_page_->end()); | 201 DCHECK(iter == tab_to_interstitial_page_->end()); |
| 194 (*tab_to_interstitial_page_)[tab_] = this; | 202 (*tab_to_interstitial_page_)[tab_] = this; |
| 195 | 203 |
| 196 if (new_navigation_) { | 204 if (new_navigation_) { |
| 197 NavigationEntryImpl* entry = new NavigationEntryImpl; | 205 NavigationEntryImpl* entry = new NavigationEntryImpl; |
| 198 entry->SetURL(url_); | 206 entry->SetURL(url_); |
| 199 entry->SetVirtualURL(url_); | 207 entry->SetVirtualURL(url_); |
| 200 entry->set_page_type(content::PAGE_TYPE_INTERSTITIAL); | 208 entry->set_page_type(content::PAGE_TYPE_INTERSTITIAL); |
| 201 | 209 |
| 202 // Give sub-classes a chance to set some states on the navigation entry. | 210 // Give delegates a chance to set some states on the navigation entry. |
| 203 UpdateEntry(entry); | 211 delegate_->OverrideEntry(entry); |
| 204 | 212 |
| 205 tab_->GetControllerImpl().AddTransientEntry(entry); | 213 tab_->GetControllerImpl().AddTransientEntry(entry); |
| 206 } | 214 } |
| 207 | 215 |
| 208 DCHECK(!render_view_host_); | 216 DCHECK(!render_view_host_); |
| 209 render_view_host_ = CreateRenderViewHost(); | 217 render_view_host_ = CreateRenderViewHost(); |
| 210 CreateWebContentsView(); | 218 CreateWebContentsView(); |
| 211 | 219 |
| 212 std::string data_url = "data:text/html;charset=utf-8," + | 220 std::string data_url = "data:text/html;charset=utf-8," + |
| 213 net::EscapePath(GetHTMLContents()); | 221 net::EscapePath(delegate_->GetHTMLContents()); |
| 214 render_view_host_->NavigateToURL(GURL(data_url)); | 222 render_view_host_->NavigateToURL(GURL(data_url)); |
| 215 | 223 |
| 216 notification_registrar_.Add(this, | 224 notification_registrar_.Add(this, |
| 217 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 225 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 218 content::Source<WebContents>(tab_)); | 226 content::Source<WebContents>(tab_)); |
| 219 notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 227 notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 220 content::Source<NavigationController>(&tab_->GetController())); | 228 content::Source<NavigationController>(&tab_->GetController())); |
| 221 notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 229 notification_registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
| 222 content::Source<NavigationController>(&tab_->GetController())); | 230 content::Source<NavigationController>(&tab_->GetController())); |
| 223 notification_registrar_.Add( | 231 notification_registrar_.Add( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 253 if (!new_navigation_ && should_revert_tab_title_) { | 261 if (!new_navigation_ && should_revert_tab_title_) { |
| 254 entry->SetTitle(original_tab_title_); | 262 entry->SetTitle(original_tab_title_); |
| 255 tab_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); | 263 tab_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); |
| 256 } | 264 } |
| 257 | 265 |
| 258 content::NotificationService::current()->Notify( | 266 content::NotificationService::current()->Notify( |
| 259 content::NOTIFICATION_INTERSTITIAL_DETACHED, | 267 content::NOTIFICATION_INTERSTITIAL_DETACHED, |
| 260 content::Source<WebContents>(tab_), | 268 content::Source<WebContents>(tab_), |
| 261 content::NotificationService::NoDetails()); | 269 content::NotificationService::NoDetails()); |
| 262 | 270 |
| 263 delete this; | 271 InterstitialPageMap::iterator iter = tab_to_interstitial_page_->find(tab_); |
| 272 DCHECK(iter != tab_to_interstitial_page_->end()); |
| 273 if (iter != tab_to_interstitial_page_->end()) |
| 274 tab_to_interstitial_page_->erase(iter); |
| 264 } | 275 } |
| 265 | 276 |
| 266 void InterstitialPage::Observe(int type, | 277 void InterstitialPage::Observe(int type, |
| 267 const content::NotificationSource& source, | 278 const content::NotificationSource& source, |
| 268 const content::NotificationDetails& details) { | 279 const content::NotificationDetails& details) { |
| 269 switch (type) { | 280 switch (type) { |
| 270 case content::NOTIFICATION_NAV_ENTRY_PENDING: | 281 case content::NOTIFICATION_NAV_ENTRY_PENDING: |
| 271 // We are navigating away from the interstitial (the user has typed a URL | 282 // We are navigating away from the interstitial (the user has typed a URL |
| 272 // in the location bar or clicked a bookmark). Make sure clicking on the | 283 // in the location bar or clicked a bookmark). Make sure clicking on the |
| 273 // interstitial will have no effect. Also cancel any blocked requests | 284 // interstitial will have no effect. Also cancel any blocked requests |
| (...skipping 22 matching lines...) Expand all Loading... |
| 296 if (action_taken_ == NO_ACTION) { | 307 if (action_taken_ == NO_ACTION) { |
| 297 // We are navigating away from the interstitial or closing a tab with an | 308 // We are navigating away from the interstitial or closing a tab with an |
| 298 // interstitial. Default to DontProceed(). We don't just call Hide as | 309 // interstitial. Default to DontProceed(). We don't just call Hide as |
| 299 // subclasses will almost certainly override DontProceed to do some work | 310 // subclasses will almost certainly override DontProceed to do some work |
| 300 // (ex: close pending connections). | 311 // (ex: close pending connections). |
| 301 DontProceed(); | 312 DontProceed(); |
| 302 } else { | 313 } else { |
| 303 // User decided to proceed and either the navigation was committed or | 314 // User decided to proceed and either the navigation was committed or |
| 304 // the tab was closed before that. | 315 // the tab was closed before that. |
| 305 Hide(); | 316 Hide(); |
| 306 // WARNING: we are now deleted! | 317 delete this; |
| 307 } | 318 } |
| 308 break; | 319 break; |
| 309 case content::NOTIFICATION_DOM_OPERATION_RESPONSE: | 320 case content::NOTIFICATION_DOM_OPERATION_RESPONSE: |
| 310 if (enabled()) { | 321 if (enabled()) { |
| 311 content::Details<DomOperationNotificationDetails> dom_op_details( | 322 content::Details<DomOperationNotificationDetails> dom_op_details( |
| 312 details); | 323 details); |
| 313 CommandReceived(dom_op_details->json); | 324 delegate_->CommandReceived(dom_op_details->json); |
| 314 } | 325 } |
| 315 break; | 326 break; |
| 316 default: | 327 default: |
| 317 NOTREACHED(); | 328 NOTREACHED(); |
| 318 } | 329 } |
| 319 } | 330 } |
| 320 | 331 |
| 321 RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() { | 332 RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() { |
| 322 return rvh_view_delegate_.get(); | 333 return rvh_view_delegate_.get(); |
| 323 } | 334 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 should_revert_tab_title_ = true; | 420 should_revert_tab_title_ = true; |
| 410 } | 421 } |
| 411 // TODO(evan): make use of title_direction. | 422 // TODO(evan): make use of title_direction. |
| 412 // http://code.google.com/p/chromium/issues/detail?id=27094 | 423 // http://code.google.com/p/chromium/issues/detail?id=27094 |
| 413 entry->SetTitle(title); | 424 entry->SetTitle(title); |
| 414 tab_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); | 425 tab_->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TITLE); |
| 415 } | 426 } |
| 416 | 427 |
| 417 content::RendererPreferences InterstitialPage::GetRendererPrefs( | 428 content::RendererPreferences InterstitialPage::GetRendererPrefs( |
| 418 content::BrowserContext* browser_context) const { | 429 content::BrowserContext* browser_context) const { |
| 430 delegate_->OverrideRendererPrefs(&renderer_preferences_); |
| 419 return renderer_preferences_; | 431 return renderer_preferences_; |
| 420 } | 432 } |
| 421 | 433 |
| 422 WebPreferences InterstitialPage::GetWebkitPrefs() { | 434 WebPreferences InterstitialPage::GetWebkitPrefs() { |
| 423 return tab_->GetWebkitPrefs(render_view_host(), url_); | 435 return tab_->GetWebkitPrefs(render_view_host(), url_); |
| 424 } | 436 } |
| 425 | 437 |
| 426 bool InterstitialPage::PreHandleKeyboardEvent( | 438 bool InterstitialPage::PreHandleKeyboardEvent( |
| 427 const NativeWebKeyboardEvent& event, | 439 const NativeWebKeyboardEvent& event, |
| 428 bool* is_keyboard_shortcut) { | 440 bool* is_keyboard_shortcut) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 439 } | 451 } |
| 440 | 452 |
| 441 RenderViewHost* InterstitialPage::CreateRenderViewHost() { | 453 RenderViewHost* InterstitialPage::CreateRenderViewHost() { |
| 442 RenderViewHost* render_view_host = new RenderViewHost( | 454 RenderViewHost* render_view_host = new RenderViewHost( |
| 443 SiteInstance::Create(tab()->GetBrowserContext()), | 455 SiteInstance::Create(tab()->GetBrowserContext()), |
| 444 this, MSG_ROUTING_NONE, kInvalidSessionStorageNamespaceId); | 456 this, MSG_ROUTING_NONE, kInvalidSessionStorageNamespaceId); |
| 445 return render_view_host; | 457 return render_view_host; |
| 446 } | 458 } |
| 447 | 459 |
| 448 WebContentsView* InterstitialPage::CreateWebContentsView() { | 460 WebContentsView* InterstitialPage::CreateWebContentsView() { |
| 461 if (!create_view_) |
| 462 return NULL; |
| 449 WebContentsView* web_contents_view = tab()->GetView(); | 463 WebContentsView* web_contents_view = tab()->GetView(); |
| 450 RenderWidgetHostView* view = | 464 RenderWidgetHostView* view = |
| 451 web_contents_view->CreateViewForWidget(render_view_host_); | 465 web_contents_view->CreateViewForWidget(render_view_host_); |
| 452 render_view_host_->SetView(view); | 466 render_view_host_->SetView(view); |
| 453 render_view_host_->AllowBindings(content::BINDINGS_POLICY_DOM_AUTOMATION); | 467 render_view_host_->AllowBindings(content::BINDINGS_POLICY_DOM_AUTOMATION); |
| 454 | 468 |
| 455 int32 max_page_id = | 469 int32 max_page_id = |
| 456 tab()->GetMaxPageIDForSiteInstance(render_view_host_->site_instance()); | 470 tab()->GetMaxPageIDForSiteInstance(render_view_host_->site_instance()); |
| 457 render_view_host_->CreateRenderView(string16(), max_page_id); | 471 render_view_host_->CreateRenderView(string16(), max_page_id); |
| 458 view->SetSize(web_contents_view->GetContainerSize()); | 472 view->SetSize(web_contents_view->GetContainerSize()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 479 // Since the user wants to proceed, we'll let any blocked request go through. | 493 // Since the user wants to proceed, we'll let any blocked request go through. |
| 480 if (new_navigation_) | 494 if (new_navigation_) |
| 481 TakeActionOnResourceDispatcher(CANCEL); | 495 TakeActionOnResourceDispatcher(CANCEL); |
| 482 else | 496 else |
| 483 TakeActionOnResourceDispatcher(RESUME); | 497 TakeActionOnResourceDispatcher(RESUME); |
| 484 | 498 |
| 485 // No need to hide if we are a new navigation, we'll get hidden when the | 499 // No need to hide if we are a new navigation, we'll get hidden when the |
| 486 // navigation is committed. | 500 // navigation is committed. |
| 487 if (!new_navigation_) { | 501 if (!new_navigation_) { |
| 488 Hide(); | 502 Hide(); |
| 489 // WARNING: we are now deleted! | 503 delegate_->OnProceed(); |
| 504 delete this; |
| 505 return; |
| 490 } | 506 } |
| 491 } | |
| 492 | 507 |
| 493 std::string InterstitialPage::GetHTMLContents() { | 508 delegate_->OnProceed(); |
| 494 return std::string(); | |
| 495 } | 509 } |
| 496 | 510 |
| 497 void InterstitialPage::DontProceed() { | 511 void InterstitialPage::DontProceed() { |
| 498 DCHECK(action_taken_ != DONT_PROCEED_ACTION); | 512 DCHECK(action_taken_ != DONT_PROCEED_ACTION); |
| 499 | 513 |
| 500 Disable(); | 514 Disable(); |
| 501 action_taken_ = DONT_PROCEED_ACTION; | 515 action_taken_ = DONT_PROCEED_ACTION; |
| 502 | 516 |
| 503 // If this is a new navigation, we are returning to the original page, so we | 517 // If this is a new navigation, we are returning to the original page, so we |
| 504 // resume blocked requests for it. If it is not a new navigation, then it | 518 // resume blocked requests for it. If it is not a new navigation, then it |
| (...skipping 10 matching lines...) Expand all Loading... |
| 515 // explicitely. Note that by calling DiscardNonCommittedEntries() we also | 529 // explicitely. Note that by calling DiscardNonCommittedEntries() we also |
| 516 // discard the pending entry, which is what we want, since the navigation is | 530 // discard the pending entry, which is what we want, since the navigation is |
| 517 // cancelled. | 531 // cancelled. |
| 518 tab_->GetController().DiscardNonCommittedEntries(); | 532 tab_->GetController().DiscardNonCommittedEntries(); |
| 519 } | 533 } |
| 520 | 534 |
| 521 if (reload_on_dont_proceed_) | 535 if (reload_on_dont_proceed_) |
| 522 tab_->GetController().Reload(true); | 536 tab_->GetController().Reload(true); |
| 523 | 537 |
| 524 Hide(); | 538 Hide(); |
| 525 // WARNING: we are now deleted! | 539 delegate_->OnDontProceed(); |
| 540 delete this; |
| 526 } | 541 } |
| 527 | 542 |
| 528 void InterstitialPage::CancelForNavigation() { | 543 void InterstitialPage::CancelForNavigation() { |
| 529 // The user is trying to navigate away. We should unblock the renderer and | 544 // The user is trying to navigate away. We should unblock the renderer and |
| 530 // disable the interstitial, but keep it visible until the navigation | 545 // disable the interstitial, but keep it visible until the navigation |
| 531 // completes. | 546 // completes. |
| 532 Disable(); | 547 Disable(); |
| 533 // If this interstitial was shown for a new navigation, allow any navigations | 548 // If this interstitial was shown for a new navigation, allow any navigations |
| 534 // on the original page to resume (e.g., subresource requests, XHRs, etc). | 549 // on the original page to resume (e.g., subresource requests, XHRs, etc). |
| 535 // Otherwise, cancel the pending, possibly dangerous navigations. | 550 // Otherwise, cancel the pending, possibly dangerous navigations. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 553 | 568 |
| 554 void InterstitialPage::Focus() { | 569 void InterstitialPage::Focus() { |
| 555 // Focus the native window. | 570 // Focus the native window. |
| 556 render_view_host_->view()->Focus(); | 571 render_view_host_->view()->Focus(); |
| 557 } | 572 } |
| 558 | 573 |
| 559 void InterstitialPage::FocusThroughTabTraversal(bool reverse) { | 574 void InterstitialPage::FocusThroughTabTraversal(bool reverse) { |
| 560 render_view_host_->SetInitialFocus(reverse); | 575 render_view_host_->SetInitialFocus(reverse); |
| 561 } | 576 } |
| 562 | 577 |
| 578 content::InterstitialPageDelegate* InterstitialPage::GetDelegateForTesting() { |
| 579 return delegate_.get(); |
| 580 } |
| 581 |
| 582 void InterstitialPage::DontCreateViewForTesting() { |
| 583 create_view_ = false; |
| 584 } |
| 585 |
| 563 content::ViewType InterstitialPage::GetRenderViewType() const { | 586 content::ViewType InterstitialPage::GetRenderViewType() const { |
| 564 return content::VIEW_TYPE_INTERSTITIAL_PAGE; | 587 return content::VIEW_TYPE_INTERSTITIAL_PAGE; |
| 565 } | 588 } |
| 566 | 589 |
| 567 gfx::Rect InterstitialPage::GetRootWindowResizerRect() const { | 590 gfx::Rect InterstitialPage::GetRootWindowResizerRect() const { |
| 568 return gfx::Rect(); | 591 return gfx::Rect(); |
| 569 } | 592 } |
| 570 | 593 |
| 571 void InterstitialPage::Disable() { | 594 void InterstitialPage::Disable() { |
| 572 enabled_ = false; | 595 enabled_ = false; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 if (!tab->GetViewDelegate()) | 724 if (!tab->GetViewDelegate()) |
| 702 return; | 725 return; |
| 703 | 726 |
| 704 tab->GetViewDelegate()->TakeFocus(reverse); | 727 tab->GetViewDelegate()->TakeFocus(reverse); |
| 705 } | 728 } |
| 706 | 729 |
| 707 void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( | 730 void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( |
| 708 int request_id, int number_of_matches, const gfx::Rect& selection_rect, | 731 int request_id, int number_of_matches, const gfx::Rect& selection_rect, |
| 709 int active_match_ordinal, bool final_update) { | 732 int active_match_ordinal, bool final_update) { |
| 710 } | 733 } |
| OLD | NEW |