| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 return NULL; | 144 return NULL; |
| 145 } | 145 } |
| 146 browser = CreateBrowser(function, window_id, error); | 146 browser = CreateBrowser(function, window_id, error); |
| 147 if (!browser) | 147 if (!browser) |
| 148 return NULL; | 148 return NULL; |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Ensure the selected browser is tabbed. | 151 // Ensure the selected browser is tabbed. |
| 152 if (!browser->is_type_tabbed() && browser->IsAttemptingToCloseBrowser()) | 152 if (!browser->is_type_tabbed() && browser->IsAttemptingToCloseBrowser()) |
| 153 browser = chrome::FindTabbedBrowser(function->GetProfile(), | 153 browser = chrome::FindTabbedBrowser(function->GetProfile(), |
| 154 function->include_incognito(), | 154 function->include_incognito()); |
| 155 browser->host_desktop_type()); | |
| 156 | |
| 157 if (!browser || !browser->window()) { | 155 if (!browser || !browser->window()) { |
| 158 if (error) | 156 if (error) |
| 159 *error = keys::kNoCurrentWindowError; | 157 *error = keys::kNoCurrentWindowError; |
| 160 return NULL; | 158 return NULL; |
| 161 } | 159 } |
| 162 | 160 |
| 163 // TODO(jstritar): Add a constant, chrome.tabs.TAB_ID_ACTIVE, that | 161 // TODO(jstritar): Add a constant, chrome.tabs.TAB_ID_ACTIVE, that |
| 164 // represents the active tab. | 162 // represents the active tab. |
| 165 WebContents* opener = NULL; | 163 WebContents* opener = NULL; |
| 166 if (params.opener_tab_id.get()) { | 164 if (params.opener_tab_id.get()) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 pinned = *params.pinned; | 216 pinned = *params.pinned; |
| 219 | 217 |
| 220 // We can't load extension URLs into incognito windows unless the extension | 218 // We can't load extension URLs into incognito windows unless the extension |
| 221 // uses split mode. Special case to fall back to a tabbed window. | 219 // uses split mode. Special case to fall back to a tabbed window. |
| 222 if (url.SchemeIs(kExtensionScheme) && | 220 if (url.SchemeIs(kExtensionScheme) && |
| 223 !IncognitoInfo::IsSplitMode(function->extension()) && | 221 !IncognitoInfo::IsSplitMode(function->extension()) && |
| 224 browser->profile()->IsOffTheRecord()) { | 222 browser->profile()->IsOffTheRecord()) { |
| 225 Profile* profile = browser->profile()->GetOriginalProfile(); | 223 Profile* profile = browser->profile()->GetOriginalProfile(); |
| 226 chrome::HostDesktopType desktop_type = browser->host_desktop_type(); | 224 chrome::HostDesktopType desktop_type = browser->host_desktop_type(); |
| 227 | 225 |
| 228 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); | 226 browser = chrome::FindTabbedBrowser(profile, false); |
| 229 if (!browser) { | 227 if (!browser) { |
| 230 browser = new Browser( | 228 browser = new Browser( |
| 231 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); | 229 Browser::CreateParams(Browser::TYPE_TABBED, profile, desktop_type)); |
| 232 browser->window()->Show(); | 230 browser->window()->Show(); |
| 233 } | 231 } |
| 234 } | 232 } |
| 235 | 233 |
| 236 // If index is specified, honor the value, but keep it bound to | 234 // If index is specified, honor the value, but keep it bound to |
| 237 // -1 <= index <= tab_strip->count() where -1 invokes the default behavior. | 235 // -1 <= index <= tab_strip->count() where -1 invokes the default behavior. |
| 238 int index = -1; | 236 int index = -1; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 } | 586 } |
| 589 | 587 |
| 590 void ExtensionTabUtil::CreateTab(WebContents* web_contents, | 588 void ExtensionTabUtil::CreateTab(WebContents* web_contents, |
| 591 const std::string& extension_id, | 589 const std::string& extension_id, |
| 592 WindowOpenDisposition disposition, | 590 WindowOpenDisposition disposition, |
| 593 const gfx::Rect& initial_rect, | 591 const gfx::Rect& initial_rect, |
| 594 bool user_gesture) { | 592 bool user_gesture) { |
| 595 Profile* profile = | 593 Profile* profile = |
| 596 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 594 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 597 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); | 595 chrome::HostDesktopType active_desktop = chrome::GetActiveDesktop(); |
| 598 Browser* browser = chrome::FindTabbedBrowser(profile, false, active_desktop); | 596 Browser* browser = chrome::FindTabbedBrowser(profile, false); |
| 599 const bool browser_created = !browser; | 597 const bool browser_created = !browser; |
| 600 if (!browser) | 598 if (!browser) |
| 601 browser = new Browser(Browser::CreateParams(profile, active_desktop)); | 599 browser = new Browser(Browser::CreateParams(profile, active_desktop)); |
| 602 chrome::NavigateParams params(browser, web_contents); | 600 chrome::NavigateParams params(browser, web_contents); |
| 603 | 601 |
| 604 // The extension_app_id parameter ends up as app_name in the Browser | 602 // The extension_app_id parameter ends up as app_name in the Browser |
| 605 // which causes the Browser to return true for is_app(). This affects | 603 // which causes the Browser to return true for is_app(). This affects |
| 606 // among other things, whether the location bar gets displayed. | 604 // among other things, whether the location bar gets displayed. |
| 607 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted | 605 // TODO(mpcomplete): This seems wrong. What if the extension content is hosted |
| 608 // in a tab? | 606 // in a tab? |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 chrome::ShowSingletonTabOverwritingNTP(browser, params); | 672 chrome::ShowSingletonTabOverwritingNTP(browser, params); |
| 675 return true; | 673 return true; |
| 676 } | 674 } |
| 677 | 675 |
| 678 // static | 676 // static |
| 679 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { | 677 bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { |
| 680 return browser && browser->tab_strip_model() && !browser->is_devtools(); | 678 return browser && browser->tab_strip_model() && !browser->is_devtools(); |
| 681 } | 679 } |
| 682 | 680 |
| 683 } // namespace extensions | 681 } // namespace extensions |
| OLD | NEW |