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

Side by Side Diff: chrome/browser/ui/browser_navigator.cc

Issue 9416031: Prerendered pages are swapped in at browser::Navigate time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove TODO Created 8 years, 9 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 (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 "chrome/browser/ui/browser_navigator.h" 5 #include "chrome/browser/ui/browser_navigator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/browser_about_handler.h" 12 #include "chrome/browser/browser_about_handler.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_tab_helper.h" 14 #include "chrome/browser/extensions/extension_tab_helper.h"
15 #include "chrome/browser/google/google_url_tracker.h" 15 #include "chrome/browser/google/google_url_tracker.h"
16 #include "chrome/browser/google/google_util.h" 16 #include "chrome/browser/google/google_util.h"
17 #include "chrome/browser/prefs/incognito_mode_prefs.h" 17 #include "chrome/browser/prefs/incognito_mode_prefs.h"
18 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/prerender/prerender_manager.h"
20 #include "chrome/browser/prerender/prerender_manager_factory.h"
19 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/rlz/rlz.h" 22 #include "chrome/browser/rlz/rlz.h"
21 #include "chrome/browser/tab_contents/tab_util.h" 23 #include "chrome/browser/tab_contents/tab_util.h"
22 #include "chrome/browser/tabs/tab_strip_model.h" 24 #include "chrome/browser/tabs/tab_strip_model.h"
23 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_list.h" 26 #include "chrome/browser/ui/browser_list.h"
25 #include "chrome/browser/ui/browser_window.h" 27 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/omnibox/location_bar.h" 28 #include "chrome/browser/ui/omnibox/location_bar.h"
27 #include "chrome/browser/ui/status_bubble.h" 29 #include "chrome/browser/ui/status_bubble.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 30 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 extra_headers); 354 extra_headers);
353 } 355 }
354 } 356 }
355 } 357 }
356 } 358 }
357 } 359 }
358 #endif 360 #endif
359 #endif 361 #endif
360 } 362 }
361 363
364 // If a prerendered page exists for |url|, replace the page at |target_contents|
365 // with it.
366 bool SwapInPrerender(TabContentsWrapper* target_contents, const GURL& url) {
367 prerender::PrerenderManager* prerender_manager =
368 prerender::PrerenderManagerFactory::GetForProfile(
369 target_contents->profile());
370 if (!prerender_manager)
371 return false;
372 return prerender_manager->MaybeUsePrerenderedPage(
373 target_contents->web_contents(), url);
374 }
375
362 } // namespace 376 } // namespace
363 377
364 namespace browser { 378 namespace browser {
365 379
366 NavigateParams::NavigateParams( 380 NavigateParams::NavigateParams(
367 Browser* a_browser, 381 Browser* a_browser,
368 const GURL& a_url, 382 const GURL& a_url,
369 content::PageTransition a_transition) 383 content::PageTransition a_transition)
370 : url(a_url), 384 : url(a_url),
371 target_contents(NULL), 385 target_contents(NULL),
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 540 }
527 541
528 if (user_initiated) { 542 if (user_initiated) {
529 params->target_contents->web_contents()->GetRenderViewHost()-> 543 params->target_contents->web_contents()->GetRenderViewHost()->
530 delegate()->OnUserGesture(); 544 delegate()->OnUserGesture();
531 } 545 }
532 546
533 InitializeExtraHeaders(params, params->target_contents->profile(), 547 InitializeExtraHeaders(params, params->target_contents->profile(),
534 &extra_headers); 548 &extra_headers);
535 549
550 if (SwapInPrerender(params->target_contents, url))
551 return;
552
536 // Try to handle non-navigational URLs that popup dialogs and such, these 553 // Try to handle non-navigational URLs that popup dialogs and such, these
537 // should not actually navigate. 554 // should not actually navigate.
538 if (!HandleNonNavigationAboutURL(url)) { 555 if (!HandleNonNavigationAboutURL(url)) {
539 // Perform the actual navigation, tracking whether it came from the 556 // Perform the actual navigation, tracking whether it came from the
540 // renderer. 557 // renderer.
541 558
542 LoadURLInContents(params->target_contents->web_contents(), 559 LoadURLInContents(params->target_contents->web_contents(),
543 url, params, extra_headers); 560 url, params, extra_headers);
544 } 561 }
545 } else { 562 } else {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 popup_bounds.height() > max_height || 695 popup_bounds.height() > max_height ||
679 popup_bounds.width() == 0 || 696 popup_bounds.width() == 0 ||
680 popup_bounds.height() == 0) { 697 popup_bounds.height() == 0) {
681 return NEW_FOREGROUND_TAB; 698 return NEW_FOREGROUND_TAB;
682 } 699 }
683 return NEW_POPUP; 700 return NEW_POPUP;
684 } 701 }
685 #endif 702 #endif
686 703
687 } // namespace browser 704 } // namespace browser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698