| 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_list.h" | 10 #include "chrome/browser/browser_list.h" |
| 11 #include "chrome/browser/browser_url_handler.h" | 11 #include "chrome/browser/browser_url_handler.h" |
| 12 #include "chrome/browser/browser_window.h" | 12 #include "chrome/browser/browser_window.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/tabs/tab_strip_model.h" | 14 #include "chrome/browser/tabs/tab_strip_model.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/status_bubble.h" | 16 #include "chrome/browser/ui/status_bubble.h" |
| 17 #include "chrome/browser/ui/omnibox/location_bar.h" | 17 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 19 #include "chrome/browser/ui/webui/web_ui_factory.h" |
| 19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 21 #include "content/browser/site_instance.h" | 22 #include "content/browser/site_instance.h" |
| 22 #include "content/browser/tab_contents/tab_contents.h" | 23 #include "content/browser/tab_contents/tab_contents.h" |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // Returns an appropriate SiteInstance for WebUI URLs, or the SiteInstance for | 27 // Returns an appropriate SiteInstance for WebUI URLs, or the SiteInstance for |
| 27 // |source_contents| if it represents the same website as |url|. Returns NULL | 28 // |source_contents| if it represents the same website as |url|. Returns NULL |
| 28 // otherwise. | 29 // otherwise. |
| 29 SiteInstance* GetSiteInstance(TabContents* source_contents, Profile* profile, | 30 SiteInstance* GetSiteInstance(TabContents* source_contents, Profile* profile, |
| 30 const GURL& url) { | 31 const GURL& url) { |
| 31 // If url is a WebUI or extension, we need to be sure to use the right type | 32 // 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 // of renderer process up front. Otherwise, we create a normal SiteInstance |
| 33 // as part of creating the tab. | 34 // as part of creating the tab. |
| 34 if (WebUIFactory::UseWebUIForURL(profile, url)) | 35 if (WebUIFactory::GetInstance()->UseWebUIForURL(profile, url)) |
| 35 return SiteInstance::CreateSiteInstanceForURL(profile, url); | 36 return SiteInstance::CreateSiteInstanceForURL(profile, url); |
| 36 | 37 |
| 37 if (!source_contents) | 38 if (!source_contents) |
| 38 return NULL; | 39 return NULL; |
| 39 | 40 |
| 40 // Don't use this logic when "--process-per-tab" is specified. | 41 // Don't use this logic when "--process-per-tab" is specified. |
| 41 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) && | 42 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab) && |
| 42 SiteInstance::IsSameWebSite(source_contents->profile(), | 43 SiteInstance::IsSameWebSite(source_contents->profile(), |
| 43 source_contents->GetURL(), | 44 source_contents->GetURL(), |
| 44 url)) { | 45 url)) { |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 params->url, params->referrer, params->transition); | 486 params->url, params->referrer, params->transition); |
| 486 } | 487 } |
| 487 | 488 |
| 488 // If the singleton tab isn't already selected, select it. | 489 // If the singleton tab isn't already selected, select it. |
| 489 if (params->source_contents != params->target_contents) | 490 if (params->source_contents != params->target_contents) |
| 490 params->browser->SelectTabContentsAt(singleton_index, user_initiated); | 491 params->browser->SelectTabContentsAt(singleton_index, user_initiated); |
| 491 } | 492 } |
| 492 } | 493 } |
| 493 | 494 |
| 494 } // namespace browser | 495 } // namespace browser |
| OLD | NEW |