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

Unified Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 9699065: "index" property should be optional with "chrome.tabs.move" (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Small changes per comments Created 8 years, 7 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 | « no previous file | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_tabs_module.cc
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 65cfe3c86bacb8f9a02dbe31868f5971c47c2d1c..cf9a569bb9e494828384a042024b7563db88a8a4 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/extensions/extension_tabs_module.h"
#include <algorithm>
+#include <limits>
#include <vector>
#include "base/base64.h"
@@ -1409,12 +1410,10 @@ bool MoveTabsFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(ReadOneOrMoreIntegers(tab_value, &tab_ids));
DictionaryValue* update_props = NULL;
+ int new_index;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props));
-
- int new_index = -1;
- EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(
- keys::kIndexKey, &new_index));
- EXTENSION_FUNCTION_VALIDATE(new_index >= 0);
+ EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(keys::kIndexKey,
+ &new_index));
ListValue tab_values;
for (size_t i = 0; i < tab_ids.size(); ++i) {
@@ -1441,6 +1440,7 @@ bool MoveTabsFunction::RunImpl() {
int window_id = extension_misc::kUnknownWindowId;
EXTENSION_FUNCTION_VALIDATE(update_props->GetInteger(
keys::kWindowIdKey, &window_id));
+
if (!GetBrowserFromWindowID(this, window_id, &target_browser))
return false;
@@ -1472,7 +1472,8 @@ bool MoveTabsFunction::RunImpl() {
// Clamp move location to the last position.
// This is ">" because it can append to a new index position.
- if (new_index > target_tab_strip->count())
+ // -1 means set the move location to the last position.
+ if (new_index > target_tab_strip->count() || new_index < 0)
new_index = target_tab_strip->count();
target_tab_strip->InsertTabContentsAt(
@@ -1489,7 +1490,8 @@ bool MoveTabsFunction::RunImpl() {
// Perform a simple within-window move.
// Clamp move location to the last position.
// This is ">=" because the move must be to an existing location.
- if (new_index >= source_tab_strip->count())
+ // -1 means set the move location to the last position.
+ if (new_index >= source_tab_strip->count() || new_index < 0)
new_index = source_tab_strip->count() - 1;
if (new_index != tab_index)
« no previous file with comments | « no previous file | chrome/common/extensions/api/tabs.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698