summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_toolstrip_api.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 19:07:21 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 19:07:21 +0000
commit5592d7ec9c8b63cca9ab980d4c2d9888dafc3761 (patch)
treeb84940449246e80d5db8ad0e2aefa718a1e86bd9 /chrome/browser/extensions/extension_toolstrip_api.cc
parent6a2da2a134813c7820f89d6c750287663bfed078 (diff)
downloadchromium_src-5592d7ec9c8b63cca9ab980d4c2d9888dafc3761.zip
chromium_src-5592d7ec9c8b63cca9ab980d4c2d9888dafc3761.tar.gz
chromium_src-5592d7ec9c8b63cca9ab980d4c2d9888dafc3761.tar.bz2
Extension API Renaming/Consistency changes
BUG=20288 Review URL: http://codereview.chromium.org/180016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24770 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_toolstrip_api.cc')
-rw-r--r--chrome/browser/extensions/extension_toolstrip_api.cc49
1 files changed, 28 insertions, 21 deletions
diff --git a/chrome/browser/extensions/extension_toolstrip_api.cc b/chrome/browser/extensions/extension_toolstrip_api.cc
index 248eedb..8f70243 100644
--- a/chrome/browser/extensions/extension_toolstrip_api.cc
+++ b/chrome/browser/extensions/extension_toolstrip_api.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/browser.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_shelf_model.h"
+#include "chrome/browser/extensions/extension_tabs_module_constants.h"
namespace extension_toolstrip_api_functions {
const char kExpandFunction[] = "toolstrip.expand";
@@ -26,6 +27,8 @@ const int kMinHeight = 50;
const int kMaxHeight = 1000;
}; // namespace
+namespace keys = extension_tabs_module_constants;
+
bool ToolstripFunction::RunImpl() {
ExtensionHost* host = dispatcher()->GetExtensionHost();
if (!host) {
@@ -58,30 +61,28 @@ bool ToolstripExpandFunction::RunImpl() {
return false;
}
- EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST));
- const ListValue* args = static_cast<const ListValue*>(args_);
- EXTENSION_FUNCTION_VALIDATE(args->GetSize() <= 2);
+ EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY));
+ const DictionaryValue* args = static_cast<const DictionaryValue*>(args_);
int height;
- EXTENSION_FUNCTION_VALIDATE(args->GetInteger(0, &height));
+ EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kHeightKey,
+ &height));
EXTENSION_FUNCTION_VALIDATE(height >= 0);
if (height < kMinHeight || height > kMaxHeight) {
error_ = kBadHeightError;
return false;
}
+
GURL url;
- if (args->GetSize() == 2) {
- Value* url_val;
- EXTENSION_FUNCTION_VALIDATE(args->Get(1, &url_val));
- if (url_val->GetType() != Value::TYPE_NULL) {
- std::string url_str;
- EXTENSION_FUNCTION_VALIDATE(url_val->GetAsString(&url_str));
- url = GURL(url_str);
- if (!url.is_valid() && !url.is_empty()) {
- error_ = kInvalidURLError;
- return false;
- }
+ if (args->HasKey(keys::kUrlKey)) {
+ std::string url_string;
+ EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kUrlKey,
+ &url_string));
+ url = GURL(url_string);
+ if (!url.is_valid() && !url.is_empty()) {
+ error_ = kInvalidURLError;
+ return false;
}
}
@@ -100,12 +101,18 @@ bool ToolstripCollapseFunction::RunImpl() {
GURL url;
if (args_->GetType() != Value::TYPE_NULL) {
- std::string url_str;
- EXTENSION_FUNCTION_VALIDATE(args_->GetAsString(&url_str));
- url = GURL(url_str);
- if (!url.is_valid() && !url.is_empty()) {
- error_ = kInvalidURLError;
- return false;
+ EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY));
+ const DictionaryValue* args = static_cast<const DictionaryValue*>(args_);
+
+ if (args->HasKey(keys::kUrlKey)) {
+ std::string url_string;
+ EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kUrlKey,
+ &url_string));
+ url = GURL(url_string);
+ if (!url.is_valid() && !url.is_empty()) {
+ error_ = kInvalidURLError;
+ return false;
+ }
}
}