| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 const GURL& url) { | 325 const GURL& url) { |
| 326 WebContents::CreateParams create_params( | 326 WebContents::CreateParams create_params( |
| 327 params.browser->profile(), | 327 params.browser->profile(), |
| 328 tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url)); | 328 tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url)); |
| 329 if (params.source_contents) { | 329 if (params.source_contents) { |
| 330 create_params.initial_size = | 330 create_params.initial_size = |
| 331 params.source_contents->GetView()->GetContainerSize(); | 331 params.source_contents->GetView()->GetContainerSize(); |
| 332 if (params.should_set_opener) | 332 if (params.should_set_opener) |
| 333 create_params.opener = params.source_contents; | 333 create_params.opener = params.source_contents; |
| 334 } | 334 } |
| 335 if (params.disposition == NEW_BACKGROUND_TAB) |
| 336 create_params.initially_hidden = true; |
| 337 |
| 335 #if defined(USE_AURA) | 338 #if defined(USE_AURA) |
| 336 if (params.browser->window() && | 339 if (params.browser->window() && |
| 337 params.browser->window()->GetNativeWindow()) { | 340 params.browser->window()->GetNativeWindow()) { |
| 338 create_params.context = | 341 create_params.context = |
| 339 params.browser->window()->GetNativeWindow(); | 342 params.browser->window()->GetNativeWindow(); |
| 340 } | 343 } |
| 341 #endif | 344 #endif |
| 342 | 345 |
| 343 WebContents* target_contents = WebContents::Create(create_params); | 346 WebContents* target_contents = WebContents::Create(create_params); |
| 344 | 347 |
| 345 // New tabs can have WebUI URLs that will make calls back to arbitrary | 348 // New tabs can have WebUI URLs that will make calls back to arbitrary |
| 346 // tab helpers, so the entire set of tab helpers needs to be set up | 349 // tab helpers, so the entire set of tab helpers needs to be set up |
| 347 // immediately. | 350 // immediately. |
| 348 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); | 351 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); |
| 349 extensions::TabHelper::FromWebContents(target_contents)-> | 352 extensions::TabHelper::FromWebContents(target_contents)-> |
| 350 SetExtensionAppById(params.extension_app_id); | 353 SetExtensionAppById(params.extension_app_id); |
| 351 // TODO(sky): Figure out why this is needed. Without it we seem to get | |
| 352 // failures in startup tests. | |
| 353 // By default, content believes it is not hidden. When adding contents | |
| 354 // in the background, tell it that it's hidden. | |
| 355 if ((params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) == 0) { | |
| 356 // TabStripModel::AddWebContents invokes WasHidden if not foreground. | |
| 357 target_contents->WasHidden(); | |
| 358 } | |
| 359 return target_contents; | 354 return target_contents; |
| 360 } | 355 } |
| 361 | 356 |
| 362 // If a prerendered page exists for |url|, replace the page at |target_contents| | 357 // If a prerendered page exists for |url|, replace the page at |target_contents| |
| 363 // with it. | 358 // with it. |
| 364 bool SwapInPrerender(WebContents* target_contents, const GURL& url) { | 359 bool SwapInPrerender(WebContents* target_contents, const GURL& url) { |
| 365 prerender::PrerenderManager* prerender_manager = | 360 prerender::PrerenderManager* prerender_manager = |
| 366 prerender::PrerenderManagerFactory::GetForProfile( | 361 prerender::PrerenderManagerFactory::GetForProfile( |
| 367 Profile::FromBrowserContext(target_contents->GetBrowserContext())); | 362 Profile::FromBrowserContext(target_contents->GetBrowserContext())); |
| 368 return prerender_manager && | 363 return prerender_manager && |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 bool reverse_on_redirect = false; | 685 bool reverse_on_redirect = false; |
| 691 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 686 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
| 692 &rewritten_url, browser_context, &reverse_on_redirect); | 687 &rewritten_url, browser_context, &reverse_on_redirect); |
| 693 | 688 |
| 694 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 689 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
| 695 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && | 690 return !(rewritten_url.scheme() == chrome::kChromeUIScheme && |
| 696 rewritten_url.host() == chrome::kChromeUIUberHost); | 691 rewritten_url.host() == chrome::kChromeUIUberHost); |
| 697 } | 692 } |
| 698 | 693 |
| 699 } // namespace chrome | 694 } // namespace chrome |
| OLD | NEW |