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

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

Issue 9623018: Prerendered pages are swapped in at browser::Navigate time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 extra_headers); 356 extra_headers);
355 } 357 }
356 } 358 }
357 } 359 }
358 } 360 }
359 } 361 }
360 #endif 362 #endif
361 #endif 363 #endif
362 } 364 }
363 365
366 // If a prerendered page exists for |url|, replace the page at |target_contents|
367 // with it.
368 bool SwapInPrerender(TabContentsWrapper* target_contents, const GURL& url) {
369 prerender::PrerenderManager* prerender_manager =
370 prerender::PrerenderManagerFactory::GetForProfile(
371 target_contents->profile());
372 if (!prerender_manager)
Peter Kasting 2012/03/08 20:56:38 Nit: Shorter: return prerender_manager && prere
373 return false;
374 return prerender_manager->MaybeUsePrerenderedPage(
375 target_contents->web_contents(), url);
376 }
377
364 } // namespace 378 } // namespace
365 379
366 namespace browser { 380 namespace browser {
367 381
368 NavigateParams::NavigateParams( 382 NavigateParams::NavigateParams(
369 Browser* a_browser, 383 Browser* a_browser,
370 const GURL& a_url, 384 const GURL& a_url,
371 content::PageTransition a_transition) 385 content::PageTransition a_transition)
372 : url(a_url), 386 : url(a_url),
373 target_contents(NULL), 387 target_contents(NULL),
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 542 }
529 543
530 if (user_initiated) { 544 if (user_initiated) {
531 params->target_contents->web_contents()->GetRenderViewHost()-> 545 params->target_contents->web_contents()->GetRenderViewHost()->
532 GetDelegate()->OnUserGesture(); 546 GetDelegate()->OnUserGesture();
533 } 547 }
534 548
535 InitializeExtraHeaders(params, params->target_contents->profile(), 549 InitializeExtraHeaders(params, params->target_contents->profile(),
536 &extra_headers); 550 &extra_headers);
537 551
552 if (SwapInPrerender(params->target_contents, url))
553 return;
554
538 // Try to handle non-navigational URLs that popup dialogs and such, these 555 // Try to handle non-navigational URLs that popup dialogs and such, these
539 // should not actually navigate. 556 // should not actually navigate.
540 if (!HandleNonNavigationAboutURL(url)) { 557 if (!HandleNonNavigationAboutURL(url)) {
541 // Perform the actual navigation, tracking whether it came from the 558 // Perform the actual navigation, tracking whether it came from the
542 // renderer. 559 // renderer.
543 560
544 LoadURLInContents(params->target_contents->web_contents(), 561 LoadURLInContents(params->target_contents->web_contents(),
545 url, params, extra_headers); 562 url, params, extra_headers);
546 } 563 }
547 } else { 564 } else {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 popup_bounds.height() > max_height || 697 popup_bounds.height() > max_height ||
681 popup_bounds.width() == 0 || 698 popup_bounds.width() == 0 ||
682 popup_bounds.height() == 0) { 699 popup_bounds.height() == 0) {
683 return NEW_FOREGROUND_TAB; 700 return NEW_FOREGROUND_TAB;
684 } 701 }
685 return NEW_POPUP; 702 return NEW_POPUP;
686 } 703 }
687 #endif 704 #endif
688 705
689 } // namespace browser 706 } // namespace browser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698