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" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/browser_about_handler.h" | 13 #include "chrome/browser/browser_about_handler.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 15 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
16 #include "chrome/browser/prerender/prerender_manager.h" | 16 #include "chrome/browser/prerender/prerender_manager.h" |
17 #include "chrome/browser/prerender/prerender_manager_factory.h" | 17 #include "chrome/browser/prerender/prerender_manager_factory.h" |
18 #include "chrome/browser/prerender/prerender_util.h" | |
19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/tab_contents/tab_util.h" | 19 #include "chrome/browser/tab_contents/tab_util.h" |
21 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
23 #include "chrome/browser/ui/browser_instant_controller.h" | 22 #include "chrome/browser/ui/browser_instant_controller.h" |
24 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/browser/ui/host_desktop.h" | 24 #include "chrome/browser/ui/host_desktop.h" |
26 #include "chrome/browser/ui/location_bar/location_bar.h" | 25 #include "chrome/browser/ui/location_bar/location_bar.h" |
27 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 26 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
28 #include "chrome/browser/ui/singleton_tabs.h" | 27 #include "chrome/browser/ui/singleton_tabs.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 params->target_contents->UserGestureDone(); | 631 params->target_contents->UserGestureDone(); |
633 | 632 |
634 if (!swapped_in_prerender) { | 633 if (!swapped_in_prerender) { |
635 // Try to handle non-navigational URLs that popup dialogs and such, these | 634 // Try to handle non-navigational URLs that popup dialogs and such, these |
636 // should not actually navigate. | 635 // should not actually navigate. |
637 if (!HandleNonNavigationAboutURL(params->url)) { | 636 if (!HandleNonNavigationAboutURL(params->url)) { |
638 // Perform the actual navigation, tracking whether it came from the | 637 // Perform the actual navigation, tracking whether it came from the |
639 // renderer. | 638 // renderer. |
640 | 639 |
641 LoadURLInContents(params->target_contents, params->url, params); | 640 LoadURLInContents(params->target_contents, params->url, params); |
642 // For prerender bookkeeping purposes, record that this pending navigate | |
643 // originated from chrome::Navigate. | |
644 content::NavigationEntry* entry = | |
645 params->target_contents->GetController().GetPendingEntry(); | |
646 if (entry) | |
647 entry->SetExtraData(prerender::kChromeNavigateExtraDataKey, | |
648 base::string16()); | |
649 } | 641 } |
650 } | 642 } |
651 } else { | 643 } else { |
652 // |target_contents| was specified non-NULL, and so we assume it has already | 644 // |target_contents| was specified non-NULL, and so we assume it has already |
653 // been navigated appropriately. We need to do nothing more other than | 645 // been navigated appropriately. We need to do nothing more other than |
654 // add it to the appropriate tabstrip. | 646 // add it to the appropriate tabstrip. |
655 } | 647 } |
656 | 648 |
657 // If the user navigated from the omnibox, and the selected tab is going to | 649 // If the user navigated from the omnibox, and the selected tab is going to |
658 // lose focus, then make sure the focus for the source tab goes away from the | 650 // lose focus, then make sure the focus for the source tab goes away from the |
(...skipping 29 matching lines...) Expand all Loading... |
688 | 680 |
689 if (singleton_index >= 0) { | 681 if (singleton_index >= 0) { |
690 WebContents* target = | 682 WebContents* target = |
691 params->browser->tab_strip_model()->GetWebContentsAt(singleton_index); | 683 params->browser->tab_strip_model()->GetWebContentsAt(singleton_index); |
692 | 684 |
693 if (target->IsCrashed()) { | 685 if (target->IsCrashed()) { |
694 target->GetController().Reload(true); | 686 target->GetController().Reload(true); |
695 } else if (params->path_behavior == NavigateParams::IGNORE_AND_NAVIGATE && | 687 } else if (params->path_behavior == NavigateParams::IGNORE_AND_NAVIGATE && |
696 target->GetURL() != params->url) { | 688 target->GetURL() != params->url) { |
697 LoadURLInContents(target, params->url, params); | 689 LoadURLInContents(target, params->url, params); |
698 // For prerender bookkeeping purposes, record that this pending navigate | |
699 // originated from chrome::Navigate. | |
700 content::NavigationEntry* entry = | |
701 target->GetController().GetPendingEntry(); | |
702 if (entry) | |
703 entry->SetExtraData(prerender::kChromeNavigateExtraDataKey, | |
704 base::string16()); | |
705 } | 690 } |
706 | 691 |
707 // If the singleton tab isn't already selected, select it. | 692 // If the singleton tab isn't already selected, select it. |
708 if (params->source_contents != params->target_contents) { | 693 if (params->source_contents != params->target_contents) { |
709 params->browser->tab_strip_model()->ActivateTabAt(singleton_index, | 694 params->browser->tab_strip_model()->ActivateTabAt(singleton_index, |
710 user_initiated); | 695 user_initiated); |
711 } | 696 } |
712 } | 697 } |
713 | 698 |
714 if (params->disposition != CURRENT_TAB) { | 699 if (params->disposition != CURRENT_TAB) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 bool reverse_on_redirect = false; | 751 bool reverse_on_redirect = false; |
767 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 752 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
768 &rewritten_url, browser_context, &reverse_on_redirect); | 753 &rewritten_url, browser_context, &reverse_on_redirect); |
769 | 754 |
770 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 755 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
771 return !(rewritten_url.scheme() == content::kChromeUIScheme && | 756 return !(rewritten_url.scheme() == content::kChromeUIScheme && |
772 rewritten_url.host() == chrome::kChromeUIUberHost); | 757 rewritten_url.host() == chrome::kChromeUIUberHost); |
773 } | 758 } |
774 | 759 |
775 } // namespace chrome | 760 } // namespace chrome |
OLD | NEW |