Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Side by Side Diff: chrome/browser/tab_contents/tab_util.cc

Issue 9146028: Define the public interface for content browser SiteInstance. This interface is implemented by th... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_factory.h" 9 #include "chrome/browser/ui/webui/chrome_web_ui_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/browser/site_instance.h"
13 #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"
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::WebContents; 17 using content::WebContents;
jam 2012/01/24 03:29:33 nit: "using content::SiteInstance" to remove all t
ananta 2012/01/24 23:46:26 Done.
18 18
19 namespace tab_util { 19 namespace tab_util {
20 20
21 TabContents* GetTabContentsByID(int render_process_id, int render_view_id) { 21 TabContents* GetTabContentsByID(int render_process_id, int render_view_id) {
22 RenderViewHost* render_view_host = 22 RenderViewHost* render_view_host =
23 RenderViewHost::FromID(render_process_id, render_view_id); 23 RenderViewHost::FromID(render_process_id, render_view_id);
24 if (!render_view_host) 24 if (!render_view_host)
25 return NULL; 25 return NULL;
26 26
27 return render_view_host->delegate()->GetAsTabContents(); 27 return render_view_host->delegate()->GetAsTabContents();
28 } 28 }
29 29
30 content::WebContents* GetWebContentsByID(int render_process_id, 30 content::WebContents* GetWebContentsByID(int render_process_id,
31 int render_view_id) { 31 int render_view_id) {
32 RenderViewHost* render_view_host = 32 RenderViewHost* render_view_host =
33 RenderViewHost::FromID(render_process_id, render_view_id); 33 RenderViewHost::FromID(render_process_id, render_view_id);
34 if (!render_view_host) 34 if (!render_view_host)
35 return NULL; 35 return NULL;
36 36
37 return render_view_host->delegate()->GetAsWebContents(); 37 return render_view_host->delegate()->GetAsWebContents();
38 } 38 }
39 39
40 SiteInstance* GetSiteInstanceForNewTab(WebContents* source_contents, 40 content::SiteInstance* GetSiteInstanceForNewTab(WebContents* source_contents,
41 Profile* profile, 41 Profile* profile,
42 const GURL& url) { 42 const GURL& url) {
43 // If url is a WebUI or extension, we need to be sure to use the right type 43 // If url is a WebUI or extension, we need to be sure to use the right type
44 // of renderer process up front. Otherwise, we create a normal SiteInstance 44 // of renderer process up front. Otherwise, we create a normal SiteInstance
45 // as part of creating the tab. 45 // as part of creating the tab.
46 ExtensionService* service = profile->GetExtensionService(); 46 ExtensionService* service = profile->GetExtensionService();
47 if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url) || 47 if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url) ||
48 (service && 48 (service &&
49 service->extensions()->GetHostedAppByURL(ExtensionURLInfo(url)))) { 49 service->extensions()->GetHostedAppByURL(ExtensionURLInfo(url)))) {
50 return SiteInstance::CreateSiteInstanceForURL(profile, url); 50 return content::SiteInstance::CreateSiteInstanceForURL(profile, url);
51 } 51 }
52 52
53 if (!source_contents) 53 if (!source_contents)
54 return NULL; 54 return NULL;
55 55
56 // Don't use this logic when "--process-per-tab" is specified. 56 // Don't use this logic when "--process-per-tab" is specified.
57 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) && 57 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) &&
58 SiteInstance::IsSameWebSite(source_contents->GetBrowserContext(), 58 content::SiteInstance::IsSameWebSite(
59 source_contents->GetURL(), 59 source_contents->GetBrowserContext(),
60 url)) { 60 source_contents->GetURL(),
61 url)) {
61 return source_contents->GetSiteInstance(); 62 return source_contents->GetSiteInstance();
62 } 63 }
63 return NULL; 64 return NULL;
64 } 65 }
65 66
66 } // namespace tab_util 67 } // namespace tab_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698