Chromium Code Reviews| Index: chrome/browser/extensions/api/tabs/tabs.cc |
| =================================================================== |
| --- chrome/browser/extensions/api/tabs/tabs.cc (revision 142698) |
| +++ chrome/browser/extensions/api/tabs/tabs.cc (working copy) |
| @@ -1101,6 +1101,41 @@ |
| return true; |
| } |
| +bool DuplicateTabFunction::RunImpl() { |
| + int tab_id = -1; |
| + EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |
| + |
| + Browser* browser = GetCurrentBrowser(); |
| + if (!browser) { |
| + error_ = keys::kNoCurrentWindowError; |
| + return false; |
| + } |
| + |
| + TabStripModel* tab_strip = NULL; |
| + TabContents* contents = NULL; |
| + int tab_index = -1; |
| + if (!GetTabById(tab_id, profile(), include_incognito(), |
| + NULL, &tab_strip, &contents, &tab_index, &error_)) |
| + return false; |
| + |
| + browser->DuplicateContentsAt(tab_index); |
| + int new_index = tab_index + 1; |
|
Aaron Boodman
2012/06/29 07:24:15
Bummer that we have to assume it's the next tab. C
SanjoyPal
2012/07/03 10:03:21
Done.
|
| + TabContents* new_contents = browser->GetTabContentsAt(new_index); |
| + |
| + // Return data about the newly created tab. |
| + if (has_callback()) { |
| + if (GetExtension()->HasAPIPermission(ExtensionAPIPermission::kTab)) { |
| + result_.reset(ExtensionTabUtil::CreateTabValue( |
| + new_contents->web_contents(), |
| + tab_strip, new_index)); |
| + } else { |
| + result_.reset(Value::CreateNullValue()); |
| + } |
| + } |
| + |
| + return true; |
| +} |
| + |
| bool GetTabFunction::RunImpl() { |
| int tab_id = -1; |
| EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |