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

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

Issue 7448012: Create the correct SiteInstance when restoring tabs that belong to apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix style. Created 9 years, 5 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/ui/browser.cc » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h"
10 #include "chrome/common/chrome_switches.h"
7 #include "content/browser/renderer_host/render_process_host.h" 11 #include "content/browser/renderer_host/render_process_host.h"
8 #include "content/browser/renderer_host/render_view_host.h" 12 #include "content/browser/renderer_host/render_view_host.h"
13 #include "content/browser/site_instance.h"
9 #include "content/browser/tab_contents/tab_contents.h" 14 #include "content/browser/tab_contents/tab_contents.h"
15 #include "googleurl/src/gurl.h"
10 16
11 TabContents* tab_util::GetTabContentsByID(int render_process_id, 17 namespace tab_util {
12 int render_view_id) { 18
19 TabContents* GetTabContentsByID(int render_process_id, int render_view_id) {
13 RenderViewHost* render_view_host = 20 RenderViewHost* render_view_host =
14 RenderViewHost::FromID(render_process_id, render_view_id); 21 RenderViewHost::FromID(render_process_id, render_view_id);
15 if (!render_view_host) 22 if (!render_view_host)
16 return NULL; 23 return NULL;
17 24
18 return render_view_host->delegate()->GetAsTabContents(); 25 return render_view_host->delegate()->GetAsTabContents();
19 } 26 }
27
28 SiteInstance* GetSiteInstanceForNewTab(TabContents* source_contents,
29 Profile* profile,
30 const GURL& url) {
31 // If url is a WebUI or extension, we need to be sure to use the right type
32 // of renderer process up front. Otherwise, we create a normal SiteInstance
33 // as part of creating the tab.
34 ExtensionService* service = profile->GetExtensionService();
35 if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url) ||
36 (service && service->GetExtensionByWebExtent(url))) {
37 return SiteInstance::CreateSiteInstanceForURL(profile, url);
38 }
39
40 if (!source_contents)
41 return NULL;
42
43 // Don't use this logic when "--process-per-tab" is specified.
44 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) &&
45 SiteInstance::IsSameWebSite(source_contents->profile(),
46 source_contents->GetURL(),
47 url)) {
48 return source_contents->GetSiteInstance();
49 }
50 return NULL;
51 }
52
53 } // namespace tab_util
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_util.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698