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

Side by Side Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 6288007: Prerendering for redirects -- part 2.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/tab_contents/tab_contents.h" 5 #include "chrome/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 NotificationType::FRAME_PROVISIONAL_LOAD_START, 1628 NotificationType::FRAME_PROVISIONAL_LOAD_START,
1629 Source<NavigationController>(&controller_), 1629 Source<NavigationController>(&controller_),
1630 Details<ProvisionalLoadDetails>(&details)); 1630 Details<ProvisionalLoadDetails>(&details));
1631 if (is_main_frame) { 1631 if (is_main_frame) {
1632 // If we're displaying a network error page do not reset the content 1632 // If we're displaying a network error page do not reset the content
1633 // settings delegate's cookies so the user has a chance to modify cookie 1633 // settings delegate's cookies so the user has a chance to modify cookie
1634 // settings. 1634 // settings.
1635 if (!is_error_page) 1635 if (!is_error_page)
1636 content_settings_delegate_->ClearCookieSpecificContentSettings(); 1636 content_settings_delegate_->ClearCookieSpecificContentSettings();
1637 content_settings_delegate_->ClearGeolocationContentSettings(); 1637 content_settings_delegate_->ClearGeolocationContentSettings();
1638
1639 // Check if the URL we are about to load has been prerendered by any chance,
1640 // and use it if possible.
1641 MaybeUsePreloadedPage(url);
1638 } 1642 }
1639 } 1643 }
1640 1644
1641 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, 1645 void TabContents::OnDidRedirectProvisionalLoad(int32 page_id,
1642 const GURL& source_url, 1646 const GURL& source_url,
1643 const GURL& target_url) { 1647 const GURL& target_url) {
1644 NavigationEntry* entry; 1648 NavigationEntry* entry;
1645 if (page_id == -1) 1649 if (page_id == -1)
1646 entry = controller_.pending_entry(); 1650 entry = controller_.pending_entry();
1647 else 1651 else
1648 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); 1652 entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id);
1649 if (!entry || entry->url() != source_url) 1653 if (!entry || entry->url() != source_url)
1650 return; 1654 return;
1651 entry->set_url(target_url); 1655 entry->set_url(target_url);
1656
1657 // Check if the URL we are about to load has been prerendered by any chance,
1658 // and use it if possible.
1659 MaybeUsePreloadedPage(target_url);
1652 } 1660 }
1653 1661
1654 void TabContents::OnDidFailProvisionalLoadWithError( 1662 void TabContents::OnDidFailProvisionalLoadWithError(
1655 int64 frame_id, 1663 int64 frame_id,
1656 bool is_main_frame, 1664 bool is_main_frame,
1657 int error_code, 1665 int error_code,
1658 const GURL& url, 1666 const GURL& url,
1659 bool showing_repost_interstitial) { 1667 bool showing_repost_interstitial) {
1660 VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec() 1668 VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec()
1661 << ", error_code: " << error_code 1669 << ", error_code: " << error_code
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 Source<TabContents>(this), 2564 Source<TabContents>(this),
2557 Details<RenderViewHost>(rvh)); 2565 Details<RenderViewHost>(rvh));
2558 render_manager_.RenderViewDeleted(rvh); 2566 render_manager_.RenderViewDeleted(rvh);
2559 } 2567 }
2560 2568
2561 void TabContents::DidNavigate(RenderViewHost* rvh, 2569 void TabContents::DidNavigate(RenderViewHost* rvh,
2562 const ViewHostMsg_FrameNavigate_Params& params) { 2570 const ViewHostMsg_FrameNavigate_Params& params) {
2563 int extra_invalidate_flags = 0; 2571 int extra_invalidate_flags = 0;
2564 2572
2565 if (PageTransition::IsMainFrame(params.transition)) { 2573 if (PageTransition::IsMainFrame(params.transition)) {
2566 PrerenderManager* pm = profile()->GetPrerenderManager(); 2574 if (MaybeUsePreloadedPage(params.url)) {
2567 if (pm != NULL) { 2575 return;
2568 if (pm->MaybeUsePreloadedPage(this, params.url)) {
2569 // TODO(tburkard): If the preloaded page has not finished preloading
2570 // yet, we should not do this.
2571 DidStopLoading();
2572 return;
2573 }
2574 } 2576 }
2575 2577
2576 bool was_bookmark_bar_visible = ShouldShowBookmarkBar(); 2578 bool was_bookmark_bar_visible = ShouldShowBookmarkBar();
2577 2579
2578 render_manager_.DidNavigateMainFrame(rvh); 2580 render_manager_.DidNavigateMainFrame(rvh);
2579 2581
2580 if (was_bookmark_bar_visible != ShouldShowBookmarkBar()) 2582 if (was_bookmark_bar_visible != ShouldShowBookmarkBar())
2581 extra_invalidate_flags |= INVALIDATE_BOOKMARK_BAR; 2583 extra_invalidate_flags |= INVALIDATE_BOOKMARK_BAR;
2582 } 2584 }
2583 2585
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
3371 } 3373 }
3372 3374
3373 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) { 3375 void TabContents::SwapInRenderViewHost(RenderViewHost* rvh) {
3374 render_manager_.SwapInRenderViewHost(rvh); 3376 render_manager_.SwapInRenderViewHost(rvh);
3375 } 3377 }
3376 3378
3377 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { 3379 void TabContents::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) {
3378 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); 3380 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
3379 rwh_view->SetSize(view()->GetContainerSize()); 3381 rwh_view->SetSize(view()->GetContainerSize());
3380 } 3382 }
3383
3384 bool TabContents::MaybeUsePreloadedPage(const GURL& url) {
3385 PrerenderManager* pm = profile()->GetPrerenderManager();
3386 if (pm != NULL) {
3387 if (pm->MaybeUsePreloadedPage(this, url)) {
3388 // TODO(tburkard): If the preloaded page has not finished preloading
3389 // yet, we should not do this.
3390 DidStopLoading();
3391 return true;
3392 }
3393 }
3394 return false;
3395 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698