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,33 @@ |
| return true; |
| } |
| +bool DuplicateTabFunction::RunImpl() { |
| + int tab_id = -1; |
| + EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |
| + |
| + Browser* browser = NULL; |
| + TabStripModel* tab_strip = NULL; |
| + TabContents* contents = NULL; |
| + int tab_index = -1; |
| + if (!GetTabById(tab_id, profile(), include_incognito(), |
| + &browser, &tab_strip, &contents, &tab_index, &error_)) |
|
Aaron Boodman
2012/08/07 01:03:25
Nit: curly braces are required here.
SanjoyPal
2012/08/14 11:14:13
Done.
|
| + return false; |
| + |
| + TabContents* new_contents = browser->DuplicateContentsAt(tab_index); |
| + int new_index = tab_strip->GetIndexOfTabContents(new_contents); |
| + |
| + // Return data about the newly created tab. |
| + if (has_callback()) { |
| + bool has_permission = GetExtension()->HasAPIPermission( |
|
Aaron Boodman
2012/08/07 01:03:25
Use HasAPIPermissionForTab. Currently the "ForTab"
SanjoyPal
2012/08/14 11:14:13
Done.
|
| + ExtensionAPIPermission::kTab); |
| + result_.reset(ExtensionTabUtil::CreateTabValue( |
| + new_contents->web_contents(), |
| + tab_strip, new_index, has_permission)); |
| + } |
| + |
| + return true; |
| +} |
| + |
| bool GetTabFunction::RunImpl() { |
| int tab_id = -1; |
| EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |