| 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/tab_contents/tab_util.h" | 5 #include "chrome/browser/tab_contents/tab_util.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 8 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "content/public/browser/render_frame_host.h" | 10 #include "content/public/browser/render_frame_host.h" |
| 11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
| 12 #include "content/public/browser/site_instance.h" | 12 #include "content/public/browser/site_instance.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "extensions/features/features.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 #if defined(ENABLE_EXTENSIONS) | 17 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 17 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 using content::RenderFrameHost; | 21 using content::RenderFrameHost; |
| 21 using content::RenderViewHost; | 22 using content::RenderViewHost; |
| 22 using content::SiteInstance; | 23 using content::SiteInstance; |
| 23 using content::WebContents; | 24 using content::WebContents; |
| 24 | 25 |
| 25 namespace tab_util { | 26 namespace tab_util { |
| 26 | 27 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 return WebContents::FromRenderFrameHost(render_frame_host); | 43 return WebContents::FromRenderFrameHost(render_frame_host); |
| 43 } | 44 } |
| 44 | 45 |
| 45 scoped_refptr<SiteInstance> GetSiteInstanceForNewTab(Profile* profile, | 46 scoped_refptr<SiteInstance> GetSiteInstanceForNewTab(Profile* profile, |
| 46 const GURL& url) { | 47 const GURL& url) { |
| 47 // If |url| is a WebUI or extension, we set the SiteInstance up front so that | 48 // If |url| is a WebUI or extension, we set the SiteInstance up front so that |
| 48 // we don't end up with an extra process swap on the first navigation. | 49 // we don't end up with an extra process swap on the first navigation. |
| 49 if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(profile, url)) | 50 if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(profile, url)) |
| 50 return SiteInstance::CreateForURL(profile, url); | 51 return SiteInstance::CreateForURL(profile, url); |
| 51 | 52 |
| 52 #if defined(ENABLE_EXTENSIONS) | 53 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 53 if (extensions::ExtensionRegistry::Get( | 54 if (extensions::ExtensionRegistry::Get( |
| 54 profile)->enabled_extensions().GetHostedAppByURL(url)) | 55 profile)->enabled_extensions().GetHostedAppByURL(url)) |
| 55 return SiteInstance::CreateForURL(profile, url); | 56 return SiteInstance::CreateForURL(profile, url); |
| 56 #endif | 57 #endif |
| 57 | 58 |
| 58 // We used to share the SiteInstance for same-site links opened in new tabs, | 59 // We used to share the SiteInstance for same-site links opened in new tabs, |
| 59 // to leverage the in-memory cache and reduce process creation. It now | 60 // to leverage the in-memory cache and reduce process creation. It now |
| 60 // appears that it is more useful to have such links open in a new process, | 61 // appears that it is more useful to have such links open in a new process, |
| 61 // so we create new tabs in a new BrowsingInstance. | 62 // so we create new tabs in a new BrowsingInstance. |
| 62 return nullptr; | 63 return nullptr; |
| 63 } | 64 } |
| 64 | 65 |
| 65 } // namespace tab_util | 66 } // namespace tab_util |
| OLD | NEW |