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

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, 4 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 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));
« 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