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

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, 3 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/api/tabs/tabs_test.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 155137)
+++ chrome/browser/extensions/api/tabs/tabs.cc (working copy)
@@ -1083,6 +1083,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_)) {
+ return false;
+ }
+
+ TabContents* new_contents = chrome::DuplicateTabAt(browser, tab_index);
+ if (!has_callback())
+ return true;
+
+ int new_index = tab_strip->GetIndexOfTabContents(new_contents);
+
+ // Return data about the newly created tab.
+ SetResult(ExtensionTabUtil::CreateTabValue(
+ new_contents->web_contents(),
+ tab_strip, new_index, GetExtension()));
+
+ 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/api/tabs/tabs_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698