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