| 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 "apps/shell_window.h" | 7 #include "apps/shell_window.h" |
| 8 #include "apps/shell_window_registry.h" | 8 #include "apps/shell_window_registry.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/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 WindowController* GetShellWindowController(const WebContents* contents) { | 45 WindowController* GetShellWindowController(const WebContents* contents) { |
| 46 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 46 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 47 apps::ShellWindowRegistry* registry = | 47 apps::ShellWindowRegistry* registry = |
| 48 apps::ShellWindowRegistry::Get(profile); | 48 apps::ShellWindowRegistry::Get(profile); |
| 49 if (!registry) | 49 if (!registry) |
| 50 return NULL; | 50 return NULL; |
| 51 ShellWindow* shell_window = | 51 ShellWindow* shell_window = |
| 52 registry->GetShellWindowForRenderViewHost(contents->GetRenderViewHost()); | 52 registry->GetShellWindowForRenderViewHost(contents->GetRenderViewHost()); |
| 53 if (!shell_window) | 53 if (!shell_window) |
| 54 return NULL; | 54 return NULL; |
| 55 return WindowControllerList::GetInstance()-> | 55 return WindowControllerList::GetInstance()->FindWindowById( |
| 56 FindWindowById(shell_window->session_id().id()); | 56 shell_window->session_id().id()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| 60 | 60 |
| 61 int ExtensionTabUtil::GetWindowId(const Browser* browser) { | 61 int ExtensionTabUtil::GetWindowId(const Browser* browser) { |
| 62 return browser->session_id().id(); | 62 return browser->session_id().id(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 int ExtensionTabUtil::GetWindowIdOfTabStripModel( | 65 int ExtensionTabUtil::GetWindowIdOfTabStripModel( |
| 66 const TabStripModel* tab_strip_model) { | 66 const TabStripModel* tab_strip_model) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 88 TabStripModel* tab_strip, | 88 TabStripModel* tab_strip, |
| 89 int tab_index, | 89 int tab_index, |
| 90 const Extension* extension) { | 90 const Extension* extension) { |
| 91 // If we have a matching ShellWindow with a controller, get the tab value | 91 // If we have a matching ShellWindow with a controller, get the tab value |
| 92 // from its controller instead. | 92 // from its controller instead. |
| 93 WindowController* controller = GetShellWindowController(contents); | 93 WindowController* controller = GetShellWindowController(contents); |
| 94 if (controller && | 94 if (controller && |
| 95 (!extension || controller->IsVisibleToExtension(extension))) { | 95 (!extension || controller->IsVisibleToExtension(extension))) { |
| 96 return controller->CreateTabValue(extension, tab_index); | 96 return controller->CreateTabValue(extension, tab_index); |
| 97 } | 97 } |
| 98 base::DictionaryValue *result = | 98 base::DictionaryValue* result = |
| 99 CreateTabValue(contents, tab_strip, tab_index); | 99 CreateTabValue(contents, tab_strip, tab_index); |
| 100 ScrubTabValueForExtension(contents, extension, result); | 100 ScrubTabValueForExtension(contents, extension, result); |
| 101 return result; | 101 return result; |
| 102 } | 102 } |
| 103 | 103 |
| 104 base::ListValue* ExtensionTabUtil::CreateTabList( | 104 base::ListValue* ExtensionTabUtil::CreateTabList( |
| 105 const Browser* browser, | 105 const Browser* browser, |
| 106 const Extension* extension) { | 106 const Extension* extension) { |
| 107 base::ListValue* tab_list = new base::ListValue(); | 107 base::ListValue* tab_list = new base::ListValue(); |
| 108 TabStripModel* tab_strip = browser->tab_strip_model(); | 108 TabStripModel* tab_strip = browser->tab_strip_model(); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 content::PAGE_TRANSITION_LINK, | 355 content::PAGE_TRANSITION_LINK, |
| 356 false); | 356 false); |
| 357 browser->OpenURL(params); | 357 browser->OpenURL(params); |
| 358 browser->window()->Show(); | 358 browser->window()->Show(); |
| 359 WebContents* web_contents = | 359 WebContents* web_contents = |
| 360 browser->tab_strip_model()->GetActiveWebContents(); | 360 browser->tab_strip_model()->GetActiveWebContents(); |
| 361 web_contents->GetDelegate()->ActivateContents(web_contents); | 361 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 362 } | 362 } |
| 363 | 363 |
| 364 } // namespace extensions | 364 } // namespace extensions |
| OLD | NEW |