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

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
« no previous file with comments | « chrome/browser/tab_contents/tab_util.h ('k') | chrome/browser/tabs/default_tab_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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::SiteInstance;
17 using content::WebContents; 18 using content::WebContents;
18 19
19 namespace tab_util { 20 namespace tab_util {
20 21
21 content::WebContents* GetWebContentsByID(int render_process_id, 22 content::WebContents* GetWebContentsByID(int render_process_id,
22 int render_view_id) { 23 int render_view_id) {
23 RenderViewHost* render_view_host = 24 RenderViewHost* render_view_host =
24 RenderViewHost::FromID(render_process_id, render_view_id); 25 RenderViewHost::FromID(render_process_id, render_view_id);
25 if (!render_view_host) 26 if (!render_view_host)
26 return NULL; 27 return NULL;
27 28
28 return render_view_host->delegate()->GetAsWebContents(); 29 return render_view_host->delegate()->GetAsWebContents();
29 } 30 }
30 31
31 SiteInstance* GetSiteInstanceForNewTab(WebContents* source_contents, 32 SiteInstance* GetSiteInstanceForNewTab(WebContents* source_contents,
32 Profile* profile, 33 Profile* profile,
33 const GURL& url) { 34 const GURL& url) {
34 // 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
35 // of renderer process up front. Otherwise, we create a normal SiteInstance 36 // of renderer process up front. Otherwise, we create a normal SiteInstance
36 // as part of creating the tab. 37 // as part of creating the tab.
37 ExtensionService* service = profile->GetExtensionService(); 38 ExtensionService* service = profile->GetExtensionService();
38 if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url) || 39 if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url) ||
39 (service && 40 (service &&
40 service->extensions()->GetHostedAppByURL(ExtensionURLInfo(url)))) { 41 service->extensions()->GetHostedAppByURL(ExtensionURLInfo(url)))) {
41 return SiteInstance::CreateSiteInstanceForURL(profile, url); 42 return SiteInstance::CreateForURL(profile, url);
42 } 43 }
43 44
44 if (!source_contents) 45 if (!source_contents)
45 return NULL; 46 return NULL;
46 47
47 // Don't use this logic when "--process-per-tab" is specified. 48 // Don't use this logic when "--process-per-tab" is specified.
48 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) && 49 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) &&
49 SiteInstance::IsSameWebSite(source_contents->GetBrowserContext(), 50 SiteInstance::IsSameWebSite(source_contents->GetBrowserContext(),
50 source_contents->GetURL(), 51 source_contents->GetURL(),
51 url)) { 52 url)) {
52 return source_contents->GetSiteInstance(); 53 return source_contents->GetSiteInstance();
53 } 54 }
54 return NULL; 55 return NULL;
55 } 56 }
56 57
57 } // namespace tab_util 58 } // namespace tab_util
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_util.h ('k') | chrome/browser/tabs/default_tab_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698