Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: content/browser/frame_host/interstitial_page_impl.cc

Issue 274883002: Move didReceiveTitle and related stuff to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 } 395 }
396 396
397 void InterstitialPageImpl::RenderFrameCreated( 397 void InterstitialPageImpl::RenderFrameCreated(
398 RenderFrameHost* render_frame_host) { 398 RenderFrameHost* render_frame_host) {
399 // Note this is only for subframes in the interstitial, the notification for 399 // Note this is only for subframes in the interstitial, the notification for
400 // the main frame happens in RenderViewCreated. 400 // the main frame happens in RenderViewCreated.
401 controller_->delegate()->RenderFrameForInterstitialPageCreated( 401 controller_->delegate()->RenderFrameForInterstitialPageCreated(
402 render_frame_host); 402 render_frame_host);
403 } 403 }
404 404
405 void InterstitialPageImpl::UpdateTitle(
406 RenderFrameHost* render_frame_host,
407 int32 page_id,
408 const base::string16& title,
409 base::i18n::TextDirection title_direction) {
410 if (!enabled())
411 return;
412
413 RenderViewHost* render_view_host = render_frame_host->GetRenderViewHost();
414 DCHECK(render_view_host == render_view_host_);
415 NavigationEntry* entry = controller_->GetVisibleEntry();
416 if (!entry) {
417 // Crash reports from the field indicate this can be NULL.
418 // This is unexpected as InterstitialPages constructed with the
419 // new_navigation flag set to true create a transient navigation entry
420 // (that is returned as the active entry). And the only case so far of
421 // interstitial created with that flag set to false is with the
422 // SafeBrowsingBlockingPage, when the resource triggering the interstitial
423 // is a sub-resource, meaning the main page has already been loaded and a
424 // navigation entry should have been created.
425 NOTREACHED();
426 return;
427 }
428
429 // If this interstitial is shown on an existing navigation entry, we'll need
430 // to remember its title so we can revert to it when hidden.
431 if (!new_navigation_ && !should_revert_web_contents_title_) {
432 original_web_contents_title_ = entry->GetTitle();
433 should_revert_web_contents_title_ = true;
434 }
435 // TODO(evan): make use of title_direction.
436 // http://code.google.com/p/chromium/issues/detail?id=27094
437 entry->SetTitle(title);
438 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE);
439 }
440
405 RenderViewHostDelegateView* InterstitialPageImpl::GetDelegateView() { 441 RenderViewHostDelegateView* InterstitialPageImpl::GetDelegateView() {
406 return rvh_delegate_view_.get(); 442 return rvh_delegate_view_.get();
407 } 443 }
408 444
409 const GURL& InterstitialPageImpl::GetMainFrameLastCommittedURL() const { 445 const GURL& InterstitialPageImpl::GetMainFrameLastCommittedURL() const {
410 return url_; 446 return url_;
411 } 447 }
412 448
413 void InterstitialPageImpl::RenderViewTerminated( 449 void InterstitialPageImpl::RenderViewTerminated(
414 RenderViewHost* render_view_host, 450 RenderViewHost* render_view_host,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // Notify the tab we are not loading so the throbber is stopped. It also 495 // Notify the tab we are not loading so the throbber is stopped. It also
460 // causes a WebContentsObserver::DidStopLoading callback that the 496 // causes a WebContentsObserver::DidStopLoading callback that the
461 // AutomationProvider (used by the UI tests) expects to consider a navigation 497 // AutomationProvider (used by the UI tests) expects to consider a navigation
462 // as complete. Without this, navigating in a UI test to a URL that triggers 498 // as complete. Without this, navigating in a UI test to a URL that triggers
463 // an interstitial would hang. 499 // an interstitial would hang.
464 web_contents_was_loading_ = controller_->delegate()->IsLoading(); 500 web_contents_was_loading_ = controller_->delegate()->IsLoading();
465 controller_->delegate()->SetIsLoading( 501 controller_->delegate()->SetIsLoading(
466 controller_->delegate()->GetRenderViewHost(), false, true, NULL); 502 controller_->delegate()->GetRenderViewHost(), false, true, NULL);
467 } 503 }
468 504
469 void InterstitialPageImpl::UpdateTitle(
470 RenderViewHost* render_view_host,
471 int32 page_id,
472 const base::string16& title,
473 base::i18n::TextDirection title_direction) {
474 if (!enabled())
475 return;
476
477 DCHECK(render_view_host == render_view_host_);
478 NavigationEntry* entry = controller_->GetVisibleEntry();
479 if (!entry) {
480 // Crash reports from the field indicate this can be NULL.
481 // This is unexpected as InterstitialPages constructed with the
482 // new_navigation flag set to true create a transient navigation entry
483 // (that is returned as the active entry). And the only case so far of
484 // interstitial created with that flag set to false is with the
485 // SafeBrowsingBlockingPage, when the resource triggering the interstitial
486 // is a sub-resource, meaning the main page has already been loaded and a
487 // navigation entry should have been created.
488 NOTREACHED();
489 return;
490 }
491
492 // If this interstitial is shown on an existing navigation entry, we'll need
493 // to remember its title so we can revert to it when hidden.
494 if (!new_navigation_ && !should_revert_web_contents_title_) {
495 original_web_contents_title_ = entry->GetTitle();
496 should_revert_web_contents_title_ = true;
497 }
498 // TODO(evan): make use of title_direction.
499 // http://code.google.com/p/chromium/issues/detail?id=27094
500 entry->SetTitle(title);
501 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE);
502 }
503
504 RendererPreferences InterstitialPageImpl::GetRendererPrefs( 505 RendererPreferences InterstitialPageImpl::GetRendererPrefs(
505 BrowserContext* browser_context) const { 506 BrowserContext* browser_context) const {
506 delegate_->OverrideRendererPrefs(&renderer_preferences_); 507 delegate_->OverrideRendererPrefs(&renderer_preferences_);
507 return renderer_preferences_; 508 return renderer_preferences_;
508 } 509 }
509 510
510 WebPreferences InterstitialPageImpl::GetWebkitPrefs() { 511 WebPreferences InterstitialPageImpl::GetWebkitPrefs() {
511 if (!enabled()) 512 if (!enabled())
512 return WebPreferences(); 513 return WebPreferences();
513 514
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 904
904 web_contents->GetDelegateView()->TakeFocus(reverse); 905 web_contents->GetDelegateView()->TakeFocus(reverse);
905 } 906 }
906 907
907 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply( 908 void InterstitialPageImpl::InterstitialPageRVHDelegateView::OnFindReply(
908 int request_id, int number_of_matches, const gfx::Rect& selection_rect, 909 int request_id, int number_of_matches, const gfx::Rect& selection_rect,
909 int active_match_ordinal, bool final_update) { 910 int active_match_ordinal, bool final_update) {
910 } 911 }
911 912
912 } // namespace content 913 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/interstitial_page_impl.h ('k') | content/browser/frame_host/render_frame_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698