Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: chrome/browser/extensions/api/tabs/tabs.cc

Issue 10697017: Tabs Extension: Implementation of tabs.duplicate api. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs.h ('k') | chrome/browser/extensions/extension_function_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « chrome/browser/extensions/api/tabs/tabs.h ('k') | chrome/browser/extensions/extension_function_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698