| 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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1076 // Return data about the newly created tab. | 1076 // Return data about the newly created tab. |
| 1077 if (has_callback()) { | 1077 if (has_callback()) { |
| 1078 SetResult(ExtensionTabUtil::CreateTabValue( | 1078 SetResult(ExtensionTabUtil::CreateTabValue( |
| 1079 params.target_contents->web_contents(), | 1079 params.target_contents->web_contents(), |
| 1080 tab_strip, new_index, GetExtension())); | 1080 tab_strip, new_index, GetExtension())); |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 return true; | 1083 return true; |
| 1084 } | 1084 } |
| 1085 | 1085 |
| 1086 bool DuplicateTabFunction::RunImpl() { |
| 1087 int tab_id = -1; |
| 1088 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |
| 1089 |
| 1090 Browser* browser = NULL; |
| 1091 TabStripModel* tab_strip = NULL; |
| 1092 TabContents* contents = NULL; |
| 1093 int tab_index = -1; |
| 1094 if (!GetTabById(tab_id, profile(), include_incognito(), |
| 1095 &browser, &tab_strip, &contents, &tab_index, &error_)) { |
| 1096 return false; |
| 1097 } |
| 1098 |
| 1099 TabContents* new_contents = chrome::DuplicateTabAt(browser, tab_index); |
| 1100 if (!has_callback()) |
| 1101 return true; |
| 1102 |
| 1103 int new_index = tab_strip->GetIndexOfTabContents(new_contents); |
| 1104 |
| 1105 // Return data about the newly created tab. |
| 1106 SetResult(ExtensionTabUtil::CreateTabValue( |
| 1107 new_contents->web_contents(), |
| 1108 tab_strip, new_index, GetExtension())); |
| 1109 |
| 1110 return true; |
| 1111 } |
| 1112 |
| 1086 bool GetTabFunction::RunImpl() { | 1113 bool GetTabFunction::RunImpl() { |
| 1087 int tab_id = -1; | 1114 int tab_id = -1; |
| 1088 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); | 1115 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |
| 1089 | 1116 |
| 1090 TabStripModel* tab_strip = NULL; | 1117 TabStripModel* tab_strip = NULL; |
| 1091 TabContents* contents = NULL; | 1118 TabContents* contents = NULL; |
| 1092 int tab_index = -1; | 1119 int tab_index = -1; |
| 1093 if (!GetTabById(tab_id, profile(), include_incognito(), | 1120 if (!GetTabById(tab_id, profile(), include_incognito(), |
| 1094 NULL, &tab_strip, &contents, &tab_index, &error_)) | 1121 NULL, &tab_strip, &contents, &tab_index, &error_)) |
| 1095 return false; | 1122 return false; |
| (...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 // called for every API call the extension made. | 1850 // called for every API call the extension made. |
| 1824 GotLanguage(language); | 1851 GotLanguage(language); |
| 1825 } | 1852 } |
| 1826 | 1853 |
| 1827 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1854 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
| 1828 SetResult(Value::CreateStringValue(language.c_str())); | 1855 SetResult(Value::CreateStringValue(language.c_str())); |
| 1829 SendResponse(true); | 1856 SendResponse(true); |
| 1830 | 1857 |
| 1831 Release(); // Balanced in Run() | 1858 Release(); // Balanced in Run() |
| 1832 } | 1859 } |
| OLD | NEW |