| 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/extensions/api/tabs/tabs_constants.h" | 7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 8 #include "chrome/browser/extensions/extension_tab_helper.h" | 8 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 9 #include "chrome/browser/net/url_fixer_upper.h" | 9 #include "chrome/browser/net/url_fixer_upper.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 return (fixed_url.SchemeIs(chrome::kChromeUIScheme) && | 219 return (fixed_url.SchemeIs(chrome::kChromeUIScheme) && |
| 220 (fixed_url.host() == chrome::kChromeUIBrowserCrashHost || | 220 (fixed_url.host() == chrome::kChromeUIBrowserCrashHost || |
| 221 fixed_url.host() == chrome::kChromeUICrashHost)); | 221 fixed_url.host() == chrome::kChromeUICrashHost)); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void ExtensionTabUtil::CreateTab(WebContents* web_contents, | 224 void ExtensionTabUtil::CreateTab(WebContents* web_contents, |
| 225 const std::string& extension_id, | 225 const std::string& extension_id, |
| 226 WindowOpenDisposition disposition, | 226 WindowOpenDisposition disposition, |
| 227 const gfx::Rect& initial_pos, | 227 const gfx::Rect& initial_pos, |
| 228 bool user_gesture) { | 228 bool user_gesture) { |
| 229 // Find a browser with a profile that matches the new tab. If none is found, | |
| 230 // NULL argument to NavigateParams is valid. | |
| 231 Profile* profile = | 229 Profile* profile = |
| 232 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 230 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 233 | 231 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); |
| 234 Browser* browser = browser::FindTabbedBrowser( | |
| 235 profile, false); // Match incognito exactly. | |
| 236 TabContents* tab_contents = new TabContents(web_contents); | 232 TabContents* tab_contents = new TabContents(web_contents); |
| 237 chrome::NavigateParams params(browser, tab_contents); | 233 chrome::NavigateParams params(browser, tab_contents); |
| 238 | 234 |
| 239 // The extension_app_id parameter ends up as app_name in the Browser | 235 // The extension_app_id parameter ends up as app_name in the Browser |
| 240 // which causes the Browser to return true for is_app(). This affects | 236 // which causes the Browser to return true for is_app(). This affects |
| 241 // among other things, whether the location bar gets displayed. | 237 // among other things, whether the location bar gets displayed. |
| 242 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted | 238 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted |
| 243 // in a tab? | 239 // in a tab? |
| 244 if (disposition == NEW_POPUP) | 240 if (disposition == NEW_POPUP) |
| 245 params.extension_app_id = extension_id; | 241 params.extension_app_id = extension_id; |
| 246 | 242 |
| 247 if (!browser) | |
| 248 params.profile = profile; | |
| 249 params.disposition = disposition; | 243 params.disposition = disposition; |
| 250 params.window_bounds = initial_pos; | 244 params.window_bounds = initial_pos; |
| 251 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 245 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 252 params.user_gesture = user_gesture; | 246 params.user_gesture = user_gesture; |
| 253 chrome::Navigate(¶ms); | 247 chrome::Navigate(¶ms); |
| 254 } | 248 } |
| OLD | NEW |