| 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/api/tabs/tabs.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 window_profile); | 608 window_profile); |
| 609 } | 609 } |
| 610 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; | 610 create_params.initial_show_state = ui::SHOW_STATE_NORMAL; |
| 611 | 611 |
| 612 Browser* new_window = CreateBrowserWindow(create_params, window_profile, | 612 Browser* new_window = CreateBrowserWindow(create_params, window_profile, |
| 613 extension_id); | 613 extension_id); |
| 614 | 614 |
| 615 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) { | 615 for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) { |
| 616 TabContents* tab = chrome::AddSelectedTabWithURL( | 616 TabContents* tab = chrome::AddSelectedTabWithURL( |
| 617 new_window, *i, content::PAGE_TRANSITION_LINK); | 617 new_window, *i, content::PAGE_TRANSITION_LINK); |
| 618 if (window_type == Browser::TYPE_PANEL) | 618 if (window_type == Browser::TYPE_PANEL) { |
| 619 tab->extension_tab_helper()->SetExtensionAppIconById(extension_id); | 619 extensions::TabHelper::FromWebContents(tab->web_contents())-> |
| 620 SetExtensionAppIconById(extension_id); |
| 621 } |
| 620 } | 622 } |
| 621 if (contents) { | 623 if (contents) { |
| 622 TabStripModel* target_tab_strip = new_window->tab_strip_model(); | 624 TabStripModel* target_tab_strip = new_window->tab_strip_model(); |
| 623 target_tab_strip->InsertTabContentsAt(urls.size(), contents, | 625 target_tab_strip->InsertTabContentsAt(urls.size(), contents, |
| 624 TabStripModel::ADD_NONE); | 626 TabStripModel::ADD_NONE); |
| 625 } else if (urls.empty()) { | 627 } else if (urls.empty()) { |
| 626 chrome::NewTab(new_window); | 628 chrome::NewTab(new_window); |
| 627 } | 629 } |
| 628 chrome::SelectNumberedTab(new_window, 0); | 630 chrome::SelectNumberedTab(new_window, 0); |
| 629 | 631 |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 if (url.SchemeIs(chrome::kJavaScriptScheme)) { | 1341 if (url.SchemeIs(chrome::kJavaScriptScheme)) { |
| 1340 if (!GetExtension()->CanExecuteScriptOnPage( | 1342 if (!GetExtension()->CanExecuteScriptOnPage( |
| 1341 tab_contents_->web_contents()->GetURL(), | 1343 tab_contents_->web_contents()->GetURL(), |
| 1342 tab_contents_->web_contents()->GetURL(), | 1344 tab_contents_->web_contents()->GetURL(), |
| 1343 tab_id, | 1345 tab_id, |
| 1344 NULL, | 1346 NULL, |
| 1345 &error_)) { | 1347 &error_)) { |
| 1346 return false; | 1348 return false; |
| 1347 } | 1349 } |
| 1348 | 1350 |
| 1349 tab_contents_->extension_tab_helper()->script_executor()->ExecuteScript( | 1351 extensions::TabHelper::FromWebContents(tab_contents_->web_contents())-> |
| 1350 extension_id(), | 1352 script_executor()->ExecuteScript( |
| 1351 ScriptExecutor::JAVASCRIPT, | 1353 extension_id(), |
| 1352 url.path(), | 1354 ScriptExecutor::JAVASCRIPT, |
| 1353 ScriptExecutor::TOP_FRAME, | 1355 url.path(), |
| 1354 extensions::UserScript::DOCUMENT_IDLE, | 1356 ScriptExecutor::TOP_FRAME, |
| 1355 ScriptExecutor::MAIN_WORLD, | 1357 extensions::UserScript::DOCUMENT_IDLE, |
| 1356 base::Bind(&UpdateTabFunction::OnExecuteCodeFinished, this)); | 1358 ScriptExecutor::MAIN_WORLD, |
| 1359 base::Bind(&UpdateTabFunction::OnExecuteCodeFinished, this)); |
| 1357 | 1360 |
| 1358 *is_async = true; | 1361 *is_async = true; |
| 1359 return true; | 1362 return true; |
| 1360 } | 1363 } |
| 1361 | 1364 |
| 1362 tab_contents_->web_contents()->GetController().LoadURL( | 1365 tab_contents_->web_contents()->GetController().LoadURL( |
| 1363 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 1366 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
| 1364 | 1367 |
| 1365 // The URL of a tab contents never actually changes to a JavaScript URL, so | 1368 // The URL of a tab contents never actually changes to a JavaScript URL, so |
| 1366 // this check only makes sense in other cases. | 1369 // this check only makes sense in other cases. |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 // called for every API call the extension made. | 1856 // called for every API call the extension made. |
| 1854 GotLanguage(language); | 1857 GotLanguage(language); |
| 1855 } | 1858 } |
| 1856 | 1859 |
| 1857 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1860 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
| 1858 SetResult(Value::CreateStringValue(language.c_str())); | 1861 SetResult(Value::CreateStringValue(language.c_str())); |
| 1859 SendResponse(true); | 1862 SendResponse(true); |
| 1860 | 1863 |
| 1861 Release(); // Balanced in Run() | 1864 Release(); // Balanced in Run() |
| 1862 } | 1865 } |
| OLD | NEW |