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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 // Check if this is a singleton tab that already exists | 585 // Check if this is a singleton tab that already exists |
586 int singleton_index = chrome::GetIndexOfSingletonTab(params); | 586 int singleton_index = chrome::GetIndexOfSingletonTab(params); |
587 | 587 |
588 // Did we use a prerender? | 588 // Did we use a prerender? |
589 bool swapped_in_prerender = false; | 589 bool swapped_in_prerender = false; |
590 | 590 |
591 // If no target WebContents was specified, we need to construct one if | 591 // If no target WebContents was specified, we need to construct one if |
592 // we are supposed to target a new tab; unless it's a singleton that already | 592 // we are supposed to target a new tab; unless it's a singleton that already |
593 // exists. | 593 // exists. |
594 if (!params->target_contents && singleton_index < 0) { | 594 if (!params->target_contents && singleton_index < 0) { |
595 GURL url; | 595 DCHECK(!params->url.is_empty()); |
596 if (params->url.is_empty()) { | |
597 url = params->browser->profile()->GetHomePage(); | |
598 params->transition = content::PageTransitionFromInt( | |
599 params->transition | content::PAGE_TRANSITION_HOME_PAGE); | |
600 } else { | |
601 url = params->url; | |
602 } | |
603 | |
604 if (params->disposition != CURRENT_TAB) { | 596 if (params->disposition != CURRENT_TAB) { |
605 params->target_contents = CreateTargetContents(*params, url); | 597 params->target_contents = CreateTargetContents(*params, params->url); |
606 | 598 |
607 // This function takes ownership of |params->target_contents| until it | 599 // This function takes ownership of |params->target_contents| until it |
608 // is added to a TabStripModel. | 600 // is added to a TabStripModel. |
609 target_contents_owner.TakeOwnership(); | 601 target_contents_owner.TakeOwnership(); |
610 } else { | 602 } else { |
611 // ... otherwise if we're loading in the current tab, the target is the | 603 // ... otherwise if we're loading in the current tab, the target is the |
612 // same as the source. | 604 // same as the source. |
613 DCHECK(params->source_contents); | 605 DCHECK(params->source_contents); |
614 params->target_contents = params->source_contents; | 606 params->target_contents = params->source_contents; |
615 } | 607 } |
616 | 608 |
617 // Note: at this point, if |params->disposition| is not CURRENT_TAB, | 609 // Note: at this point, if |params->disposition| is not CURRENT_TAB, |
618 // |params->target_contents| has not been attached to a Browser yet. (That | 610 // |params->target_contents| has not been attached to a Browser yet. (That |
619 // happens later in this function.) However, in that case, the | 611 // happens later in this function.) However, in that case, the |
620 // sessionStorage namespace could not match, so prerender will use the | 612 // sessionStorage namespace could not match, so prerender will use the |
621 // asynchronous codepath and still swap. | 613 // asynchronous codepath and still swap. |
622 DCHECK(params->target_contents); | 614 DCHECK(params->target_contents); |
623 swapped_in_prerender = SwapInPrerender(url, params); | 615 swapped_in_prerender = SwapInPrerender(params->url, params); |
624 | 616 |
625 if (user_initiated) | 617 if (user_initiated) |
626 params->target_contents->UserGestureDone(); | 618 params->target_contents->UserGestureDone(); |
627 | 619 |
628 if (!swapped_in_prerender) { | 620 if (!swapped_in_prerender) { |
629 // Try to handle non-navigational URLs that popup dialogs and such, these | 621 // Try to handle non-navigational URLs that popup dialogs and such, these |
630 // should not actually navigate. | 622 // should not actually navigate. |
631 if (!HandleNonNavigationAboutURL(url)) { | 623 if (!HandleNonNavigationAboutURL(params->url)) { |
632 // Perform the actual navigation, tracking whether it came from the | 624 // Perform the actual navigation, tracking whether it came from the |
633 // renderer. | 625 // renderer. |
634 | 626 |
635 LoadURLInContents(params->target_contents, url, params); | 627 LoadURLInContents(params->target_contents, params->url, params); |
636 // For prerender bookkeeping purposes, record that this pending navigate | 628 // For prerender bookkeeping purposes, record that this pending navigate |
637 // originated from chrome::Navigate. | 629 // originated from chrome::Navigate. |
638 content::NavigationEntry* entry = | 630 content::NavigationEntry* entry = |
639 params->target_contents->GetController().GetPendingEntry(); | 631 params->target_contents->GetController().GetPendingEntry(); |
640 if (entry) | 632 if (entry) |
641 entry->SetExtraData(prerender::kChromeNavigateExtraDataKey, | 633 entry->SetExtraData(prerender::kChromeNavigateExtraDataKey, |
642 base::string16()); | 634 base::string16()); |
643 } | 635 } |
644 } | 636 } |
645 } else { | 637 } else { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 bool reverse_on_redirect = false; | 750 bool reverse_on_redirect = false; |
759 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 751 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
760 &rewritten_url, browser_context, &reverse_on_redirect); | 752 &rewritten_url, browser_context, &reverse_on_redirect); |
761 | 753 |
762 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 754 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
763 return !(rewritten_url.scheme() == content::kChromeUIScheme && | 755 return !(rewritten_url.scheme() == content::kChromeUIScheme && |
764 rewritten_url.host() == chrome::kChromeUIUberHost); | 756 rewritten_url.host() == chrome::kChromeUIUberHost); |
765 } | 757 } |
766 | 758 |
767 } // namespace chrome | 759 } // namespace chrome |
OLD | NEW |