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 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 if (!has_callback()) | 1340 if (!has_callback()) |
1341 return; | 1341 return; |
1342 | 1342 |
1343 if (GetExtension()->HasAPIPermission(extensions::APIPermission::kTab)) { | 1343 if (GetExtension()->HasAPIPermission(extensions::APIPermission::kTab)) { |
1344 SetResult(ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents())); | 1344 SetResult(ExtensionTabUtil::CreateTabValue(tab_contents_->web_contents())); |
1345 } else { | 1345 } else { |
1346 SetResult(Value::CreateNullValue()); | 1346 SetResult(Value::CreateNullValue()); |
1347 } | 1347 } |
1348 } | 1348 } |
1349 | 1349 |
1350 void UpdateTabFunction::OnExecuteCodeFinished(bool success, | 1350 void UpdateTabFunction::OnExecuteCodeFinished(const std::string& error, |
1351 int32 page_id, | 1351 int32 on_page_id, |
1352 const std::string& error, | 1352 const GURL& url, |
1353 const ListValue& script_result) { | 1353 const ListValue& script_result) { |
1354 if (!error.empty()) { | 1354 if (error.empty()) |
1355 CHECK(!success); | 1355 PopulateResult(); |
| 1356 else |
1356 error_ = error; | 1357 error_ = error; |
1357 } | 1358 SendResponse(error.empty()); |
1358 | |
1359 if (success) | |
1360 PopulateResult(); | |
1361 SendResponse(success); | |
1362 } | 1359 } |
1363 | 1360 |
1364 bool MoveTabsFunction::RunImpl() { | 1361 bool MoveTabsFunction::RunImpl() { |
1365 Value* tab_value = NULL; | 1362 Value* tab_value = NULL; |
1366 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &tab_value)); | 1363 EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &tab_value)); |
1367 | 1364 |
1368 std::vector<int> tab_ids; | 1365 std::vector<int> tab_ids; |
1369 EXTENSION_FUNCTION_VALIDATE(extensions::ReadOneOrMoreIntegers( | 1366 EXTENSION_FUNCTION_VALIDATE(extensions::ReadOneOrMoreIntegers( |
1370 tab_value, &tab_ids)); | 1367 tab_value, &tab_ids)); |
1371 | 1368 |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 // called for every API call the extension made. | 1820 // called for every API call the extension made. |
1824 GotLanguage(language); | 1821 GotLanguage(language); |
1825 } | 1822 } |
1826 | 1823 |
1827 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1824 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1828 SetResult(Value::CreateStringValue(language.c_str())); | 1825 SetResult(Value::CreateStringValue(language.c_str())); |
1829 SendResponse(true); | 1826 SendResponse(true); |
1830 | 1827 |
1831 Release(); // Balanced in Run() | 1828 Release(); // Balanced in Run() |
1832 } | 1829 } |
OLD | NEW |