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

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

Issue 10175008: Improving the process model extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improved task manager sample and minor cleanup. Created 8 years, 8 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/extension_tabs_module.cc
diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc
index 054c58e8c36eb20be6150066abf8bcb835bbcc2e..eb5dacf8585f8fb9c37523928ba26c99d561d00e 100644
--- a/chrome/browser/extensions/extension_tabs_module.cc
+++ b/chrome/browser/extensions/extension_tabs_module.cc
@@ -195,29 +195,6 @@ bool GetTabById(int tab_id,
return false;
}
-// Reads the |value| as either a single integer value or a list of integers.
-bool ReadOneOrMoreIntegers(
- Value* value, std::vector<int>* result) {
- if (value->IsType(Value::TYPE_INTEGER)) {
- int tab_id = -1;
- if (!value->GetAsInteger(&tab_id))
- return false;
- result->push_back(tab_id);
- return true;
-
- } else if (value->IsType(Value::TYPE_LIST)) {
- ListValue* tabs = static_cast<ListValue*>(value);
- for (size_t i = 0; i < tabs->GetSize(); ++i) {
- int tab_id = -1;
- if (!tabs->GetInteger(i, &tab_id))
- return false;
- result->push_back(tab_id);
- }
- return true;
- }
- return false;
-}
-
// A three state enum to distinguish between when a boolean query argument is
// set or not.
enum QueryArg {
@@ -1141,7 +1118,8 @@ bool HighlightTabsFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(info->Get(keys::kTabsKey, &tab_value));
std::vector<int> tab_indices;
- EXTENSION_FUNCTION_VALIDATE(ReadOneOrMoreIntegers(tab_value, &tab_indices));
+ EXTENSION_FUNCTION_VALIDATE(ExtensionTabUtil::ReadOneOrMoreIntegers(
+ tab_value, &tab_indices));
// Create a new selection model as we read the list of tab indices.
for (size_t i = 0; i < tab_indices.size(); ++i) {
@@ -1403,7 +1381,8 @@ bool MoveTabsFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &tab_value));
std::vector<int> tab_ids;
- EXTENSION_FUNCTION_VALIDATE(ReadOneOrMoreIntegers(tab_value, &tab_ids));
+ EXTENSION_FUNCTION_VALIDATE(ExtensionTabUtil::ReadOneOrMoreIntegers(
+ tab_value, &tab_ids));
DictionaryValue* update_props = NULL;
EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &update_props));
@@ -1572,7 +1551,8 @@ bool RemoveTabsFunction::RunImpl() {
EXTENSION_FUNCTION_VALIDATE(args_->Get(0, &tab_value));
std::vector<int> tab_ids;
- EXTENSION_FUNCTION_VALIDATE(ReadOneOrMoreIntegers(tab_value, &tab_ids));
+ EXTENSION_FUNCTION_VALIDATE(ExtensionTabUtil::ReadOneOrMoreIntegers(
+ tab_value, &tab_ids));
for (size_t i = 0; i < tab_ids.size(); ++i) {
Browser* browser = NULL;

Powered by Google App Engine
This is Rietveld 408576698