| OLD | NEW |
| 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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 params->target_contents = CreateTargetContents(*params, url); | 606 params->target_contents = CreateTargetContents(*params, url); |
| 607 | 607 |
| 608 // This function takes ownership of |params->target_contents| until it | 608 // This function takes ownership of |params->target_contents| until it |
| 609 // is added to a TabStripModel. | 609 // is added to a TabStripModel. |
| 610 target_contents_owner.TakeOwnership(); | 610 target_contents_owner.TakeOwnership(); |
| 611 } else { | 611 } else { |
| 612 // ... otherwise if we're loading in the current tab, the target is the | 612 // ... otherwise if we're loading in the current tab, the target is the |
| 613 // same as the source. | 613 // same as the source. |
| 614 DCHECK(params->source_contents); | 614 DCHECK(params->source_contents); |
| 615 params->target_contents = params->source_contents; | 615 params->target_contents = params->source_contents; |
| 616 DCHECK(params->target_contents); | |
| 617 // Prerender expects |params->target_contents| to be attached to a browser | |
| 618 // window, so only call for CURRENT_TAB navigations. (Others are currently | |
| 619 // unsupported because of session storage namespaces anyway.) | |
| 620 // Notice that this includes middle-clicking, since middle clicking | |
| 621 // translates into a chrome::Navigate call with no URL followed by a | |
| 622 // CURRENT_TAB navigation. | |
| 623 // TODO(tburkard): We can actually swap in in non-CURRENT_TAB cases, as | |
| 624 // long as the WebContents we swap into is part of a TabStrip model. | |
| 625 // Therefore, we should swap in regardless of CURRENT_TAB, and instead, | |
| 626 // check in the swapin function whether the WebContents is not in a | |
| 627 // TabStrip model, in which case we must not swap in. | |
| 628 swapped_in_prerender = SwapInPrerender(url, params); | |
| 629 } | 616 } |
| 630 | 617 |
| 618 // Note: at this point, if |params->disposition| is not CURRENT_TAB, |
| 619 // |params->target_contents| has not been attached to a Browser yet. (That |
| 620 // happens later in this function.) However, in that case, the |
| 621 // sessionStorage namespace could not match, so prerender will use the |
| 622 // asynchronous codepath and still swap. |
| 623 DCHECK(params->target_contents); |
| 624 swapped_in_prerender = SwapInPrerender(url, params); |
| 625 |
| 631 if (user_initiated) | 626 if (user_initiated) |
| 632 params->target_contents->UserGestureDone(); | 627 params->target_contents->UserGestureDone(); |
| 633 | 628 |
| 634 if (!swapped_in_prerender) { | 629 if (!swapped_in_prerender) { |
| 635 // Try to handle non-navigational URLs that popup dialogs and such, these | 630 // Try to handle non-navigational URLs that popup dialogs and such, these |
| 636 // should not actually navigate. | 631 // should not actually navigate. |
| 637 if (!HandleNonNavigationAboutURL(url)) { | 632 if (!HandleNonNavigationAboutURL(url)) { |
| 638 // Perform the actual navigation, tracking whether it came from the | 633 // Perform the actual navigation, tracking whether it came from the |
| 639 // renderer. | 634 // renderer. |
| 640 | 635 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 bool reverse_on_redirect = false; | 759 bool reverse_on_redirect = false; |
| 765 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 760 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
| 766 &rewritten_url, browser_context, &reverse_on_redirect); | 761 &rewritten_url, browser_context, &reverse_on_redirect); |
| 767 | 762 |
| 768 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 763 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
| 769 return !(rewritten_url.scheme() == content::kChromeUIScheme && | 764 return !(rewritten_url.scheme() == content::kChromeUIScheme && |
| 770 rewritten_url.host() == chrome::kChromeUIUberHost); | 765 rewritten_url.host() == chrome::kChromeUIUberHost); |
| 771 } | 766 } |
| 772 | 767 |
| 773 } // namespace chrome | 768 } // namespace chrome |
| OLD | NEW |