[email protected] | c333e79 | 2012-01-06 16:57:39 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 339d6dd | 2010-11-12 00:41:58 | [diff] [blame] | 5 | #include "chrome/browser/ui/browser_navigator.h" |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 6 | |
[email protected] | 07afd7c | 2011-02-17 10:07:11 | [diff] [blame] | 7 | #include <algorithm> |
| 8 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 9 | #include "base/command_line.h" |
[email protected] | 3853a4c | 2013-02-11 17:15:57 | [diff] [blame] | 10 | #include "base/prefs/pref_service.h" |
[email protected] | 1152118 | 2013-06-11 04:06:36 | [diff] [blame] | 11 | #include "base/strings/stringprintf.h" |
[email protected] | 5846d58 | 2013-06-08 16:02:12 | [diff] [blame] | 12 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 2f89b60 | 2011-06-01 05:49:17 | [diff] [blame] | 13 | #include "chrome/browser/browser_about_handler.h" |
[email protected] | dcc8fbc | 2013-07-12 00:54:09 | [diff] [blame] | 14 | #include "chrome/browser/chrome_notification_types.h" |
[email protected] | 93ad8e1c | 2011-11-08 21:34:05 | [diff] [blame] | 15 | #include "chrome/browser/prefs/incognito_mode_prefs.h" |
[email protected] | a0358d7 | 2012-03-09 14:06:50 | [diff] [blame] | 16 | #include "chrome/browser/prerender/prerender_manager.h" |
| 17 | #include "chrome/browser/prerender/prerender_manager_factory.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 18 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 1ab4ddf | 2011-07-21 04:48:04 | [diff] [blame] | 19 | #include "chrome/browser/tab_contents/tab_util.h" |
afakhry | 8394f94 | 2015-07-09 18:46:09 | [diff] [blame] | 20 | #include "chrome/browser/task_management/web_contents_tags.h" |
[email protected] | 7b5dc00 | 2010-11-16 23:08:10 | [diff] [blame] | 21 | #include "chrome/browser/ui/browser.h" |
[email protected] | d874814 | 2012-05-16 21:13:43 | [diff] [blame] | 22 | #include "chrome/browser/ui/browser_finder.h" |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 23 | #include "chrome/browser/ui/browser_instant_controller.h" |
[email protected] | 00070c73 | 2011-04-09 15:31:33 | [diff] [blame] | 24 | #include "chrome/browser/ui/browser_window.h" |
[email protected] | 435d43e0 | 2012-12-09 09:13:55 | [diff] [blame] | 25 | #include "chrome/browser/ui/host_desktop.h" |
[email protected] | d57ce6a | 2014-07-03 15:39:23 | [diff] [blame] | 26 | #include "chrome/browser/ui/location_bar/location_bar.h" |
[email protected] | a155899 | 2013-12-12 20:52:16 | [diff] [blame] | 27 | #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 28 | #include "chrome/browser/ui/singleton_tabs.h" |
[email protected] | 6768ac0 | 2011-04-06 17:41:04 | [diff] [blame] | 29 | #include "chrome/browser/ui/status_bubble.h" |
[email protected] | e0bc75d5 | 2014-01-30 23:42:59 | [diff] [blame] | 30 | #include "chrome/browser/ui/tab_helpers.h" |
[email protected] | b56e2e3 | 2012-05-11 21:18:04 | [diff] [blame] | 31 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
[email protected] | eca25813 | 2010-11-15 23:33:08 | [diff] [blame] | 32 | #include "chrome/common/url_constants.h" |
[email protected] | 825b166 | 2012-03-12 19:07:31 | [diff] [blame] | 33 | #include "content/public/browser/browser_url_handler.h" |
[email protected] | df165e5 | 2013-12-05 00:00:53 | [diff] [blame] | 34 | #include "content/public/browser/navigation_entry.h" |
[email protected] | ad50def5 | 2011-10-19 23:17:07 | [diff] [blame] | 35 | #include "content/public/browser/notification_service.h" |
[email protected] | 9c1662b | 2012-03-06 15:44:33 | [diff] [blame] | 36 | #include "content/public/browser/render_view_host.h" |
[email protected] | 6acde635 | 2012-01-04 16:52:20 | [diff] [blame] | 37 | #include "content/public/browser/web_contents.h" |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 38 | |
[email protected] | ad4c2d3 | 2013-12-06 12:59:26 | [diff] [blame] | 39 | #if defined(USE_ASH) |
| 40 | #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 41 | #endif |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 42 | |
[email protected] | 54944cde | 2012-12-09 09:24:59 | [diff] [blame] | 43 | #if defined(USE_AURA) |
| 44 | #include "ui/aura/window.h" |
| 45 | #endif |
| 46 | |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 47 | #if defined(ENABLE_EXTENSIONS) |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 48 | #include "chrome/browser/extensions/tab_helper.h" |
| 49 | #include "chrome/browser/web_applications/web_app.h" |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 50 | #include "extensions/browser/extension_registry.h" |
| 51 | #include "extensions/common/extension.h" |
| 52 | #include "extensions/common/extension_set.h" |
| 53 | #endif |
| 54 | |
[email protected] | e5d549d | 2011-12-28 01:29:20 | [diff] [blame] | 55 | using content::GlobalRequestID; |
[email protected] | a2efc35d | 2013-08-03 23:17:25 | [diff] [blame] | 56 | using content::NavigationController; |
[email protected] | ea049a0 | 2011-12-25 21:37:09 | [diff] [blame] | 57 | using content::WebContents; |
| 58 | |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 59 | class BrowserNavigatorWebContentsAdoption { |
| 60 | public: |
[email protected] | 27e5b391 | 2012-12-16 00:45:37 | [diff] [blame] | 61 | static void AttachTabHelpers(content::WebContents* contents) { |
[email protected] | e0bc75d5 | 2014-01-30 23:42:59 | [diff] [blame] | 62 | TabHelpers::AttachTabHelpers(contents); |
afakhry | 8394f94 | 2015-07-09 18:46:09 | [diff] [blame] | 63 | |
| 64 | // Make the tab show up in the task manager. |
| 65 | task_management::WebContentsTags::CreateForTabContents(contents); |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 66 | } |
| 67 | }; |
| 68 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 69 | namespace { |
| 70 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 71 | // Returns true if the specified Browser can open tabs. Not all Browsers support |
| 72 | // multiple tabs, such as app frames and popups. This function returns false for |
| 73 | // those types of Browser. |
| 74 | bool WindowCanOpenTabs(Browser* browser) { |
| 75 | return browser->CanSupportWindowFeature(Browser::FEATURE_TABSTRIP) || |
[email protected] | c084925 | 2012-05-12 13:51:27 | [diff] [blame] | 76 | browser->tab_strip_model()->empty(); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | // Finds an existing Browser compatible with |profile|, making a new one if no |
| 80 | // such Browser is located. |
[email protected] | 3b14b7f2 | 2012-10-04 01:29:09 | [diff] [blame] | 81 | Browser* GetOrCreateBrowser(Profile* profile, |
| 82 | chrome::HostDesktopType host_desktop_type) { |
[email protected] | 7507273 | 2013-01-09 13:39:25 | [diff] [blame] | 83 | Browser* browser = chrome::FindTabbedBrowser(profile, false, |
| 84 | host_desktop_type); |
[email protected] | 435d43e0 | 2012-12-09 09:13:55 | [diff] [blame] | 85 | return browser ? browser : new Browser( |
| 86 | Browser::CreateParams(profile, host_desktop_type)); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 87 | } |
| 88 | |
[email protected] | eca25813 | 2010-11-15 23:33:08 | [diff] [blame] | 89 | // Change some of the navigation parameters based on the particular URL. |
[email protected] | fc0ed30 | 2011-11-29 23:17:19 | [diff] [blame] | 90 | // Currently this applies to some chrome:// pages which we always want to open |
| 91 | // in a non-incognito window. Note that even though a ChromeOS guest session is |
| 92 | // technically an incognito window, these URLs are allowed. |
[email protected] | 93ad8e1c | 2011-11-08 21:34:05 | [diff] [blame] | 93 | // Returns true on success. Otherwise, if changing params leads the browser into |
| 94 | // an erroneous state, returns false. |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 95 | bool AdjustNavigateParamsForURL(chrome::NavigateParams* params) { |
[email protected] | fc0ed30 | 2011-11-29 23:17:19 | [diff] [blame] | 96 | if (params->target_contents != NULL || |
[email protected] | 887ab009 | 2012-10-16 08:48:20 | [diff] [blame] | 97 | chrome::IsURLAllowedInIncognito(params->url, |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 98 | params->initiating_profile) || |
[email protected] | 10507b33 | 2012-12-13 22:37:33 | [diff] [blame] | 99 | params->initiating_profile->IsGuestSession()) { |
[email protected] | fc0ed30 | 2011-11-29 23:17:19 | [diff] [blame] | 100 | return true; |
[email protected] | eca25813 | 2010-11-15 23:33:08 | [diff] [blame] | 101 | } |
[email protected] | fc0ed30 | 2011-11-29 23:17:19 | [diff] [blame] | 102 | |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 103 | Profile* profile = params->initiating_profile; |
[email protected] | fc0ed30 | 2011-11-29 23:17:19 | [diff] [blame] | 104 | |
| 105 | if (profile->IsOffTheRecord() || params->disposition == OFF_THE_RECORD) { |
| 106 | profile = profile->GetOriginalProfile(); |
| 107 | |
| 108 | // If incognito is forced, we punt. |
| 109 | PrefService* prefs = profile->GetPrefs(); |
| 110 | if (prefs && IncognitoModePrefs::GetAvailability(prefs) == |
| 111 | IncognitoModePrefs::FORCED) { |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | params->disposition = SINGLETON_TAB; |
[email protected] | 0edcdec | 2013-10-31 06:43:08 | [diff] [blame] | 116 | params->browser = GetOrCreateBrowser(profile, params->host_desktop_type); |
[email protected] | 50592b5 | 2013-05-02 22:26:25 | [diff] [blame] | 117 | params->window_action = chrome::NavigateParams::SHOW_WINDOW; |
[email protected] | fc0ed30 | 2011-11-29 23:17:19 | [diff] [blame] | 118 | } |
| 119 | |
[email protected] | 93ad8e1c | 2011-11-08 21:34:05 | [diff] [blame] | 120 | return true; |
[email protected] | eca25813 | 2010-11-15 23:33:08 | [diff] [blame] | 121 | } |
| 122 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 123 | // Returns a Browser that can host the navigation or tab addition specified in |
| 124 | // |params|. This might just return the same Browser specified in |params|, or |
| 125 | // some other if that Browser is deemed incompatible. |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 126 | Browser* GetBrowserForDisposition(chrome::NavigateParams* params) { |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 127 | // If no source WebContents was specified, we use the selected one from |
[email protected] | 075969d | 2012-04-17 20:05:55 | [diff] [blame] | 128 | // the target browser. This must happen first, before |
| 129 | // GetBrowserForDisposition() has a chance to replace |params->browser| with |
| 130 | // another one. |
[email protected] | 59253a65 | 2012-11-20 00:17:26 | [diff] [blame] | 131 | if (!params->source_contents && params->browser) { |
| 132 | params->source_contents = |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 133 | params->browser->tab_strip_model()->GetActiveWebContents(); |
[email protected] | 59253a65 | 2012-11-20 00:17:26 | [diff] [blame] | 134 | } |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 135 | |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 136 | Profile* profile = params->initiating_profile; |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 137 | |
| 138 | switch (params->disposition) { |
| 139 | case CURRENT_TAB: |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 140 | if (params->browser) |
| 141 | return params->browser; |
| 142 | // Find a compatible window and re-execute this command in it. Otherwise |
| 143 | // re-run with NEW_WINDOW. |
[email protected] | 3b14b7f2 | 2012-10-04 01:29:09 | [diff] [blame] | 144 | return GetOrCreateBrowser(profile, params->host_desktop_type); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 145 | case SINGLETON_TAB: |
| 146 | case NEW_FOREGROUND_TAB: |
| 147 | case NEW_BACKGROUND_TAB: |
| 148 | // See if we can open the tab in the window this navigator is bound to. |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 149 | if (params->browser && WindowCanOpenTabs(params->browser)) |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 150 | return params->browser; |
| 151 | // Find a compatible window and re-execute this command in it. Otherwise |
| 152 | // re-run with NEW_WINDOW. |
[email protected] | 3b14b7f2 | 2012-10-04 01:29:09 | [diff] [blame] | 153 | return GetOrCreateBrowser(profile, params->host_desktop_type); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 154 | case NEW_POPUP: { |
[email protected] | b35b26b3 | 2011-05-05 20:35:14 | [diff] [blame] | 155 | // Make a new popup window. |
[email protected] | d04f59d | 2012-07-13 23:07:52 | [diff] [blame] | 156 | // Coerce app-style if |source| represents an app. |
| 157 | std::string app_name; |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 158 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | d04f59d | 2012-07-13 23:07:52 | [diff] [blame] | 159 | if (!params->extension_app_id.empty()) { |
| 160 | app_name = web_app::GenerateApplicationNameFromExtensionId( |
| 161 | params->extension_app_id); |
[email protected] | 190e5e2 | 2013-07-27 05:59:23 | [diff] [blame] | 162 | } else if (params->browser && !params->browser->app_name().empty()) { |
[email protected] | d04f59d | 2012-07-13 23:07:52 | [diff] [blame] | 163 | app_name = params->browser->app_name(); |
[email protected] | 7381d9f | 2012-09-12 20:26:22 | [diff] [blame] | 164 | } else if (params->source_contents) { |
| 165 | extensions::TabHelper* extensions_tab_helper = |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 166 | extensions::TabHelper::FromWebContents(params->source_contents); |
| 167 | if (extensions_tab_helper && extensions_tab_helper->is_app()) { |
[email protected] | 7381d9f | 2012-09-12 20:26:22 | [diff] [blame] | 168 | app_name = web_app::GenerateApplicationNameFromExtensionId( |
| 169 | extensions_tab_helper->extension_app()->id()); |
| 170 | } |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 171 | } |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 172 | #endif |
[email protected] | d04f59d | 2012-07-13 23:07:52 | [diff] [blame] | 173 | if (app_name.empty()) { |
[email protected] | 435d43e0 | 2012-12-09 09:13:55 | [diff] [blame] | 174 | Browser::CreateParams browser_params( |
| 175 | Browser::TYPE_POPUP, profile, params->host_desktop_type); |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 176 | browser_params.trusted_source = params->trusted_source; |
[email protected] | d04f59d | 2012-07-13 23:07:52 | [diff] [blame] | 177 | browser_params.initial_bounds = params->window_bounds; |
[email protected] | a4fe6701 | 2012-07-25 20:14:29 | [diff] [blame] | 178 | return new Browser(browser_params); |
[email protected] | d04f59d | 2012-07-13 23:07:52 | [diff] [blame] | 179 | } |
| 180 | |
[email protected] | a4fe6701 | 2012-07-25 20:14:29 | [diff] [blame] | 181 | return new Browser(Browser::CreateParams::CreateForApp( |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 182 | app_name, |
| 183 | params->trusted_source, |
| 184 | params->window_bounds, |
| 185 | profile, |
[email protected] | 2b09ae55 | 2013-02-23 06:38:03 | [diff] [blame] | 186 | params->host_desktop_type)); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 187 | } |
[email protected] | d04f59d | 2012-07-13 23:07:52 | [diff] [blame] | 188 | case NEW_WINDOW: { |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 189 | // Make a new normal browser window. |
[email protected] | 435d43e0 | 2012-12-09 09:13:55 | [diff] [blame] | 190 | return new Browser(Browser::CreateParams(profile, |
| 191 | params->host_desktop_type)); |
[email protected] | d04f59d | 2012-07-13 23:07:52 | [diff] [blame] | 192 | } |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 193 | case OFF_THE_RECORD: |
| 194 | // Make or find an incognito window. |
[email protected] | 3b14b7f2 | 2012-10-04 01:29:09 | [diff] [blame] | 195 | return GetOrCreateBrowser(profile->GetOffTheRecordProfile(), |
| 196 | params->host_desktop_type); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 197 | // The following types all result in no navigation. |
| 198 | case SUPPRESS_OPEN: |
| 199 | case SAVE_TO_DISK: |
| 200 | case IGNORE_ACTION: |
| 201 | return NULL; |
| 202 | default: |
| 203 | NOTREACHED(); |
| 204 | } |
| 205 | return NULL; |
| 206 | } |
| 207 | |
| 208 | // Fix disposition and other parameter values depending on prevailing |
| 209 | // conditions. |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 210 | void NormalizeDisposition(chrome::NavigateParams* params) { |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 211 | // Calculate the WindowOpenDisposition if necessary. |
[email protected] | c084925 | 2012-05-12 13:51:27 | [diff] [blame] | 212 | if (params->browser->tab_strip_model()->empty() && |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 213 | (params->disposition == NEW_BACKGROUND_TAB || |
| 214 | params->disposition == CURRENT_TAB || |
| 215 | params->disposition == SINGLETON_TAB)) { |
| 216 | params->disposition = NEW_FOREGROUND_TAB; |
| 217 | } |
| 218 | if (params->browser->profile()->IsOffTheRecord() && |
| 219 | params->disposition == OFF_THE_RECORD) { |
| 220 | params->disposition = NEW_FOREGROUND_TAB; |
| 221 | } |
[email protected] | 688c792c | 2012-02-22 01:09:16 | [diff] [blame] | 222 | if (!params->source_contents && params->disposition == CURRENT_TAB) |
| 223 | params->disposition = NEW_FOREGROUND_TAB; |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 224 | |
[email protected] | 0b17b7d | 2010-11-17 17:39:58 | [diff] [blame] | 225 | switch (params->disposition) { |
| 226 | case NEW_BACKGROUND_TAB: |
[email protected] | eaca0ad1 | 2011-04-18 15:53:41 | [diff] [blame] | 227 | // Disposition trumps add types. ADD_ACTIVE is a default, so we need to |
[email protected] | 0b17b7d | 2010-11-17 17:39:58 | [diff] [blame] | 228 | // remove it if disposition implies the tab is going to open in the |
| 229 | // background. |
[email protected] | eaca0ad1 | 2011-04-18 15:53:41 | [diff] [blame] | 230 | params->tabstrip_add_types &= ~TabStripModel::ADD_ACTIVE; |
[email protected] | 0b17b7d | 2010-11-17 17:39:58 | [diff] [blame] | 231 | break; |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 232 | |
[email protected] | 0b17b7d | 2010-11-17 17:39:58 | [diff] [blame] | 233 | case NEW_WINDOW: |
| 234 | case NEW_POPUP: |
| 235 | // Code that wants to open a new window typically expects it to be shown |
| 236 | // automatically. |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 237 | if (params->window_action == chrome::NavigateParams::NO_ACTION) |
| 238 | params->window_action = chrome::NavigateParams::SHOW_WINDOW; |
[email protected] | 0b17b7d | 2010-11-17 17:39:58 | [diff] [blame] | 239 | // Fall-through. |
| 240 | case NEW_FOREGROUND_TAB: |
| 241 | case SINGLETON_TAB: |
[email protected] | eaca0ad1 | 2011-04-18 15:53:41 | [diff] [blame] | 242 | params->tabstrip_add_types |= TabStripModel::ADD_ACTIVE; |
[email protected] | 0b17b7d | 2010-11-17 17:39:58 | [diff] [blame] | 243 | break; |
| 244 | |
| 245 | default: |
| 246 | break; |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 247 | } |
| 248 | } |
| 249 | |
[email protected] | d7ff359 | 2010-11-30 21:50:46 | [diff] [blame] | 250 | // Obtain the profile used by the code that originated the Navigate() request. |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 251 | Profile* GetSourceProfile(chrome::NavigateParams* params) { |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 252 | if (params->source_contents) { |
| 253 | return Profile::FromBrowserContext( |
| 254 | params->source_contents->GetBrowserContext()); |
| 255 | } |
[email protected] | d7ff359 | 2010-11-30 21:50:46 | [diff] [blame] | 256 | |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 257 | return params->initiating_profile; |
[email protected] | d7ff359 | 2010-11-30 21:50:46 | [diff] [blame] | 258 | } |
| 259 | |
[email protected] | 6acde635 | 2012-01-04 16:52:20 | [diff] [blame] | 260 | void LoadURLInContents(WebContents* target_contents, |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 261 | const GURL& url, |
[email protected] | 72ea827d | 2012-09-28 01:30:55 | [diff] [blame] | 262 | chrome::NavigateParams* params) { |
[email protected] | a2efc35d | 2013-08-03 23:17:25 | [diff] [blame] | 263 | NavigationController::LoadURLParams load_url_params(url); |
lfg | 9ef7d2d | 2014-12-15 22:32:30 | [diff] [blame] | 264 | load_url_params.source_site_instance = params->source_site_instance; |
[email protected] | cf00233 | 2012-08-14 19:17:47 | [diff] [blame] | 265 | load_url_params.referrer = params->referrer; |
[email protected] | c8029778 | 2013-11-21 07:10:16 | [diff] [blame] | 266 | load_url_params.frame_tree_node_id = params->frame_tree_node_id; |
[email protected] | f887290 | 2013-10-30 03:18:57 | [diff] [blame] | 267 | load_url_params.redirect_chain = params->redirect_chain; |
[email protected] | cf00233 | 2012-08-14 19:17:47 | [diff] [blame] | 268 | load_url_params.transition_type = params->transition; |
[email protected] | 72ea827d | 2012-09-28 01:30:55 | [diff] [blame] | 269 | load_url_params.extra_headers = params->extra_headers; |
[email protected] | 866fa2cc | 2013-07-22 22:19:52 | [diff] [blame] | 270 | load_url_params.should_replace_current_entry = |
| 271 | params->should_replace_current_entry; |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 272 | |
[email protected] | cf00233 | 2012-08-14 19:17:47 | [diff] [blame] | 273 | if (params->transferred_global_request_id != GlobalRequestID()) { |
| 274 | load_url_params.is_renderer_initiated = params->is_renderer_initiated; |
| 275 | load_url_params.transferred_global_request_id = |
| 276 | params->transferred_global_request_id; |
| 277 | } else if (params->is_renderer_initiated) { |
| 278 | load_url_params.is_renderer_initiated = true; |
| 279 | } |
[email protected] | a2efc35d | 2013-08-03 23:17:25 | [diff] [blame] | 280 | |
| 281 | // Only allows the browser-initiated navigation to use POST. |
| 282 | if (params->uses_post && !params->is_renderer_initiated) { |
| 283 | load_url_params.load_type = |
| 284 | NavigationController::LOAD_TYPE_BROWSER_INITIATED_HTTP_POST; |
| 285 | load_url_params.browser_initiated_post_data = |
| 286 | params->browser_initiated_post_data; |
| 287 | } |
[email protected] | cf00233 | 2012-08-14 19:17:47 | [diff] [blame] | 288 | target_contents->GetController().LoadURLWithParams(load_url_params); |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 289 | } |
[email protected] | d7ff359 | 2010-11-30 21:50:46 | [diff] [blame] | 290 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 291 | // This class makes sure the Browser object held in |params| is made visible |
| 292 | // by the time it goes out of scope, provided |params| wants it to be shown. |
[email protected] | 0edcdec | 2013-10-31 06:43:08 | [diff] [blame] | 293 | class ScopedBrowserShower { |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 294 | public: |
[email protected] | 0edcdec | 2013-10-31 06:43:08 | [diff] [blame] | 295 | explicit ScopedBrowserShower(chrome::NavigateParams* params) |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 296 | : params_(params) { |
| 297 | } |
[email protected] | 0edcdec | 2013-10-31 06:43:08 | [diff] [blame] | 298 | ~ScopedBrowserShower() { |
stevenjb | a92701cc | 2014-09-29 23:41:12 | [diff] [blame] | 299 | if (params_->window_action == |
| 300 | chrome::NavigateParams::SHOW_WINDOW_INACTIVE) { |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 301 | params_->browser->window()->ShowInactive(); |
stevenjb | a92701cc | 2014-09-29 23:41:12 | [diff] [blame] | 302 | } else if (params_->window_action == chrome::NavigateParams::SHOW_WINDOW) { |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 303 | params_->browser->window()->Show(); |
stevenjb | a92701cc | 2014-09-29 23:41:12 | [diff] [blame] | 304 | // If a user gesture opened a popup window, focus the contents. |
| 305 | if (params_->user_gesture && params_->disposition == NEW_POPUP && |
| 306 | params_->target_contents) { |
| 307 | params_->target_contents->Focus(); |
| 308 | } |
| 309 | } |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 310 | } |
stevenjb | a92701cc | 2014-09-29 23:41:12 | [diff] [blame] | 311 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 312 | private: |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 313 | chrome::NavigateParams* params_; |
[email protected] | 0edcdec | 2013-10-31 06:43:08 | [diff] [blame] | 314 | DISALLOW_COPY_AND_ASSIGN(ScopedBrowserShower); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 315 | }; |
| 316 | |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 317 | // This class manages the lifetime of a WebContents created by the |
| 318 | // Navigate() function. When Navigate() creates a WebContents for a URL, |
[email protected] | 075969d | 2012-04-17 20:05:55 | [diff] [blame] | 319 | // an instance of this class takes ownership of it via TakeOwnership() until the |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 320 | // WebContents is added to a tab strip at which time ownership is |
[email protected] | 075969d | 2012-04-17 20:05:55 | [diff] [blame] | 321 | // relinquished via ReleaseOwnership(). If this object goes out of scope without |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 322 | // being added to a tab strip, the created WebContents is deleted to |
[email protected] | 075969d | 2012-04-17 20:05:55 | [diff] [blame] | 323 | // avoid a leak and the params->target_contents field is set to NULL. |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 324 | class ScopedTargetContentsOwner { |
| 325 | public: |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 326 | explicit ScopedTargetContentsOwner(chrome::NavigateParams* params) |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 327 | : params_(params) { |
| 328 | } |
| 329 | ~ScopedTargetContentsOwner() { |
| 330 | if (target_contents_owner_.get()) |
| 331 | params_->target_contents = NULL; |
| 332 | } |
| 333 | |
| 334 | // Assumes ownership of |params_|' target_contents until ReleaseOwnership |
| 335 | // is called. |
| 336 | void TakeOwnership() { |
| 337 | target_contents_owner_.reset(params_->target_contents); |
| 338 | } |
| 339 | |
| 340 | // Relinquishes ownership of |params_|' target_contents. |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 341 | WebContents* ReleaseOwnership() { |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 342 | return target_contents_owner_.release(); |
| 343 | } |
| 344 | |
| 345 | private: |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 346 | chrome::NavigateParams* params_; |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 347 | scoped_ptr<WebContents> target_contents_owner_; |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 348 | DISALLOW_COPY_AND_ASSIGN(ScopedTargetContentsOwner); |
| 349 | }; |
| 350 | |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 351 | content::WebContents* CreateTargetContents(const chrome::NavigateParams& params, |
| 352 | const GURL& url) { |
| 353 | WebContents::CreateParams create_params( |
| 354 | params.browser->profile(), |
| 355 | tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url)); |
| 356 | if (params.source_contents) { |
| 357 | create_params.initial_size = |
[email protected] | fc2b46b | 2014-05-03 16:33:45 | [diff] [blame] | 358 | params.source_contents->GetContainerBounds().size(); |
alexmos | 090fae8e | 2015-05-28 17:09:28 | [diff] [blame] | 359 | create_params.created_with_opener = params.created_with_opener; |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 360 | } |
[email protected] | 1ac10dca | 2013-08-20 20:47:04 | [diff] [blame] | 361 | if (params.disposition == NEW_BACKGROUND_TAB) |
| 362 | create_params.initially_hidden = true; |
| 363 | |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 364 | #if defined(USE_AURA) |
| 365 | if (params.browser->window() && |
| 366 | params.browser->window()->GetNativeWindow()) { |
| 367 | create_params.context = |
| 368 | params.browser->window()->GetNativeWindow(); |
| 369 | } |
| 370 | #endif |
| 371 | |
[email protected] | 2188b01 | 2013-08-01 21:49:15 | [diff] [blame] | 372 | WebContents* target_contents = WebContents::Create(create_params); |
| 373 | |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 374 | // New tabs can have WebUI URLs that will make calls back to arbitrary |
| 375 | // tab helpers, so the entire set of tab helpers needs to be set up |
| 376 | // immediately. |
| 377 | BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 378 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 379 | extensions::TabHelper::FromWebContents(target_contents)-> |
| 380 | SetExtensionAppById(params.extension_app_id); |
thestig | a84d8e6 | 2014-10-17 22:27:55 | [diff] [blame] | 381 | #endif |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 382 | return target_contents; |
| 383 | } |
| 384 | |
[email protected] | 2c13a4c | 2013-10-21 21:55:31 | [diff] [blame] | 385 | // If a prerendered page exists for |url|, replace the page at |
| 386 | // |params->target_contents| with it and update to point to the swapped-in |
| 387 | // WebContents. |
| 388 | bool SwapInPrerender(const GURL& url, chrome::NavigateParams* params) { |
[email protected] | a155899 | 2013-12-12 20:52:16 | [diff] [blame] | 389 | Profile* profile = |
| 390 | Profile::FromBrowserContext(params->target_contents->GetBrowserContext()); |
| 391 | InstantSearchPrerenderer* prerenderer = |
| 392 | InstantSearchPrerenderer::GetForProfile(profile); |
| 393 | if (prerenderer && prerenderer->UsePrerenderedPage(url, params)) |
| 394 | return true; |
| 395 | |
[email protected] | a0358d7 | 2012-03-09 14:06:50 | [diff] [blame] | 396 | prerender::PrerenderManager* prerender_manager = |
[email protected] | a155899 | 2013-12-12 20:52:16 | [diff] [blame] | 397 | prerender::PrerenderManagerFactory::GetForProfile(profile); |
[email protected] | 36ab69d | 2012-04-06 18:24:54 | [diff] [blame] | 398 | return prerender_manager && |
[email protected] | 2c13a4c | 2013-10-21 21:55:31 | [diff] [blame] | 399 | prerender_manager->MaybeUsePrerenderedPage(url, params); |
[email protected] | a0358d7 | 2012-03-09 14:06:50 | [diff] [blame] | 400 | } |
| 401 | |
[email protected] | 44e11ab | 2013-07-03 02:36:44 | [diff] [blame] | 402 | chrome::HostDesktopType GetHostDesktop(Browser* browser) { |
| 403 | if (browser) |
| 404 | return browser->host_desktop_type(); |
| 405 | return chrome::GetActiveDesktop(); |
| 406 | } |
| 407 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 408 | } // namespace |
| 409 | |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 410 | namespace chrome { |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 411 | |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 412 | NavigateParams::NavigateParams(Browser* a_browser, |
| 413 | const GURL& a_url, |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 414 | ui::PageTransition a_transition) |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 415 | : url(a_url), |
[email protected] | c8029778 | 2013-11-21 07:10:16 | [diff] [blame] | 416 | frame_tree_node_id(-1), |
[email protected] | a2efc35d | 2013-08-03 23:17:25 | [diff] [blame] | 417 | uses_post(false), |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 418 | target_contents(NULL), |
| 419 | source_contents(NULL), |
| 420 | disposition(CURRENT_TAB), |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 421 | trusted_source(false), |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 422 | transition(a_transition), |
[email protected] | ff4330a | 2011-10-14 21:11:02 | [diff] [blame] | 423 | is_renderer_initiated(false), |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 424 | tabstrip_index(-1), |
[email protected] | eaca0ad1 | 2011-04-18 15:53:41 | [diff] [blame] | 425 | tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 426 | window_action(NO_ACTION), |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 427 | user_gesture(true), |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 428 | path_behavior(RESPECT), |
[email protected] | 578c696 | 2011-08-24 22:06:40 | [diff] [blame] | 429 | ref_behavior(IGNORE_REF), |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 430 | browser(a_browser), |
[email protected] | e2caa03 | 2012-11-15 23:29:18 | [diff] [blame] | 431 | initiating_profile(NULL), |
[email protected] | 44e11ab | 2013-07-03 02:36:44 | [diff] [blame] | 432 | host_desktop_type(GetHostDesktop(a_browser)), |
[email protected] | 2188b01 | 2013-08-01 21:49:15 | [diff] [blame] | 433 | should_replace_current_entry(false), |
alexmos | 090fae8e | 2015-05-28 17:09:28 | [diff] [blame] | 434 | created_with_opener(false) { |
[email protected] | 44e11ab | 2013-07-03 02:36:44 | [diff] [blame] | 435 | } |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 436 | |
| 437 | NavigateParams::NavigateParams(Browser* a_browser, |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 438 | WebContents* a_target_contents) |
[email protected] | c8029778 | 2013-11-21 07:10:16 | [diff] [blame] | 439 | : frame_tree_node_id(-1), |
| 440 | uses_post(false), |
[email protected] | a2efc35d | 2013-08-03 23:17:25 | [diff] [blame] | 441 | target_contents(a_target_contents), |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 442 | source_contents(NULL), |
| 443 | disposition(CURRENT_TAB), |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 444 | trusted_source(false), |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 445 | transition(ui::PAGE_TRANSITION_LINK), |
[email protected] | ff4330a | 2011-10-14 21:11:02 | [diff] [blame] | 446 | is_renderer_initiated(false), |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 447 | tabstrip_index(-1), |
[email protected] | eaca0ad1 | 2011-04-18 15:53:41 | [diff] [blame] | 448 | tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
[email protected] | 7d32999 | 2011-04-15 18:20:02 | [diff] [blame] | 449 | window_action(NO_ACTION), |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 450 | user_gesture(true), |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 451 | path_behavior(RESPECT), |
[email protected] | 578c696 | 2011-08-24 22:06:40 | [diff] [blame] | 452 | ref_behavior(IGNORE_REF), |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 453 | browser(a_browser), |
[email protected] | e2caa03 | 2012-11-15 23:29:18 | [diff] [blame] | 454 | initiating_profile(NULL), |
[email protected] | 44e11ab | 2013-07-03 02:36:44 | [diff] [blame] | 455 | host_desktop_type(GetHostDesktop(a_browser)), |
[email protected] | 2188b01 | 2013-08-01 21:49:15 | [diff] [blame] | 456 | should_replace_current_entry(false), |
alexmos | 090fae8e | 2015-05-28 17:09:28 | [diff] [blame] | 457 | created_with_opener(false) { |
[email protected] | 44e11ab | 2013-07-03 02:36:44 | [diff] [blame] | 458 | } |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 459 | |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 460 | NavigateParams::NavigateParams(Profile* a_profile, |
| 461 | const GURL& a_url, |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 462 | ui::PageTransition a_transition) |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 463 | : url(a_url), |
[email protected] | c8029778 | 2013-11-21 07:10:16 | [diff] [blame] | 464 | frame_tree_node_id(-1), |
[email protected] | a2efc35d | 2013-08-03 23:17:25 | [diff] [blame] | 465 | uses_post(false), |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 466 | target_contents(NULL), |
| 467 | source_contents(NULL), |
| 468 | disposition(NEW_FOREGROUND_TAB), |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 469 | trusted_source(false), |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 470 | transition(a_transition), |
| 471 | is_renderer_initiated(false), |
| 472 | tabstrip_index(-1), |
| 473 | tabstrip_add_types(TabStripModel::ADD_ACTIVE), |
[email protected] | 50592b5 | 2013-05-02 22:26:25 | [diff] [blame] | 474 | window_action(SHOW_WINDOW), |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 475 | user_gesture(true), |
| 476 | path_behavior(RESPECT), |
| 477 | ref_behavior(IGNORE_REF), |
| 478 | browser(NULL), |
[email protected] | 3b14b7f2 | 2012-10-04 01:29:09 | [diff] [blame] | 479 | initiating_profile(a_profile), |
[email protected] | 44e11ab | 2013-07-03 02:36:44 | [diff] [blame] | 480 | host_desktop_type(chrome::GetActiveDesktop()), |
[email protected] | 2188b01 | 2013-08-01 21:49:15 | [diff] [blame] | 481 | should_replace_current_entry(false), |
alexmos | 090fae8e | 2015-05-28 17:09:28 | [diff] [blame] | 482 | created_with_opener(false) { |
[email protected] | 44e11ab | 2013-07-03 02:36:44 | [diff] [blame] | 483 | } |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 484 | |
| 485 | NavigateParams::~NavigateParams() {} |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 486 | |
[email protected] | 19c6414 | 2013-03-06 20:08:53 | [diff] [blame] | 487 | void FillNavigateParamsFromOpenURLParams(chrome::NavigateParams* nav_params, |
| 488 | const content::OpenURLParams& params) { |
| 489 | nav_params->referrer = params.referrer; |
lfg | 9ef7d2d | 2014-12-15 22:32:30 | [diff] [blame] | 490 | nav_params->source_site_instance = params.source_site_instance; |
[email protected] | c8029778 | 2013-11-21 07:10:16 | [diff] [blame] | 491 | nav_params->frame_tree_node_id = params.frame_tree_node_id; |
[email protected] | f887290 | 2013-10-30 03:18:57 | [diff] [blame] | 492 | nav_params->redirect_chain = params.redirect_chain; |
[email protected] | 19c6414 | 2013-03-06 20:08:53 | [diff] [blame] | 493 | nav_params->extra_headers = params.extra_headers; |
| 494 | nav_params->disposition = params.disposition; |
[email protected] | d2202e2 | 2014-04-14 20:20:53 | [diff] [blame] | 495 | nav_params->trusted_source = false; |
[email protected] | 19c6414 | 2013-03-06 20:08:53 | [diff] [blame] | 496 | nav_params->is_renderer_initiated = params.is_renderer_initiated; |
| 497 | nav_params->transferred_global_request_id = |
| 498 | params.transferred_global_request_id; |
[email protected] | 866fa2cc | 2013-07-22 22:19:52 | [diff] [blame] | 499 | nav_params->should_replace_current_entry = |
| 500 | params.should_replace_current_entry; |
[email protected] | a2efc35d | 2013-08-03 23:17:25 | [diff] [blame] | 501 | nav_params->uses_post = params.uses_post; |
| 502 | nav_params->browser_initiated_post_data = params.browser_initiated_post_data; |
[email protected] | 19c6414 | 2013-03-06 20:08:53 | [diff] [blame] | 503 | } |
| 504 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 505 | void Navigate(NavigateParams* params) { |
[email protected] | d7ff359 | 2010-11-30 21:50:46 | [diff] [blame] | 506 | Browser* source_browser = params->browser; |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 507 | if (source_browser) |
| 508 | params->initiating_profile = source_browser->profile(); |
| 509 | DCHECK(params->initiating_profile); |
[email protected] | 93ad8e1c | 2011-11-08 21:34:05 | [diff] [blame] | 510 | |
| 511 | if (!AdjustNavigateParamsForURL(params)) |
| 512 | return; |
[email protected] | eca25813 | 2010-11-15 23:33:08 | [diff] [blame] | 513 | |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 514 | #if defined(ENABLE_EXTENSIONS) |
[email protected] | bfaf3d9 | 2014-03-19 06:43:51 | [diff] [blame] | 515 | const extensions::Extension* extension = |
| 516 | extensions::ExtensionRegistry::Get(params->initiating_profile)-> |
| 517 | enabled_extensions().GetExtensionOrAppByURL(params->url); |
| 518 | // Platform apps cannot navigate. Block the request. |
| 519 | if (extension && extension->is_platform_app()) |
| 520 | params->url = GURL(chrome::kExtensionInvalidRequestURL); |
thestig | 2dbee717e | 2014-09-05 14:54:28 | [diff] [blame] | 521 | #endif |
[email protected] | 4d007b31 | 2012-10-17 03:00:48 | [diff] [blame] | 522 | |
[email protected] | 4a5b172 | 2012-05-04 21:16:04 | [diff] [blame] | 523 | // The browser window may want to adjust the disposition. |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 524 | if (params->disposition == NEW_POPUP && |
| 525 | source_browser && |
| 526 | source_browser->window()) { |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 527 | params->disposition = |
| 528 | source_browser->window()->GetDispositionForPopupBounds( |
| 529 | params->window_bounds); |
| 530 | } |
| 531 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 532 | params->browser = GetBrowserForDisposition(params); |
[email protected] | 9522ddf | 2011-10-07 19:12:11 | [diff] [blame] | 533 | if (!params->browser) |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 534 | return; |
[email protected] | 9522ddf | 2011-10-07 19:12:11 | [diff] [blame] | 535 | |
[email protected] | ad4c2d3 | 2013-12-06 12:59:26 | [diff] [blame] | 536 | #if defined(USE_ASH) |
| 537 | if (source_browser && source_browser != params->browser) { |
| 538 | // When the newly created browser was spawned by a browser which visits |
| 539 | // another user's desktop, it should be shown on the same desktop as the |
| 540 | // originating one. (This is part of the desktop separation per profile). |
| 541 | MultiUserWindowManager* manager = MultiUserWindowManager::GetInstance(); |
| 542 | // Some unit tests have no manager instantiated. |
| 543 | if (manager) { |
| 544 | aura::Window* src_window = source_browser->window()->GetNativeWindow(); |
| 545 | aura::Window* new_window = params->browser->window()->GetNativeWindow(); |
| 546 | const std::string& src_user = |
| 547 | manager->GetUserPresentingWindow(src_window); |
| 548 | if (src_user != manager->GetUserPresentingWindow(new_window)) { |
| 549 | // Once the window gets presented, it should be shown on the same |
| 550 | // desktop as the desktop of the creating browser. Note that this |
| 551 | // command will not show the window if it wasn't shown yet by the |
| 552 | // browser creation. |
| 553 | manager->ShowWindowForUser(new_window, src_user); |
| 554 | } |
| 555 | } |
| 556 | } |
| 557 | #endif |
| 558 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 559 | // Navigate() must not return early after this point. |
| 560 | |
[email protected] | 8fb16a8 | 2012-08-17 02:17:59 | [diff] [blame] | 561 | if (GetSourceProfile(params) != params->browser->profile()) { |
[email protected] | d7ff359 | 2010-11-30 21:50:46 | [diff] [blame] | 562 | // A tab is being opened from a link from a different profile, we must reset |
| 563 | // source information that may cause state to be shared. |
| 564 | params->source_contents = NULL; |
[email protected] | cb8fb01a | 2011-12-05 21:01:14 | [diff] [blame] | 565 | params->referrer = content::Referrer(); |
[email protected] | d7ff359 | 2010-11-30 21:50:46 | [diff] [blame] | 566 | } |
| 567 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 568 | // Make sure the Browser is shown if params call for it. |
[email protected] | 0edcdec | 2013-10-31 06:43:08 | [diff] [blame] | 569 | ScopedBrowserShower shower(params); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 570 | |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 571 | // Makes sure any WebContents created by this function is destroyed if |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 572 | // not properly added to a tab strip. |
| 573 | ScopedTargetContentsOwner target_contents_owner(params); |
| 574 | |
| 575 | // Some dispositions need coercion to base types. |
| 576 | NormalizeDisposition(params); |
| 577 | |
[email protected] | 0edcdec | 2013-10-31 06:43:08 | [diff] [blame] | 578 | // If a new window has been created, it needs to be shown. |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 579 | if (params->window_action == NavigateParams::NO_ACTION && |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 580 | source_browser != params->browser && |
[email protected] | c084925 | 2012-05-12 13:51:27 | [diff] [blame] | 581 | params->browser->tab_strip_model()->empty()) { |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 582 | params->window_action = NavigateParams::SHOW_WINDOW; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | // If we create a popup window from a non user-gesture, don't activate it. |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 586 | if (params->window_action == NavigateParams::SHOW_WINDOW && |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 587 | params->disposition == NEW_POPUP && |
| 588 | params->user_gesture == false) { |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 589 | params->window_action = NavigateParams::SHOW_WINDOW_INACTIVE; |
[email protected] | 588300d | 2011-04-28 21:06:35 | [diff] [blame] | 590 | } |
| 591 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 592 | // Determine if the navigation was user initiated. If it was, we need to |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 593 | // inform the target WebContents, and we may need to update the UI. |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 594 | ui::PageTransition base_transition = |
| 595 | ui::PageTransitionStripQualifier(params->transition); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 596 | bool user_initiated = |
Sylvain Defresne | c6ccc77d | 2014-09-19 10:19:35 | [diff] [blame] | 597 | params->transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR || |
| 598 | base_transition == ui::PAGE_TRANSITION_TYPED || |
| 599 | base_transition == ui::PAGE_TRANSITION_AUTO_BOOKMARK || |
| 600 | base_transition == ui::PAGE_TRANSITION_GENERATED || |
| 601 | base_transition == ui::PAGE_TRANSITION_AUTO_TOPLEVEL || |
| 602 | base_transition == ui::PAGE_TRANSITION_RELOAD || |
| 603 | base_transition == ui::PAGE_TRANSITION_KEYWORD; |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 604 | |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 605 | // Check if this is a singleton tab that already exists |
[email protected] | 5d9cace7 | 2012-06-21 16:07:12 | [diff] [blame] | 606 | int singleton_index = chrome::GetIndexOfSingletonTab(params); |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 607 | |
[email protected] | 77759005 | 2014-01-17 22:11:54 | [diff] [blame] | 608 | // Did we use a prerender? |
| 609 | bool swapped_in_prerender = false; |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 610 | |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 611 | // If no target WebContents was specified, we need to construct one if |
[email protected] | 075969d | 2012-04-17 20:05:55 | [diff] [blame] | 612 | // we are supposed to target a new tab; unless it's a singleton that already |
| 613 | // exists. |
[email protected] | fa7ebe0 | 2010-11-29 23:04:57 | [diff] [blame] | 614 | if (!params->target_contents && singleton_index < 0) { |
[email protected] | f5ec3c92 | 2014-05-22 15:04:03 | [diff] [blame] | 615 | DCHECK(!params->url.is_empty()); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 616 | if (params->disposition != CURRENT_TAB) { |
[email protected] | f5ec3c92 | 2014-05-22 15:04:03 | [diff] [blame] | 617 | params->target_contents = CreateTargetContents(*params, params->url); |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 618 | |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 619 | // This function takes ownership of |params->target_contents| until it |
| 620 | // is added to a TabStripModel. |
| 621 | target_contents_owner.TakeOwnership(); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 622 | } else { |
| 623 | // ... otherwise if we're loading in the current tab, the target is the |
| 624 | // same as the source. |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 625 | DCHECK(params->source_contents); |
[email protected] | 77759005 | 2014-01-17 22:11:54 | [diff] [blame] | 626 | params->target_contents = params->source_contents; |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 627 | |
davidben | 1f9befb | 2015-01-14 18:14:05 | [diff] [blame] | 628 | // Prerender can only swap in CURRENT_TAB navigations; others have |
| 629 | // different sessionStorage namespaces. |
| 630 | swapped_in_prerender = SwapInPrerender(params->url, params); |
| 631 | } |
[email protected] | a5f730d5 | 2014-05-14 01:09:22 | [diff] [blame] | 632 | |
[email protected] | e35ccd5 | 2012-05-23 16:22:47 | [diff] [blame] | 633 | if (user_initiated) |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 634 | params->target_contents->UserGestureDone(); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 635 | |
[email protected] | 77759005 | 2014-01-17 22:11:54 | [diff] [blame] | 636 | if (!swapped_in_prerender) { |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 637 | // Try to handle non-navigational URLs that popup dialogs and such, these |
| 638 | // should not actually navigate. |
[email protected] | f5ec3c92 | 2014-05-22 15:04:03 | [diff] [blame] | 639 | if (!HandleNonNavigationAboutURL(params->url)) { |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 640 | // Perform the actual navigation, tracking whether it came from the |
| 641 | // renderer. |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 642 | |
[email protected] | f5ec3c92 | 2014-05-22 15:04:03 | [diff] [blame] | 643 | LoadURLInContents(params->target_contents, params->url, params); |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 644 | } |
[email protected] | 2f89b60 | 2011-06-01 05:49:17 | [diff] [blame] | 645 | } |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 646 | } else { |
| 647 | // |target_contents| was specified non-NULL, and so we assume it has already |
| 648 | // been navigated appropriately. We need to do nothing more other than |
| 649 | // add it to the appropriate tabstrip. |
| 650 | } |
| 651 | |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 652 | // If the user navigated from the omnibox, and the selected tab is going to |
| 653 | // lose focus, then make sure the focus for the source tab goes away from the |
| 654 | // omnibox. |
| 655 | if (params->source_contents && |
| 656 | (params->disposition == NEW_FOREGROUND_TAB || |
| 657 | params->disposition == NEW_WINDOW) && |
| 658 | (params->tabstrip_add_types & TabStripModel::ADD_INHERIT_OPENER)) |
[email protected] | fc2b46b | 2014-05-03 16:33:45 | [diff] [blame] | 659 | params->source_contents->Focus(); |
[email protected] | 26c53e66 | 2011-07-09 02:21:02 | [diff] [blame] | 660 | |
[email protected] | 0c940663 | 2013-02-08 01:13:33 | [diff] [blame] | 661 | if (params->source_contents == params->target_contents || |
[email protected] | 77759005 | 2014-01-17 22:11:54 | [diff] [blame] | 662 | (swapped_in_prerender && params->disposition == CURRENT_TAB)) { |
[email protected] | 3c9e187 | 2010-11-18 16:17:49 | [diff] [blame] | 663 | // The navigation occurred in the source tab. |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 664 | params->browser->UpdateUIForNavigationInTab(params->target_contents, |
| 665 | params->transition, |
| 666 | user_initiated); |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 667 | } else if (singleton_index == -1) { |
| 668 | // If some non-default value is set for the index, we should tell the |
| 669 | // TabStripModel to respect it. |
| 670 | if (params->tabstrip_index != -1) |
| 671 | params->tabstrip_add_types |= TabStripModel::ADD_FORCE_INDEX; |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 672 | |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 673 | // The navigation should insert a new tab into the target Browser. |
[email protected] | ee9b0cb | 2012-11-29 20:56:17 | [diff] [blame] | 674 | params->browser->tab_strip_model()->AddWebContents( |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 675 | params->target_contents, |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 676 | params->tabstrip_index, |
| 677 | params->transition, |
| 678 | params->tabstrip_add_types); |
| 679 | // Now that the |params->target_contents| is safely owned by the target |
| 680 | // Browser's TabStripModel, we can release ownership. |
| 681 | target_contents_owner.ReleaseOwnership(); |
| 682 | } |
[email protected] | bb89e748 | 2010-11-17 18:27:04 | [diff] [blame] | 683 | |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 684 | if (singleton_index >= 0) { |
[email protected] | 52877dbc6 | 2012-06-29 22:22:03 | [diff] [blame] | 685 | WebContents* target = |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 686 | params->browser->tab_strip_model()->GetWebContentsAt(singleton_index); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 687 | |
[email protected] | be1f56ab | 2011-12-22 06:55:31 | [diff] [blame] | 688 | if (target->IsCrashed()) { |
[email protected] | f5fa20e | 2011-12-21 22:35:56 | [diff] [blame] | 689 | target->GetController().Reload(true); |
[email protected] | 7de53c6 | 2011-05-13 06:44:16 | [diff] [blame] | 690 | } else if (params->path_behavior == NavigateParams::IGNORE_AND_NAVIGATE && |
[email protected] | fee32054 | 2011-03-02 01:30:49 | [diff] [blame] | 691 | target->GetURL() != params->url) { |
[email protected] | 72ea827d | 2012-09-28 01:30:55 | [diff] [blame] | 692 | LoadURLInContents(target, params->url, params); |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 693 | } |
[email protected] | 637b344 | 2011-01-10 23:31:48 | [diff] [blame] | 694 | |
| 695 | // If the singleton tab isn't already selected, select it. |
[email protected] | 5789218 | 2012-12-03 19:15:39 | [diff] [blame] | 696 | if (params->source_contents != params->target_contents) { |
| 697 | params->browser->tab_strip_model()->ActivateTabAt(singleton_index, |
| 698 | user_initiated); |
| 699 | } |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 700 | } |
[email protected] | 0548c535 | 2011-09-07 00:33:33 | [diff] [blame] | 701 | |
| 702 | if (params->disposition != CURRENT_TAB) { |
[email protected] | ad50def5 | 2011-10-19 23:17:07 | [diff] [blame] | 703 | content::NotificationService::current()->Notify( |
[email protected] | 884033e | 2012-04-16 19:38:42 | [diff] [blame] | 704 | chrome::NOTIFICATION_TAB_ADDED, |
[email protected] | 674bc59 | 2011-12-20 23:00:42 | [diff] [blame] | 705 | content::Source<content::WebContentsDelegate>(params->browser), |
[email protected] | e232c99 | 2012-12-06 12:43:20 | [diff] [blame] | 706 | content::Details<WebContents>(params->target_contents)); |
[email protected] | 0548c535 | 2011-09-07 00:33:33 | [diff] [blame] | 707 | } |
[email protected] | 8b0e9cc3 | 2010-11-09 04:00:19 | [diff] [blame] | 708 | } |
| 709 | |
[email protected] | 887ab009 | 2012-10-16 08:48:20 | [diff] [blame] | 710 | bool IsURLAllowedInIncognito(const GURL& url, |
| 711 | content::BrowserContext* browser_context) { |
[email protected] | dbdda540 | 2013-05-30 22:13:48 | [diff] [blame] | 712 | if (url.scheme() == content::kViewSourceScheme) { |
[email protected] | 429e971 | 2013-04-30 09:35:50 | [diff] [blame] | 713 | // A view-source URL is allowed in incognito mode only if the URL itself |
| 714 | // is allowed in incognito mode. Remove the "view-source:" from the start |
| 715 | // of the URL and validate the rest. |
| 716 | std::string stripped_spec = url.spec(); |
[email protected] | dbdda540 | 2013-05-30 22:13:48 | [diff] [blame] | 717 | DCHECK_GT(stripped_spec.size(), strlen(content::kViewSourceScheme)); |
| 718 | stripped_spec.erase(0, strlen(content::kViewSourceScheme) + 1); |
[email protected] | 429e971 | 2013-04-30 09:35:50 | [diff] [blame] | 719 | GURL stripped_url(stripped_spec); |
| 720 | return stripped_url.is_valid() && |
| 721 | IsURLAllowedInIncognito(stripped_url, browser_context); |
| 722 | } |
[email protected] | fc0ed30 | 2011-11-29 23:17:19 | [diff] [blame] | 723 | // Most URLs are allowed in incognito; the following are exceptions. |
| 724 | // chrome://extensions is on the list because it redirects to |
| 725 | // chrome://settings. |
[email protected] | 2d9748b2 | 2014-02-11 00:17:29 | [diff] [blame] | 726 | if (url.scheme() == content::kChromeUIScheme && |
[email protected] | 130b48e0 | 2011-10-14 15:48:19 | [diff] [blame] | 727 | (url.host() == chrome::kChromeUISettingsHost || |
[email protected] | 846c3ecea | 2011-12-14 18:47:26 | [diff] [blame] | 728 | url.host() == chrome::kChromeUISettingsFrameHost || |
michaelpg | 3dadf61a | 2014-11-04 23:05:36 | [diff] [blame] | 729 | url.host() == chrome::kChromeUIHelpHost || |
[email protected] | 130b48e0 | 2011-10-14 15:48:19 | [diff] [blame] | 730 | url.host() == chrome::kChromeUIExtensionsHost || |
[email protected] | fc0ed30 | 2011-11-29 23:17:19 | [diff] [blame] | 731 | url.host() == chrome::kChromeUIBookmarksHost || |
[email protected] | aed0498 | 2014-01-14 00:50:45 | [diff] [blame] | 732 | #if !defined(OS_CHROMEOS) |
| 733 | url.host() == chrome::kChromeUIChromeSigninHost || |
| 734 | #endif |
[email protected] | 89e1466e | 2013-10-22 15:47:18 | [diff] [blame] | 735 | url.host() == chrome::kChromeUIUberHost || |
| 736 | url.host() == chrome::kChromeUIThumbnailHost || |
| 737 | url.host() == chrome::kChromeUIThumbnailHost2 || |
[email protected] | ae16fc33 | 2014-02-25 02:14:08 | [diff] [blame] | 738 | url.host() == chrome::kChromeUIThumbnailListHost || |
[email protected] | 09bb43a | 2014-04-15 04:39:02 | [diff] [blame] | 739 | url.host() == chrome::kChromeUISuggestionsHost || |
[email protected] | 98a9244 | 2014-08-08 09:53:06 | [diff] [blame] | 740 | url.host() == chrome::kChromeUIDevicesHost || |
| 741 | url.host() == chrome::kChromeUIVoiceSearchHost)) { |
[email protected] | 89e1466e | 2013-10-22 15:47:18 | [diff] [blame] | 742 | return false; |
| 743 | } |
| 744 | |
| 745 | if (url.scheme() == chrome::kChromeSearchScheme && |
| 746 | (url.host() == chrome::kChromeUIThumbnailHost || |
| 747 | url.host() == chrome::kChromeUIThumbnailHost2 || |
[email protected] | ae16fc33 | 2014-02-25 02:14:08 | [diff] [blame] | 748 | url.host() == chrome::kChromeUIThumbnailListHost || |
| 749 | url.host() == chrome::kChromeUISuggestionsHost)) { |
[email protected] | 887ab009 | 2012-10-16 08:48:20 | [diff] [blame] | 750 | return false; |
| 751 | } |
| 752 | |
| 753 | GURL rewritten_url = url; |
| 754 | bool reverse_on_redirect = false; |
| 755 | content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
| 756 | &rewritten_url, browser_context, &reverse_on_redirect); |
| 757 | |
| 758 | // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
[email protected] | 2d9748b2 | 2014-02-11 00:17:29 | [diff] [blame] | 759 | return !(rewritten_url.scheme() == content::kChromeUIScheme && |
[email protected] | 887ab009 | 2012-10-16 08:48:20 | [diff] [blame] | 760 | rewritten_url.host() == chrome::kChromeUIUberHost); |
[email protected] | 130b48e0 | 2011-10-14 15:48:19 | [diff] [blame] | 761 | } |
| 762 | |
[email protected] | 78e2edc | 2012-07-01 23:32:28 | [diff] [blame] | 763 | } // namespace chrome |