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 "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
10 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 11 #include "chrome/browser/extensions/chrome_extension_function_details.h" |
11 #include "chrome/browser/extensions/tab_helper.h" | 12 #include "chrome/browser/extensions/tab_helper.h" |
12 #include "chrome/browser/extensions/window_controller.h" | 13 #include "chrome/browser/extensions/window_controller.h" |
13 #include "chrome/browser/extensions/window_controller_list.h" | 14 #include "chrome/browser/extensions/window_controller_list.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/sessions/session_tab_helper.h" | 16 #include "chrome/browser/sessions/session_tab_helper.h" |
16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
18 #include "chrome/browser/ui/browser_iterator.h" | 19 #include "chrome/browser/ui/browser_iterator.h" |
19 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
20 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 21 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 271 } |
271 return result; | 272 return result; |
272 } else { | 273 } else { |
273 return GetBrowserInProfileWithId(function->GetProfile(), | 274 return GetBrowserInProfileWithId(function->GetProfile(), |
274 window_id, | 275 window_id, |
275 function->include_incognito(), | 276 function->include_incognito(), |
276 error); | 277 error); |
277 } | 278 } |
278 } | 279 } |
279 | 280 |
| 281 Browser* ExtensionTabUtil::GetBrowserFromWindowID( |
| 282 const ChromeExtensionFunctionDetails& details, |
| 283 int window_id, |
| 284 std::string* error) { |
| 285 if (window_id == extension_misc::kCurrentWindowId) { |
| 286 Browser* result = details.GetCurrentBrowser(); |
| 287 if (!result || !result->window()) { |
| 288 if (error) |
| 289 *error = keys::kNoCurrentWindowError; |
| 290 return NULL; |
| 291 } |
| 292 return result; |
| 293 } else { |
| 294 return GetBrowserInProfileWithId(details.GetProfile(), |
| 295 window_id, |
| 296 details.function()->include_incognito(), |
| 297 error); |
| 298 } |
| 299 } |
| 300 |
280 int ExtensionTabUtil::GetWindowId(const Browser* browser) { | 301 int ExtensionTabUtil::GetWindowId(const Browser* browser) { |
281 return browser->session_id().id(); | 302 return browser->session_id().id(); |
282 } | 303 } |
283 | 304 |
284 int ExtensionTabUtil::GetWindowIdOfTabStripModel( | 305 int ExtensionTabUtil::GetWindowIdOfTabStripModel( |
285 const TabStripModel* tab_strip_model) { | 306 const TabStripModel* tab_strip_model) { |
286 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 307 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
287 if (it->tab_strip_model() == tab_strip_model) | 308 if (it->tab_strip_model() == tab_strip_model) |
288 return GetWindowId(*it); | 309 return GetWindowId(*it); |
289 } | 310 } |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 false); | 613 false); |
593 browser->OpenURL(params); | 614 browser->OpenURL(params); |
594 browser->window()->Show(); | 615 browser->window()->Show(); |
595 WebContents* web_contents = | 616 WebContents* web_contents = |
596 browser->tab_strip_model()->GetActiveWebContents(); | 617 browser->tab_strip_model()->GetActiveWebContents(); |
597 web_contents->GetDelegate()->ActivateContents(web_contents); | 618 web_contents->GetDelegate()->ActivateContents(web_contents); |
598 } | 619 } |
599 } | 620 } |
600 | 621 |
601 } // namespace extensions | 622 } // namespace extensions |
OLD | NEW |