| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 } | 406 } |
| 407 | 407 |
| 408 void InterstitialPageImpl::RenderFrameCreated( | 408 void InterstitialPageImpl::RenderFrameCreated( |
| 409 RenderFrameHost* render_frame_host) { | 409 RenderFrameHost* render_frame_host) { |
| 410 // Note this is only for subframes in the interstitial, the notification for | 410 // Note this is only for subframes in the interstitial, the notification for |
| 411 // the main frame happens in RenderViewCreated. | 411 // the main frame happens in RenderViewCreated. |
| 412 controller_->delegate()->RenderFrameForInterstitialPageCreated( | 412 controller_->delegate()->RenderFrameForInterstitialPageCreated( |
| 413 render_frame_host); | 413 render_frame_host); |
| 414 } | 414 } |
| 415 | 415 |
| 416 void InterstitialPageImpl::UpdateTitle( |
| 417 RenderFrameHost* render_frame_host, |
| 418 int32 page_id, |
| 419 const base::string16& title, |
| 420 base::i18n::TextDirection title_direction) { |
| 421 if (!enabled()) |
| 422 return; |
| 423 |
| 424 RenderViewHost* render_view_host = render_frame_host->GetRenderViewHost(); |
| 425 DCHECK(render_view_host == render_view_host_); |
| 426 NavigationEntry* entry = controller_->GetVisibleEntry(); |
| 427 if (!entry) { |
| 428 // Crash reports from the field indicate this can be NULL. |
| 429 // This is unexpected as InterstitialPages constructed with the |
| 430 // new_navigation flag set to true create a transient navigation entry |
| 431 // (that is returned as the active entry). And the only case so far of |
| 432 // interstitial created with that flag set to false is with the |
| 433 // SafeBrowsingBlockingPage, when the resource triggering the interstitial |
| 434 // is a sub-resource, meaning the main page has already been loaded and a |
| 435 // navigation entry should have been created. |
| 436 NOTREACHED(); |
| 437 return; |
| 438 } |
| 439 |
| 440 // If this interstitial is shown on an existing navigation entry, we'll need |
| 441 // to remember its title so we can revert to it when hidden. |
| 442 if (!new_navigation_ && !should_revert_web_contents_title_) { |
| 443 original_web_contents_title_ = entry->GetTitle(); |
| 444 should_revert_web_contents_title_ = true; |
| 445 } |
| 446 // TODO(evan): make use of title_direction. |
| 447 // http://code.google.com/p/chromium/issues/detail?id=27094 |
| 448 entry->SetTitle(title); |
| 449 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); |
| 450 } |
| 451 |
| 416 RenderViewHostDelegateView* InterstitialPageImpl::GetDelegateView() { | 452 RenderViewHostDelegateView* InterstitialPageImpl::GetDelegateView() { |
| 417 return rvh_delegate_view_.get(); | 453 return rvh_delegate_view_.get(); |
| 418 } | 454 } |
| 419 | 455 |
| 420 const GURL& InterstitialPageImpl::GetMainFrameLastCommittedURL() const { | 456 const GURL& InterstitialPageImpl::GetMainFrameLastCommittedURL() const { |
| 421 return url_; | 457 return url_; |
| 422 } | 458 } |
| 423 | 459 |
| 424 void InterstitialPageImpl::RenderViewTerminated( | 460 void InterstitialPageImpl::RenderViewTerminated( |
| 425 RenderViewHost* render_view_host, | 461 RenderViewHost* render_view_host, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 // Notify the tab we are not loading so the throbber is stopped. It also | 506 // Notify the tab we are not loading so the throbber is stopped. It also |
| 471 // causes a WebContentsObserver::DidStopLoading callback that the | 507 // causes a WebContentsObserver::DidStopLoading callback that the |
| 472 // AutomationProvider (used by the UI tests) expects to consider a navigation | 508 // AutomationProvider (used by the UI tests) expects to consider a navigation |
| 473 // as complete. Without this, navigating in a UI test to a URL that triggers | 509 // as complete. Without this, navigating in a UI test to a URL that triggers |
| 474 // an interstitial would hang. | 510 // an interstitial would hang. |
| 475 web_contents_was_loading_ = controller_->delegate()->IsLoading(); | 511 web_contents_was_loading_ = controller_->delegate()->IsLoading(); |
| 476 controller_->delegate()->SetIsLoading( | 512 controller_->delegate()->SetIsLoading( |
| 477 controller_->delegate()->GetRenderViewHost(), false, true, NULL); | 513 controller_->delegate()->GetRenderViewHost(), false, true, NULL); |
| 478 } | 514 } |
| 479 | 515 |
| 480 void InterstitialPageImpl::UpdateTitle( | |
| 481 RenderViewHost* render_view_host, | |
| 482 int32 page_id, | |
| 483 const base::string16& title, | |
| 484 base::i18n::TextDirection title_direction) { | |
| 485 if (!enabled()) | |
| 486 return; | |
| 487 | |
| 488 DCHECK(render_view_host == render_view_host_); | |
| 489 NavigationEntry* entry = controller_->GetVisibleEntry(); | |
| 490 if (!entry) { | |
| 491 // Crash reports from the field indicate this can be NULL. | |
| 492 // This is unexpected as InterstitialPages constructed with the | |
| 493 // new_navigation flag set to true create a transient navigation entry | |
| 494 // (that is returned as the active entry). And the only case so far of | |
| 495 // interstitial created with that flag set to false is with the | |
| 496 // SafeBrowsingBlockingPage, when the resource triggering the interstitial | |
| 497 // is a sub-resource, meaning the main page has already been loaded and a | |
| 498 // navigation entry should have been created. | |
| 499 NOTREACHED(); | |
| 500 return; | |
| 501 } | |
| 502 | |
| 503 // If this interstitial is shown on an existing navigation entry, we'll need | |
| 504 // to remember its title so we can revert to it when hidden. | |
| 505 if (!new_navigation_ && !should_revert_web_contents_title_) { | |
| 506 original_web_contents_title_ = entry->GetTitle(); | |
| 507 should_revert_web_contents_title_ = true; | |
| 508 } | |
| 509 // TODO(evan): make use of title_direction. | |
| 510 // http://code.google.com/p/chromium/issues/detail?id=27094 | |
| 511 entry->SetTitle(title); | |
| 512 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); | |
| 513 } | |
| 514 | |
| 515 RendererPreferences InterstitialPageImpl::GetRendererPrefs( | 516 RendererPreferences InterstitialPageImpl::GetRendererPrefs( |
| 516 BrowserContext* browser_context) const { | 517 BrowserContext* browser_context) const { |
| 517 delegate_->OverrideRendererPrefs(&renderer_preferences_); | 518 delegate_->OverrideRendererPrefs(&renderer_preferences_); |
| 518 return renderer_preferences_; | 519 return renderer_preferences_; |
| 519 } | 520 } |
| 520 | 521 |
| 521 WebPreferences InterstitialPageImpl::GetWebkitPrefs() { | 522 WebPreferences InterstitialPageImpl::GetWebkitPrefs() { |
| 522 if (!enabled()) | 523 if (!enabled()) |
| 523 return WebPreferences(); | 524 return WebPreferences(); |
| 524 | 525 |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 | 915 |
| 915 web_contents->GetDelegateView()->TakeFocus(reverse); | 916 web_contents->GetDelegateView()->TakeFocus(reverse); |
| 916 } | 917 } |
| 917 | 918 |
| 918 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( | 919 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( |
| 919 int request_id, int number_of_matches, const gfx::Rect& selection_rect, | 920 int request_id, int number_of_matches, const gfx::Rect& selection_rect, |
| 920 int active_match_ordinal, bool final_update) { | 921 int active_match_ordinal, bool final_update) { |
| 921 } | 922 } |
| 922 | 923 |
| 923 } // namespace content | 924 } // namespace content |
| OLD | NEW |