| OLD | NEW |
| 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/extensions/extension_tab_util.h" | 5 #include "chrome/browser/extensions/extension_tab_util.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/tabs/tab_strip_model.h" | 9 #include "chrome/browser/tabs/tab_strip_model.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 13 #include "chrome/browser/sessions/restore_tab_helper.h" | 13 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 14 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 14 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
| 15 #include "chrome/browser/net/url_fixer_upper.h" |
| 16 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/common/url_constants.h" |
| 15 #include "content/public/browser/favicon_status.h" | 18 #include "content/public/browser/favicon_status.h" |
| 16 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "googleurl/src/gurl.h" |
| 18 | 22 |
| 19 namespace keys = extension_tabs_module_constants; | 23 namespace keys = extension_tabs_module_constants; |
| 20 namespace errors = extension_manifest_errors; | 24 namespace errors = extension_manifest_errors; |
| 21 | 25 |
| 22 using content::NavigationEntry; | 26 using content::NavigationEntry; |
| 23 using content::WebContents; | 27 using content::WebContents; |
| 24 | 28 |
| 25 int ExtensionTabUtil::GetWindowId(const Browser* browser) { | 29 int ExtensionTabUtil::GetWindowId(const Browser* browser) { |
| 26 return browser->session_id().id(); | 30 return browser->session_id().id(); |
| 27 } | 31 } |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 *contents = target_contents; | 220 *contents = target_contents; |
| 217 if (tab_index) | 221 if (tab_index) |
| 218 *tab_index = i; | 222 *tab_index = i; |
| 219 return true; | 223 return true; |
| 220 } | 224 } |
| 221 } | 225 } |
| 222 } | 226 } |
| 223 } | 227 } |
| 224 return false; | 228 return false; |
| 225 } | 229 } |
| 230 |
| 231 GURL ExtensionTabUtil::ResolvePossiblyRelativeURL(const std::string& url_string, |
| 232 const Extension* extension) { |
| 233 GURL url = GURL(url_string); |
| 234 if (!url.is_valid()) |
| 235 url = extension->GetResourceURL(url_string); |
| 236 |
| 237 return url; |
| 238 } |
| 239 |
| 240 bool ExtensionTabUtil::IsCrashURL(const GURL& url) { |
| 241 // Check a fixed-up URL, to normalize the scheme and parse hosts correctly. |
| 242 GURL fixed_url = |
| 243 URLFixerUpper::FixupURL(url.possibly_invalid_spec(), std::string()); |
| 244 return (fixed_url.SchemeIs(chrome::kChromeUIScheme) && |
| 245 (fixed_url.host() == chrome::kChromeUIBrowserCrashHost || |
| 246 fixed_url.host() == chrome::kChromeUICrashHost)); |
| 247 } |
| OLD | NEW |