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 #include <memory> |
| 9 #include <string> |
8 | 10 |
9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
10 #include "base/macros.h" | 12 #include "base/macros.h" |
11 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
12 #include "build/build_config.h" | 14 #include "build/build_config.h" |
13 #include "chrome/browser/browser_about_handler.h" | 15 #include "chrome/browser/browser_about_handler.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 17 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
16 #include "chrome/browser/prerender/prerender_manager.h" | 18 #include "chrome/browser/prerender/prerender_manager.h" |
17 #include "chrome/browser/prerender/prerender_manager_factory.h" | 19 #include "chrome/browser/prerender/prerender_manager_factory.h" |
18 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/tab_contents/tab_util.h" | 21 #include "chrome/browser/tab_contents/tab_util.h" |
20 #include "chrome/browser/task_manager/web_contents_tags.h" | 22 #include "chrome/browser/task_manager/web_contents_tags.h" |
21 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_finder.h" | 24 #include "chrome/browser/ui/browser_finder.h" |
23 #include "chrome/browser/ui/browser_instant_controller.h" | 25 #include "chrome/browser/ui/browser_instant_controller.h" |
24 #include "chrome/browser/ui/browser_navigator_params.h" | 26 #include "chrome/browser/ui/browser_navigator_params.h" |
25 #include "chrome/browser/ui/browser_window.h" | 27 #include "chrome/browser/ui/browser_window.h" |
26 #include "chrome/browser/ui/location_bar/location_bar.h" | 28 #include "chrome/browser/ui/location_bar/location_bar.h" |
27 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 29 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
28 #include "chrome/browser/ui/singleton_tabs.h" | 30 #include "chrome/browser/ui/singleton_tabs.h" |
29 #include "chrome/browser/ui/status_bubble.h" | 31 #include "chrome/browser/ui/status_bubble.h" |
30 #include "chrome/browser/ui/tab_helpers.h" | 32 #include "chrome/browser/ui/tab_helpers.h" |
31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
32 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
33 #include "components/prefs/pref_service.h" | 35 #include "components/prefs/pref_service.h" |
34 #include "content/public/browser/browser_url_handler.h" | 36 #include "content/public/browser/browser_url_handler.h" |
35 #include "content/public/browser/navigation_entry.h" | 37 #include "content/public/browser/navigation_entry.h" |
36 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
| 39 #include "content/public/browser/render_frame_host.h" |
| 40 #include "content/public/browser/render_process_host.h" |
37 #include "content/public/browser/render_view_host.h" | 41 #include "content/public/browser/render_view_host.h" |
38 #include "content/public/browser/web_contents.h" | 42 #include "content/public/browser/web_contents.h" |
39 #include "extensions/features/features.h" | 43 #include "extensions/features/features.h" |
40 | 44 |
41 #if defined(USE_ASH) | 45 #if defined(USE_ASH) |
42 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 46 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
43 #include "components/signin/core/account_id/account_id.h" | 47 #include "components/signin/core/account_id/account_id.h" |
44 #endif | 48 #endif |
45 | 49 |
46 #if defined(USE_AURA) | 50 #if defined(USE_AURA) |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } | 353 } |
350 | 354 |
351 private: | 355 private: |
352 chrome::NavigateParams* params_; | 356 chrome::NavigateParams* params_; |
353 std::unique_ptr<WebContents> target_contents_owner_; | 357 std::unique_ptr<WebContents> target_contents_owner_; |
354 DISALLOW_COPY_AND_ASSIGN(ScopedTargetContentsOwner); | 358 DISALLOW_COPY_AND_ASSIGN(ScopedTargetContentsOwner); |
355 }; | 359 }; |
356 | 360 |
357 content::WebContents* CreateTargetContents(const chrome::NavigateParams& params, | 361 content::WebContents* CreateTargetContents(const chrome::NavigateParams& params, |
358 const GURL& url) { | 362 const GURL& url) { |
| 363 // If |params.opener| is present, then (initially) put the new contents in the |
| 364 // same process as the opener. Note that this is only "initial" placement |
| 365 // (i.e. if subsequent navigation [including the initial navigation] triggers |
| 366 // a cross-process transfer, then the opener and new contents can end up in |
| 367 // separate processes). |
| 368 scoped_refptr<content::SiteInstance> initial_site_instance_for_new_contents = |
| 369 params.opener |
| 370 ? params.opener->GetSiteInstance() |
| 371 : tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url); |
| 372 |
359 WebContents::CreateParams create_params( | 373 WebContents::CreateParams create_params( |
360 params.browser->profile(), | 374 params.browser->profile(), initial_site_instance_for_new_contents); |
361 params.source_site_instance && !params.force_new_process_for_new_contents | |
362 ? params.source_site_instance | |
363 : tab_util::GetSiteInstanceForNewTab(params.browser->profile(), url)); | |
364 create_params.main_frame_name = params.frame_name; | 375 create_params.main_frame_name = params.frame_name; |
| 376 if (params.opener) { |
| 377 create_params.opener_render_frame_id = params.opener->GetRoutingID(); |
| 378 create_params.opener_render_process_id = |
| 379 params.opener->GetProcess()->GetID(); |
| 380 } |
365 if (params.source_contents) { | 381 if (params.source_contents) { |
366 create_params.initial_size = | 382 create_params.initial_size = |
367 params.source_contents->GetContainerBounds().size(); | 383 params.source_contents->GetContainerBounds().size(); |
368 create_params.created_with_opener = params.created_with_opener; | 384 create_params.created_with_opener = params.created_with_opener; |
369 } | 385 } |
370 if (params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) | 386 if (params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB) |
371 create_params.initially_hidden = true; | 387 create_params.initially_hidden = true; |
372 | 388 |
373 #if defined(USE_AURA) | 389 #if defined(USE_AURA) |
374 if (params.browser->window() && | 390 if (params.browser->window() && |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 } | 482 } |
467 } | 483 } |
468 } | 484 } |
469 #endif | 485 #endif |
470 | 486 |
471 // Navigate() must not return early after this point. | 487 // Navigate() must not return early after this point. |
472 | 488 |
473 if (GetSourceProfile(params) != params->browser->profile()) { | 489 if (GetSourceProfile(params) != params->browser->profile()) { |
474 // A tab is being opened from a link from a different profile, we must reset | 490 // A tab is being opened from a link from a different profile, we must reset |
475 // source information that may cause state to be shared. | 491 // source information that may cause state to be shared. |
| 492 params->opener = nullptr; |
476 params->source_contents = nullptr; | 493 params->source_contents = nullptr; |
477 params->source_site_instance = nullptr; | 494 params->source_site_instance = nullptr; |
478 params->referrer = content::Referrer(); | 495 params->referrer = content::Referrer(); |
479 } | 496 } |
480 | 497 |
481 // Make sure the Browser is shown if params call for it. | 498 // Make sure the Browser is shown if params call for it. |
482 ScopedBrowserShower shower(params); | 499 ScopedBrowserShower shower(params); |
483 | 500 |
484 // Makes sure any WebContents created by this function is destroyed if | 501 // Makes sure any WebContents created by this function is destroyed if |
485 // not properly added to a tab strip. | 502 // not properly added to a tab strip. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 bool reverse_on_redirect = false; | 693 bool reverse_on_redirect = false; |
677 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 694 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
678 &rewritten_url, browser_context, &reverse_on_redirect); | 695 &rewritten_url, browser_context, &reverse_on_redirect); |
679 | 696 |
680 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 697 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
681 return !(rewritten_url.scheme_piece() == content::kChromeUIScheme && | 698 return !(rewritten_url.scheme_piece() == content::kChromeUIScheme && |
682 rewritten_url.host_piece() == chrome::kChromeUIUberHost); | 699 rewritten_url.host_piece() == chrome::kChromeUIUberHost); |
683 } | 700 } |
684 | 701 |
685 } // namespace chrome | 702 } // namespace chrome |
OLD | NEW |