| 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 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/ui/status_bubble.h" | 30 #include "chrome/browser/ui/status_bubble.h" |
| 31 #include "chrome/browser/ui/tab_helpers.h" | 31 #include "chrome/browser/ui/tab_helpers.h" |
| 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 34 #include "components/prefs/pref_service.h" | 34 #include "components/prefs/pref_service.h" |
| 35 #include "content/public/browser/browser_url_handler.h" | 35 #include "content/public/browser/browser_url_handler.h" |
| 36 #include "content/public/browser/navigation_entry.h" | 36 #include "content/public/browser/navigation_entry.h" |
| 37 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 38 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
| 39 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
| 40 #include "extensions/features/features.h" |
| 40 | 41 |
| 41 #if defined(USE_ASH) | 42 #if defined(USE_ASH) |
| 42 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 43 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 43 #include "components/signin/core/account_id/account_id.h" | 44 #include "components/signin/core/account_id/account_id.h" |
| 44 #endif | 45 #endif |
| 45 | 46 |
| 46 #if defined(USE_AURA) | 47 #if defined(USE_AURA) |
| 47 #include "ui/aura/window.h" | 48 #include "ui/aura/window.h" |
| 48 #endif | 49 #endif |
| 49 | 50 |
| 50 #if defined(ENABLE_EXTENSIONS) | 51 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 51 #include "chrome/browser/extensions/tab_helper.h" | 52 #include "chrome/browser/extensions/tab_helper.h" |
| 52 #include "chrome/browser/web_applications/web_app.h" | 53 #include "chrome/browser/web_applications/web_app.h" |
| 53 #include "extensions/browser/extension_registry.h" | 54 #include "extensions/browser/extension_registry.h" |
| 54 #include "extensions/common/extension.h" | 55 #include "extensions/common/extension.h" |
| 55 #include "extensions/common/extension_set.h" | 56 #include "extensions/common/extension_set.h" |
| 56 #endif | 57 #endif |
| 57 | 58 |
| 58 using content::GlobalRequestID; | 59 using content::GlobalRequestID; |
| 59 using content::NavigationController; | 60 using content::NavigationController; |
| 60 using content::WebContents; | 61 using content::WebContents; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // See if we can open the tab in the window this navigator is bound to. | 150 // See if we can open the tab in the window this navigator is bound to. |
| 150 if (params->browser && WindowCanOpenTabs(params->browser)) | 151 if (params->browser && WindowCanOpenTabs(params->browser)) |
| 151 return params->browser; | 152 return params->browser; |
| 152 // Find a compatible window and re-execute this command in it. Otherwise | 153 // Find a compatible window and re-execute this command in it. Otherwise |
| 153 // re-run with NEW_WINDOW. | 154 // re-run with NEW_WINDOW. |
| 154 return GetOrCreateBrowser(profile); | 155 return GetOrCreateBrowser(profile); |
| 155 case WindowOpenDisposition::NEW_POPUP: { | 156 case WindowOpenDisposition::NEW_POPUP: { |
| 156 // Make a new popup window. | 157 // Make a new popup window. |
| 157 // Coerce app-style if |source| represents an app. | 158 // Coerce app-style if |source| represents an app. |
| 158 std::string app_name; | 159 std::string app_name; |
| 159 #if defined(ENABLE_EXTENSIONS) | 160 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 160 if (!params->extension_app_id.empty()) { | 161 if (!params->extension_app_id.empty()) { |
| 161 app_name = web_app::GenerateApplicationNameFromExtensionId( | 162 app_name = web_app::GenerateApplicationNameFromExtensionId( |
| 162 params->extension_app_id); | 163 params->extension_app_id); |
| 163 } else if (params->browser && !params->browser->app_name().empty()) { | 164 } else if (params->browser && !params->browser->app_name().empty()) { |
| 164 app_name = params->browser->app_name(); | 165 app_name = params->browser->app_name(); |
| 165 } else if (params->source_contents) { | 166 } else if (params->source_contents) { |
| 166 extensions::TabHelper* extensions_tab_helper = | 167 extensions::TabHelper* extensions_tab_helper = |
| 167 extensions::TabHelper::FromWebContents(params->source_contents); | 168 extensions::TabHelper::FromWebContents(params->source_contents); |
| 168 if (extensions_tab_helper && extensions_tab_helper->is_app()) { | 169 if (extensions_tab_helper && extensions_tab_helper->is_app()) { |
| 169 app_name = web_app::GenerateApplicationNameFromExtensionId( | 170 app_name = web_app::GenerateApplicationNameFromExtensionId( |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 params.browser->window()->GetNativeWindow(); | 370 params.browser->window()->GetNativeWindow(); |
| 370 } | 371 } |
| 371 #endif | 372 #endif |
| 372 | 373 |
| 373 WebContents* target_contents = WebContents::Create(create_params); | 374 WebContents* target_contents = WebContents::Create(create_params); |
| 374 | 375 |
| 375 // New tabs can have WebUI URLs that will make calls back to arbitrary | 376 // New tabs can have WebUI URLs that will make calls back to arbitrary |
| 376 // tab helpers, so the entire set of tab helpers needs to be set up | 377 // tab helpers, so the entire set of tab helpers needs to be set up |
| 377 // immediately. | 378 // immediately. |
| 378 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); | 379 BrowserNavigatorWebContentsAdoption::AttachTabHelpers(target_contents); |
| 379 #if defined(ENABLE_EXTENSIONS) | 380 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 380 extensions::TabHelper::FromWebContents(target_contents)-> | 381 extensions::TabHelper::FromWebContents(target_contents)-> |
| 381 SetExtensionAppById(params.extension_app_id); | 382 SetExtensionAppById(params.extension_app_id); |
| 382 #endif | 383 #endif |
| 383 | 384 |
| 384 return target_contents; | 385 return target_contents; |
| 385 } | 386 } |
| 386 | 387 |
| 387 // If a prerendered page exists for |url|, replace the page at | 388 // If a prerendered page exists for |url|, replace the page at |
| 388 // |params->target_contents| with it and update to point to the swapped-in | 389 // |params->target_contents| with it and update to point to the swapped-in |
| 389 // WebContents. | 390 // WebContents. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 408 | 409 |
| 409 void Navigate(NavigateParams* params) { | 410 void Navigate(NavigateParams* params) { |
| 410 Browser* source_browser = params->browser; | 411 Browser* source_browser = params->browser; |
| 411 if (source_browser) | 412 if (source_browser) |
| 412 params->initiating_profile = source_browser->profile(); | 413 params->initiating_profile = source_browser->profile(); |
| 413 DCHECK(params->initiating_profile); | 414 DCHECK(params->initiating_profile); |
| 414 | 415 |
| 415 if (!AdjustNavigateParamsForURL(params)) | 416 if (!AdjustNavigateParamsForURL(params)) |
| 416 return; | 417 return; |
| 417 | 418 |
| 418 #if defined(ENABLE_EXTENSIONS) | 419 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 419 const extensions::Extension* extension = | 420 const extensions::Extension* extension = |
| 420 extensions::ExtensionRegistry::Get(params->initiating_profile)-> | 421 extensions::ExtensionRegistry::Get(params->initiating_profile)-> |
| 421 enabled_extensions().GetExtensionOrAppByURL(params->url); | 422 enabled_extensions().GetExtensionOrAppByURL(params->url); |
| 422 // Platform apps cannot navigate. Block the request. | 423 // Platform apps cannot navigate. Block the request. |
| 423 if (extension && extension->is_platform_app()) | 424 if (extension && extension->is_platform_app()) |
| 424 params->url = GURL(chrome::kExtensionInvalidRequestURL); | 425 params->url = GURL(chrome::kExtensionInvalidRequestURL); |
| 425 #endif | 426 #endif |
| 426 | 427 |
| 427 // The browser window may want to adjust the disposition. | 428 // The browser window may want to adjust the disposition. |
| 428 if (params->disposition == WindowOpenDisposition::NEW_POPUP && | 429 if (params->disposition == WindowOpenDisposition::NEW_POPUP && |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 bool reverse_on_redirect = false; | 668 bool reverse_on_redirect = false; |
| 668 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( | 669 content::BrowserURLHandler::GetInstance()->RewriteURLIfNecessary( |
| 669 &rewritten_url, browser_context, &reverse_on_redirect); | 670 &rewritten_url, browser_context, &reverse_on_redirect); |
| 670 | 671 |
| 671 // Some URLs are mapped to uber subpages. Do not allow them in incognito. | 672 // Some URLs are mapped to uber subpages. Do not allow them in incognito. |
| 672 return !(rewritten_url.scheme() == content::kChromeUIScheme && | 673 return !(rewritten_url.scheme() == content::kChromeUIScheme && |
| 673 rewritten_url.host() == chrome::kChromeUIUberHost); | 674 rewritten_url.host() == chrome::kChromeUIUberHost); |
| 674 } | 675 } |
| 675 | 676 |
| 676 } // namespace chrome | 677 } // namespace chrome |
| OLD | NEW |