| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "components/signin/core/account_id/account_id.h" | 43 #include "components/signin/core/account_id/account_id.h" |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 #if defined(USE_AURA) | 46 #if defined(USE_AURA) |
| 47 #include "ui/aura/window.h" | 47 #include "ui/aura/window.h" |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 #if BUILDFLAG(ENABLE_EXTENSIONS) | 50 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 51 #include "chrome/browser/extensions/tab_helper.h" | 51 #include "chrome/browser/extensions/tab_helper.h" |
| 52 #include "chrome/browser/web_applications/web_app.h" | 52 #include "chrome/browser/web_applications/web_app.h" |
| 53 #include "extensions/browser/extension_registry.h" | |
| 54 #include "extensions/common/extension.h" | |
| 55 #include "extensions/common/extension_set.h" | |
| 56 #endif | 53 #endif |
| 57 | 54 |
| 58 using content::GlobalRequestID; | 55 using content::GlobalRequestID; |
| 59 using content::NavigationController; | 56 using content::NavigationController; |
| 60 using content::WebContents; | 57 using content::WebContents; |
| 61 | 58 |
| 62 class BrowserNavigatorWebContentsAdoption { | 59 class BrowserNavigatorWebContentsAdoption { |
| 63 public: | 60 public: |
| 64 static void AttachTabHelpers(content::WebContents* contents) { | 61 static void AttachTabHelpers(content::WebContents* contents) { |
| 65 TabHelpers::AttachTabHelpers(contents); | 62 TabHelpers::AttachTabHelpers(contents); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 411 |
| 415 void Navigate(NavigateParams* params) { | 412 void Navigate(NavigateParams* params) { |
| 416 Browser* source_browser = params->browser; | 413 Browser* source_browser = params->browser; |
| 417 if (source_browser) | 414 if (source_browser) |
| 418 params->initiating_profile = source_browser->profile(); | 415 params->initiating_profile = source_browser->profile(); |
| 419 DCHECK(params->initiating_profile); | 416 DCHECK(params->initiating_profile); |
| 420 | 417 |
| 421 if (!AdjustNavigateParamsForURL(params)) | 418 if (!AdjustNavigateParamsForURL(params)) |
| 422 return; | 419 return; |
| 423 | 420 |
| 424 #if BUILDFLAG(ENABLE_EXTENSIONS) | |
| 425 const extensions::Extension* extension = | |
| 426 extensions::ExtensionRegistry::Get(params->initiating_profile)-> | |
| 427 enabled_extensions().GetExtensionOrAppByURL(params->url); | |
| 428 // Platform apps cannot navigate. Block the request. | |
| 429 if (extension && extension->is_platform_app()) | |
| 430 params->url = GURL(chrome::kExtensionInvalidRequestURL); | |
| 431 #endif | |
| 432 | |
| 433 // The browser window may want to adjust the disposition. | 421 // The browser window may want to adjust the disposition. |
| 434 if (params->disposition == WindowOpenDisposition::NEW_POPUP && | 422 if (params->disposition == WindowOpenDisposition::NEW_POPUP && |
| 435 source_browser && source_browser->window()) { | 423 source_browser && source_browser->window()) { |
| 436 params->disposition = | 424 params->disposition = |
| 437 source_browser->window()->GetDispositionForPopupBounds( | 425 source_browser->window()->GetDispositionForPopupBounds( |
| 438 params->window_bounds); | 426 params->window_bounds); |
| 439 } | 427 } |
| 440 | 428 |
| 441 params->browser = GetBrowserForDisposition(params); | 429 params->browser = GetBrowserForDisposition(params); |
| 442 if (!params->browser) | 430 if (!params->browser) |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 bool reverse_on_redirect = false; | 661 bool reverse_on_redirect = false; |
| 674 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 662 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
| 675 &rewritten_url, browser_context, &reverse_on_redirect); | 663 &rewritten_url, browser_context, &reverse_on_redirect); |
| 676 | 664 |
| 677 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 665 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
| 678 return !(rewritten_url.scheme_piece() == content::kChromeUIScheme && | 666 return !(rewritten_url.scheme_piece() == content::kChromeUIScheme && |
| 679 rewritten_url.host_piece() == chrome::kChromeUIUberHost); | 667 rewritten_url.host_piece() == chrome::kChromeUIUberHost); |
| 680 } | 668 } |
| 681 | 669 |
| 682 } // namespace chrome | 670 } // namespace chrome |
| OLD | NEW |