| 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" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 TabStripModel* tab_strip = browser->tab_strip_model(); | 227 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 228 | 228 |
| 229 index = std::min(std::max(index, -1), tab_strip->count()); | 229 index = std::min(std::max(index, -1), tab_strip->count()); |
| 230 | 230 |
| 231 int add_types = active ? TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE; | 231 int add_types = active ? TabStripModel::ADD_ACTIVE : TabStripModel::ADD_NONE; |
| 232 add_types |= TabStripModel::ADD_FORCE_INDEX; | 232 add_types |= TabStripModel::ADD_FORCE_INDEX; |
| 233 if (pinned) | 233 if (pinned) |
| 234 add_types |= TabStripModel::ADD_PINNED; | 234 add_types |= TabStripModel::ADD_PINNED; |
| 235 chrome::NavigateParams navigate_params( | 235 chrome::NavigateParams navigate_params( |
| 236 browser, url, content::PAGE_TRANSITION_LINK); | 236 browser, url, ui::PAGE_TRANSITION_LINK); |
| 237 navigate_params.disposition = | 237 navigate_params.disposition = |
| 238 active ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; | 238 active ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
| 239 navigate_params.tabstrip_index = index; | 239 navigate_params.tabstrip_index = index; |
| 240 navigate_params.tabstrip_add_types = add_types; | 240 navigate_params.tabstrip_add_types = add_types; |
| 241 chrome::Navigate(&navigate_params); | 241 chrome::Navigate(&navigate_params); |
| 242 | 242 |
| 243 // The tab may have been created in a different window, so make sure we look | 243 // The tab may have been created in a different window, so make sure we look |
| 244 // at the right tab strip. | 244 // at the right tab strip. |
| 245 tab_strip = navigate_params.browser->tab_strip_model(); | 245 tab_strip = navigate_params.browser->tab_strip_model(); |
| 246 int new_index = | 246 int new_index = |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 base::StringPrintf("options=%s", extension->id().c_str()); | 603 base::StringPrintf("options=%s", extension->id().c_str()); |
| 604 replacements.SetQueryStr(query); | 604 replacements.SetQueryStr(query); |
| 605 params.url = params.url.ReplaceComponents(replacements); | 605 params.url = params.url.ReplaceComponents(replacements); |
| 606 | 606 |
| 607 chrome::ShowSingletonTabOverwritingNTP(browser, params); | 607 chrome::ShowSingletonTabOverwritingNTP(browser, params); |
| 608 } else { | 608 } else { |
| 609 // Otherwise open a new tab with the extension's options page | 609 // Otherwise open a new tab with the extension's options page |
| 610 content::OpenURLParams params(OptionsPageInfo::GetOptionsPage(extension), | 610 content::OpenURLParams params(OptionsPageInfo::GetOptionsPage(extension), |
| 611 content::Referrer(), | 611 content::Referrer(), |
| 612 SINGLETON_TAB, | 612 SINGLETON_TAB, |
| 613 content::PAGE_TRANSITION_LINK, | 613 ui::PAGE_TRANSITION_LINK, |
| 614 false); | 614 false); |
| 615 browser->OpenURL(params); | 615 browser->OpenURL(params); |
| 616 browser->window()->Show(); | 616 browser->window()->Show(); |
| 617 WebContents* web_contents = | 617 WebContents* web_contents = |
| 618 browser->tab_strip_model()->GetActiveWebContents(); | 618 browser->tab_strip_model()->GetActiveWebContents(); |
| 619 web_contents->GetDelegate()->ActivateContents(web_contents); | 619 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 620 } | 620 } |
| 621 } | 621 } |
| 622 | 622 |
| 623 } // namespace extensions | 623 } // namespace extensions |
| OLD | NEW |