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_tabs_module.h" | 5 #include "chrome/browser/extensions/extension_tabs_module.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 TabStripModel::ADD_NONE; | 954 TabStripModel::ADD_NONE; |
955 add_types |= TabStripModel::ADD_FORCE_INDEX; | 955 add_types |= TabStripModel::ADD_FORCE_INDEX; |
956 if (pinned) | 956 if (pinned) |
957 add_types |= TabStripModel::ADD_PINNED; | 957 add_types |= TabStripModel::ADD_PINNED; |
958 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_LINK); | 958 browser::NavigateParams params(browser, url, content::PAGE_TRANSITION_LINK); |
959 params.disposition = active ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; | 959 params.disposition = active ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
960 params.tabstrip_index = index; | 960 params.tabstrip_index = index; |
961 params.tabstrip_add_types = add_types; | 961 params.tabstrip_add_types = add_types; |
962 browser::Navigate(¶ms); | 962 browser::Navigate(¶ms); |
963 | 963 |
| 964 // The tab may have been created in a different window, so make sure we look |
| 965 // at the right tab strip. |
| 966 tab_strip = params.browser->tabstrip_model(); |
964 int new_index = tab_strip->GetIndexOfTabContents(params.target_contents); | 967 int new_index = tab_strip->GetIndexOfTabContents(params.target_contents); |
965 if (opener) | 968 if (opener) |
966 tab_strip->SetOpenerOfTabContentsAt(new_index, opener); | 969 tab_strip->SetOpenerOfTabContentsAt(new_index, opener); |
967 | 970 |
968 if (active) | 971 if (active) |
969 params.target_contents->web_contents()->GetView()->SetInitialFocus(); | 972 params.target_contents->web_contents()->GetView()->SetInitialFocus(); |
970 | 973 |
971 // Return data about the newly created tab. | 974 // Return data about the newly created tab. |
972 if (has_callback()) { | 975 if (has_callback()) { |
973 result_.reset(ExtensionTabUtil::CreateTabValue( | 976 result_.reset(ExtensionTabUtil::CreateTabValue( |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 // called for every API call the extension made. | 1708 // called for every API call the extension made. |
1706 GotLanguage(language); | 1709 GotLanguage(language); |
1707 } | 1710 } |
1708 | 1711 |
1709 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1712 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1710 result_.reset(Value::CreateStringValue(language.c_str())); | 1713 result_.reset(Value::CreateStringValue(language.c_str())); |
1711 SendResponse(true); | 1714 SendResponse(true); |
1712 | 1715 |
1713 Release(); // Balanced in Run() | 1716 Release(); // Balanced in Run() |
1714 } | 1717 } |
OLD | NEW |