OLD | NEW |
1 // Copyright (c) 2011 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/ui/browser_navigator.h" | 5 #include "chrome/browser/ui/browser_navigator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "chrome/browser/browser_url_handler.h" | 10 #include "chrome/browser/browser_url_handler.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/extensions/extension_tab_helper.h" | 12 #include "chrome/browser/extensions/extension_tab_helper.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/tabs/tab_strip_model.h" | 14 #include "chrome/browser/tabs/tab_strip_model.h" |
14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_list.h" | 16 #include "chrome/browser/ui/browser_list.h" |
16 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
17 #include "chrome/browser/ui/omnibox/location_bar.h" | 18 #include "chrome/browser/ui/omnibox/location_bar.h" |
18 #include "chrome/browser/ui/status_bubble.h" | 19 #include "chrome/browser/ui/status_bubble.h" |
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
20 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" | 21 #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" |
21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/extensions/extension.h" | 23 #include "chrome/common/extensions/extension.h" |
23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
24 #include "content/browser/site_instance.h" | 25 #include "content/browser/site_instance.h" |
25 #include "content/browser/tab_contents/tab_contents.h" | 26 #include "content/browser/tab_contents/tab_contents.h" |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 // Returns an appropriate SiteInstance for WebUI URLs, or the SiteInstance for | 30 // Returns an appropriate SiteInstance for WebUI URLs, or the SiteInstance for |
30 // |source_contents| if it represents the same website as |url|. Returns NULL | 31 // |source_contents| if it represents the same website as |url|. Returns NULL |
31 // otherwise. | 32 // otherwise. |
32 SiteInstance* GetSiteInstance(TabContents* source_contents, Profile* profile, | 33 SiteInstance* GetSiteInstance(TabContents* source_contents, 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 if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url)) | 38 ExtensionService* service = profile->GetExtensionService(); |
| 39 if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url) || |
| 40 (service && service->GetExtensionByWebExtent(url))) { |
38 return SiteInstance::CreateSiteInstanceForURL(profile, url); | 41 return SiteInstance::CreateSiteInstanceForURL(profile, url); |
| 42 } |
39 | 43 |
40 if (!source_contents) | 44 if (!source_contents) |
41 return NULL; | 45 return NULL; |
42 | 46 |
43 // Don't use this logic when "--process-per-tab" is specified. | 47 // Don't use this logic when "--process-per-tab" is specified. |
44 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) && | 48 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) && |
45 SiteInstance::IsSameWebSite(source_contents->profile(), | 49 SiteInstance::IsSameWebSite(source_contents->profile(), |
46 source_contents->GetURL(), | 50 source_contents->GetURL(), |
47 url)) { | 51 url)) { |
48 return source_contents->GetSiteInstance(); | 52 return source_contents->GetSiteInstance(); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 params->url, params->referrer, params->transition); | 521 params->url, params->referrer, params->transition); |
518 } | 522 } |
519 | 523 |
520 // If the singleton tab isn't already selected, select it. | 524 // If the singleton tab isn't already selected, select it. |
521 if (params->source_contents != params->target_contents) | 525 if (params->source_contents != params->target_contents) |
522 params->browser->ActivateTabAt(singleton_index, user_initiated); | 526 params->browser->ActivateTabAt(singleton_index, user_initiated); |
523 } | 527 } |
524 } | 528 } |
525 | 529 |
526 } // namespace browser | 530 } // namespace browser |
OLD | NEW |