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( | |
Ken Rockot(use gerrit already)
2014/09/05 19:55:31
Alternatively I guess CEFDetails could provide a p
| |
282 ExtensionFunction* function, | |
283 const ChromeExtensionFunctionDetails& details, | |
284 int window_id, | |
285 std::string* error) { | |
286 if (window_id == extension_misc::kCurrentWindowId) { | |
287 Browser* result = details.GetCurrentBrowser(); | |
288 if (!result || !result->window()) { | |
289 if (error) | |
290 *error = keys::kNoCurrentWindowError; | |
291 return NULL; | |
292 } | |
293 return result; | |
294 } else { | |
295 return GetBrowserInProfileWithId( | |
296 details.GetProfile(), window_id, function->include_incognito(), error); | |
297 } | |
298 } | |
299 | |
280 int ExtensionTabUtil::GetWindowId(const Browser* browser) { | 300 int ExtensionTabUtil::GetWindowId(const Browser* browser) { |
281 return browser->session_id().id(); | 301 return browser->session_id().id(); |
282 } | 302 } |
283 | 303 |
284 int ExtensionTabUtil::GetWindowIdOfTabStripModel( | 304 int ExtensionTabUtil::GetWindowIdOfTabStripModel( |
285 const TabStripModel* tab_strip_model) { | 305 const TabStripModel* tab_strip_model) { |
286 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 306 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
287 if (it->tab_strip_model() == tab_strip_model) | 307 if (it->tab_strip_model() == tab_strip_model) |
288 return GetWindowId(*it); | 308 return GetWindowId(*it); |
289 } | 309 } |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 false); | 612 false); |
593 browser->OpenURL(params); | 613 browser->OpenURL(params); |
594 browser->window()->Show(); | 614 browser->window()->Show(); |
595 WebContents* web_contents = | 615 WebContents* web_contents = |
596 browser->tab_strip_model()->GetActiveWebContents(); | 616 browser->tab_strip_model()->GetActiveWebContents(); |
597 web_contents->GetDelegate()->ActivateContents(web_contents); | 617 web_contents->GetDelegate()->ActivateContents(web_contents); |
598 } | 618 } |
599 } | 619 } |
600 | 620 |
601 } // namespace extensions | 621 } // namespace extensions |
OLD | NEW |