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/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 9 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "content/browser/renderer_host/render_view_host.h" | 11 #include "content/browser/renderer_host/render_view_host.h" |
12 #include "content/public/browser/render_view_host_delegate.h" | 12 #include "content/public/browser/render_view_host_delegate.h" |
13 #include "content/public/browser/site_instance.h" | 13 #include "content/public/browser/site_instance.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 | 16 |
17 using content::SiteInstance; | 17 using content::SiteInstance; |
18 using content::WebContents; | 18 using content::WebContents; |
19 | 19 |
20 namespace tab_util { | 20 namespace tab_util { |
21 | 21 |
22 content::WebContents* GetWebContentsByID(int render_process_id, | 22 content::WebContents* GetWebContentsByID(int render_process_id, |
23 int render_view_id) { | 23 int render_view_id) { |
24 RenderViewHost* render_view_host = | 24 RenderViewHost* render_view_host = |
25 RenderViewHost::FromID(render_process_id, render_view_id); | 25 RenderViewHost::FromID(render_process_id, render_view_id); |
26 if (!render_view_host) | 26 if (!render_view_host) |
27 return NULL; | 27 return NULL; |
28 | 28 |
29 return render_view_host->delegate()->GetAsWebContents(); | 29 return render_view_host->GetDelegate()->GetAsWebContents(); |
30 } | 30 } |
31 | 31 |
32 SiteInstance* GetSiteInstanceForNewTab(WebContents* source_contents, | 32 SiteInstance* GetSiteInstanceForNewTab(WebContents* source_contents, |
33 Profile* profile, | 33 Profile* profile, |
34 const GURL& url) { | 34 const GURL& url) { |
35 // If url is a WebUI or extension, we need to be sure to use the right type | 35 // If url is a WebUI or extension, we need to be sure to use the right type |
36 // of renderer process up front. Otherwise, we create a normal SiteInstance | 36 // of renderer process up front. Otherwise, we create a normal SiteInstance |
37 // as part of creating the tab. | 37 // as part of creating the tab. |
38 ExtensionService* service = profile->GetExtensionService(); | 38 ExtensionService* service = profile->GetExtensionService(); |
39 if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL( | 39 if (ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL( |
(...skipping 10 matching lines...) Expand all Loading... |
50 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) && | 50 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) && |
51 SiteInstance::IsSameWebSite(source_contents->GetBrowserContext(), | 51 SiteInstance::IsSameWebSite(source_contents->GetBrowserContext(), |
52 source_contents->GetURL(), | 52 source_contents->GetURL(), |
53 url)) { | 53 url)) { |
54 return source_contents->GetSiteInstance(); | 54 return source_contents->GetSiteInstance(); |
55 } | 55 } |
56 return NULL; | 56 return NULL; |
57 } | 57 } |
58 | 58 |
59 } // namespace tab_util | 59 } // namespace tab_util |
OLD | NEW |