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/macros.h" | 10 #include "base/macros.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #include "extensions/common/extension.h" | 54 #include "extensions/common/extension.h" |
55 #include "extensions/common/extension_set.h" | 55 #include "extensions/common/extension_set.h" |
56 #endif | 56 #endif |
57 | 57 |
58 using content::GlobalRequestID; | 58 using content::GlobalRequestID; |
59 using content::NavigationController; | 59 using content::NavigationController; |
60 using content::WebContents; | 60 using content::WebContents; |
61 | 61 |
62 class BrowserNavigatorWebContentsAdoption { | 62 class BrowserNavigatorWebContentsAdoption { |
63 public: | 63 public: |
64 static void AttachTabHelpers(content::WebContents* contents) { | 64 static void AttachTabHelpers( |
65 TabHelpers::AttachTabHelpers(contents); | 65 content::WebContents* contents, |
| 66 const base::Optional<WebContents::CreateParams>& create_params) { |
| 67 TabHelpers::AttachTabHelpers(contents, create_params); |
66 | 68 |
67 // Make the tab show up in the task manager. | 69 // Make the tab show up in the task manager. |
68 task_manager::WebContentsTags::CreateForTabContents(contents); | 70 task_manager::WebContentsTags::CreateForTabContents(contents); |
69 } | 71 } |
70 }; | 72 }; |
71 | 73 |
72 namespace { | 74 namespace { |
73 | 75 |
74 // Returns true if the specified Browser can open tabs. Not all Browsers support | 76 // Returns true if the specified Browser can open tabs. Not all Browsers support |
75 // multiple tabs, such as app frames and popups. This function returns false for | 77 // multiple tabs, such as app frames and popups. This function returns false for |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 create_params.context = | 376 create_params.context = |
375 params.browser->window()->GetNativeWindow(); | 377 params.browser->window()->GetNativeWindow(); |
376 } | 378 } |
377 #endif | 379 #endif |
378 | 380 |
379 WebContents* target_contents = WebContents::Create(create_params); | 381 WebContents* target_contents = WebContents::Create(create_params); |
380 | 382 |
381 // New tabs can have WebUI URLs that will make calls back to arbitrary | 383 // New tabs can have WebUI URLs that will make calls back to arbitrary |
382 // tab helpers, so the entire set of tab helpers needs to be set up | 384 // tab helpers, so the entire set of tab helpers needs to be set up |
383 // immediately. | 385 // immediately. |
384 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); | 386 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents, |
| 387 create_params); |
385 #if BUILDFLAG(ENABLE_EXTENSIONS) | 388 #if BUILDFLAG(ENABLE_EXTENSIONS) |
386 extensions::TabHelper::FromWebContents(target_contents)-> | 389 extensions::TabHelper::FromWebContents(target_contents)-> |
387 SetExtensionAppById(params.extension_app_id); | 390 SetExtensionAppById(params.extension_app_id); |
388 #endif | 391 #endif |
389 | 392 |
390 return target_contents; | 393 return target_contents; |
391 } | 394 } |
392 | 395 |
393 // If a prerendered page exists for |url|, replace the page at | 396 // If a prerendered page exists for |url|, replace the page at |
394 // |params->target_contents| with it and update to point to the swapped-in | 397 // |params->target_contents| with it and update to point to the swapped-in |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 bool reverse_on_redirect = false; | 676 bool reverse_on_redirect = false; |
674 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 677 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
675 &rewritten_url, browser_context, &reverse_on_redirect); | 678 &rewritten_url, browser_context, &reverse_on_redirect); |
676 | 679 |
677 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 680 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
678 return !(rewritten_url.scheme_piece() == content::kChromeUIScheme && | 681 return !(rewritten_url.scheme_piece() == content::kChromeUIScheme && |
679 rewritten_url.host_piece() == chrome::kChromeUIUberHost); | 682 rewritten_url.host_piece() == chrome::kChromeUIUberHost); |
680 } | 683 } |
681 | 684 |
682 } // namespace chrome | 685 } // namespace chrome |
OLD | NEW |