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

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, 5 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
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,36 @@
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 = browser->DuplicateContentsAt(tab_index);
+ int new_index = tab_strip->GetIndexOfTabContents(new_contents);
+
+ // Return data about the newly created tab.
+ if (has_callback()) {
+ if (GetExtension()->HasAPIPermission(ExtensionAPIPermission::kTab)) {
+ result_.reset(ExtensionTabUtil::CreateTabValue(
SanjoyPal 2012/07/06 13:46:52 shall i pass a bool parameter hasPermission to Cre
+ new_contents->web_contents(),
+ tab_strip, new_index));
+ } else {
+ result_.reset(Value::CreateIntegerValue(
+ ExtensionTabUtil::GetTabId(new_contents->web_contents())));
+ }
+ }
+
+ return true;
+}
+
bool GetTabFunction::RunImpl() {
int tab_id = -1;
EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id));

Powered by Google App Engine
This is Rietveld 408576698