diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 02:14:56 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-24 02:14:56 +0000 |
commit | 76a3db852fb58323d63b6857493191e00e97422a (patch) | |
tree | a9af5546c680a37ec89c1aaec0733f1026a24711 /chrome/browser | |
parent | d267ac762bb0764857fedb92a516a9aa290b0dd2 (diff) | |
download | chromium_src-76a3db852fb58323d63b6857493191e00e97422a.zip chromium_src-76a3db852fb58323d63b6857493191e00e97422a.tar.gz chromium_src-76a3db852fb58323d63b6857493191e00e97422a.tar.bz2 |
Push bookmarks.remove/removeAll polymorphism into c++. fix bookmarks id schema issues (http://code.google.com/p/chromium/issues/detail?id=17562 failed to update schema types from int to string).
R=erikkay
BUG=17417
Review URL: http://codereview.chromium.org/160064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21503 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
5 files changed, 22 insertions, 18 deletions
diff --git a/chrome/browser/automation/automation_extension_function.cc b/chrome/browser/automation/automation_extension_function.cc index 57690fd..89288c0 100644 --- a/chrome/browser/automation/automation_extension_function.cc +++ b/chrome/browser/automation/automation_extension_function.cc @@ -14,10 +14,6 @@ bool AutomationExtensionFunction::enabled_ = false; -void AutomationExtensionFunction::SetName(const std::string& name) { - name_ = name; -} - void AutomationExtensionFunction::SetArgs(const std::string& args) { args_ = args; } diff --git a/chrome/browser/automation/automation_extension_function.h b/chrome/browser/automation/automation_extension_function.h index e10d04c..1d1da41 100644 --- a/chrome/browser/automation/automation_extension_function.h +++ b/chrome/browser/automation/automation_extension_function.h @@ -20,7 +20,6 @@ class AutomationExtensionFunction : public ExtensionFunction { AutomationExtensionFunction() { } // ExtensionFunction implementation. - virtual void SetName(const std::string& name); virtual void SetArgs(const std::string& args); virtual const std::string GetResult(); virtual const std::string GetError(); @@ -44,7 +43,6 @@ class AutomationExtensionFunction : public ExtensionFunction { private: static bool enabled_; - std::string name_; std::string args_; DISALLOW_COPY_AND_ASSIGN(AutomationExtensionFunction); }; diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index 2d7cbb3..f0acba9 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.cc @@ -358,19 +358,21 @@ bool SearchBookmarksFunction::RunImpl() { } bool RemoveBookmarkFunction::RunImpl() { - EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST)); - const ListValue* args = static_cast<const ListValue*>(args_); bool recursive = false; - EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(1, &recursive)); + if (name() == + extension_bookmarks_module_constants::kRemoveBookmarkTreeFunction) + recursive = true; BookmarkModel* model = profile()->GetBookmarkModel(); int64 id; std::string id_string; - if (args->GetString(0, &id_string) && StringToInt64(id_string, &id)) { + if (args_->IsType(Value::TYPE_STRING) && + args_->GetAsString(&id_string) && + StringToInt64(id_string, &id)) { return ExtensionBookmarks::RemoveNode(model, id, recursive, &error_); } else { - ListValue* ids; - EXTENSION_FUNCTION_VALIDATE(args->GetList(0, &ids)); + EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_LIST)); + ListValue* ids = static_cast<ListValue*>(args_); size_t count = ids->GetSize(); EXTENSION_FUNCTION_VALIDATE(count > 0); for (size_t i = 0; i < count; ++i) { @@ -477,9 +479,13 @@ bool MoveBookmarkFunction::RunImpl() { // Optional, defaults to current parent. parent = node->GetParent(); } else { - int parentId; - EXTENSION_FUNCTION_VALIDATE(destination->GetInteger(keys::kParentIdKey, - &parentId)); + std::string parentId_string; + EXTENSION_FUNCTION_VALIDATE(destination->GetString(keys::kParentIdKey, + &parentId_string)); + int64 parentId; + if (!GetBookmarkIdAsInt64(parentId_string, &parentId)) + return false; + parent = model->GetNodeByID(parentId); } if (!parent) { diff --git a/chrome/browser/extensions/extension_function.h b/chrome/browser/extensions/extension_function.h index ed2f9d0..02bab68 100644 --- a/chrome/browser/extensions/extension_function.h +++ b/chrome/browser/extensions/extension_function.h @@ -29,11 +29,12 @@ class Profile; // APIs that live beyond a single stack frame. class ExtensionFunction : public base::RefCounted<ExtensionFunction> { public: - ExtensionFunction() : request_id_(-1), has_callback_(false) {} + ExtensionFunction() : request_id_(-1), name_(""), has_callback_(false) {} virtual ~ExtensionFunction() {} // Specifies the name of the function. - virtual void SetName(const std::string& name) { } + void set_name(const std::string& name) { name_ = name; } + const std::string name() { return name_; } // Specifies the raw arguments to the function, as a JSON-encoded string. virtual void SetArgs(const std::string& args) = 0; @@ -71,6 +72,9 @@ class ExtensionFunction : public base::RefCounted<ExtensionFunction> { // Id of this request, used to map the response back to the caller. int request_id_; + // The name of this function. + std::string name_; + // True if the js caller provides a callback function to receive the response // of this call. bool has_callback_; diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index 57a1212..40c5996 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -151,7 +151,7 @@ ExtensionFunction* FactoryRegistry::NewFunction(const std::string& name) { FactoryMap::iterator iter = factories_.find(name); DCHECK(iter != factories_.end()); ExtensionFunction* function = iter->second(); - function->SetName(name); + function->set_name(name); return function; } |