Chromium Code Reviews| Index: chrome/browser/extensions/api/tabs/tabs.cc |
| =================================================================== |
| --- chrome/browser/extensions/api/tabs/tabs.cc (revision 150331) |
| +++ chrome/browser/extensions/api/tabs/tabs.cc (working copy) |
| @@ -1089,6 +1089,41 @@ |
| 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_)) { |
| + return false; |
| + } |
| + |
| + TabContents* new_contents = chrome::DuplicateTabAt(browser, tab_index); |
| + int new_index = tab_strip->GetIndexOfTabContents(new_contents); |
| + |
| + // Return data about the newly created tab. |
| + if (has_callback()) { |
|
Aaron Boodman
2012/08/15 04:14:05
You can invert this check and return early to redu
SanjoyPal
2012/09/05 08:31:15
Done.
|
| + bool has_permission = GetExtension()->HasAPIPermissionForTab(tab_id, |
|
Aaron Boodman
2012/08/15 04:14:05
Actually, I think it would be better to just pass
SanjoyPal
2012/09/05 08:31:15
Done. We need cleanup other callers of CreateTabVa
Aaron Boodman
2012/09/05 21:56:21
Since I made the original comment, we already modi
|
| + extensions::APIPermission::kTab); |
| + if (has_permission) |
|
Aaron Boodman
2012/08/15 04:14:05
Curly braces are required here...
SanjoyPal
2012/09/05 08:31:15
Done.
|
| + SetResult(ExtensionTabUtil::CreateTabValue( |
| + new_contents->web_contents(), |
| + tab_strip, new_index, |
| + ExtensionTabUtil::INCLUDE_PRIVACY_SENSITIVE_FIELDS)); |
| + else |
|
Aaron Boodman
2012/08/15 04:14:05
... and here ...
SanjoyPal
2012/09/05 08:31:15
Done.
|
| + SetResult(ExtensionTabUtil::CreateTabValue( |
| + new_contents->web_contents(), |
| + tab_strip, new_index, |
| + ExtensionTabUtil::OMIT_PRIVACY_SENSITIVE_FIELDS)); |
| + } |
| + |
| + return true; |
| +} |
| + |
| bool GetTabFunction::RunImpl() { |
| int tab_id = -1; |
| EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |