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

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: More cleanup Created 8 years, 10 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 bool SwapInPrerender(TabContentsWrapper* target_contents, const GURL& url) {
365 // See if there is a PrerenderManager and swap in then.
366 prerender::PrerenderManager* prerender_manager =
367 prerender::PrerenderManagerFactory::GetForProfile(
368 target_contents->profile());
369 if (!prerender_manager)
370 return false;
371 return prerender_manager->MaybeUsePrerenderedPage(
372 target_contents->web_contents(), url);
373 }
374
362 } // namespace 375 } // namespace
363 376
364 namespace browser { 377 namespace browser {
365 378
366 NavigateParams::NavigateParams( 379 NavigateParams::NavigateParams(
367 Browser* a_browser, 380 Browser* a_browser,
368 const GURL& a_url, 381 const GURL& a_url,
369 content::PageTransition a_transition) 382 content::PageTransition a_transition)
370 : url(a_url), 383 : url(a_url),
371 target_contents(NULL), 384 target_contents(NULL),
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 539 }
527 540
528 if (user_initiated) { 541 if (user_initiated) {
529 params->target_contents->web_contents()->GetRenderViewHost()-> 542 params->target_contents->web_contents()->GetRenderViewHost()->
530 delegate()->OnUserGesture(); 543 delegate()->OnUserGesture();
531 } 544 }
532 545
533 InitializeExtraHeaders(params, params->target_contents->profile(), 546 InitializeExtraHeaders(params, params->target_contents->profile(),
534 &extra_headers); 547 &extra_headers);
535 548
549 if (SwapInPrerender(params->target_contents, url)) {
dominich 2012/02/28 16:21:00 nit: you don't need the {} here.
cbentzel 2012/02/29 18:16:13 Done.
550 return;
551 }
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