Commit 66c9abc2 authored by hirono@chromium.org's avatar hirono@chromium.org

Files.app: Let the file browser private tasks APIs use the auto-generated helper classes.

Originally, the file browser private tasks APIs parse the arguments and generate
the results manually.  This CL lets the APIs use the auto generated helper
classes to parse the arguments.

BUG=241693
TEST=file_manager_browsertest

Review URL: https://chromiumcodereview.appspot.com/23740004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221635 0039d316-1c4b-4281-b951-d872f2087c98
parent 4e039309
......@@ -29,10 +29,8 @@ class FileBrowserPrivateExecuteTaskFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.executeTask",
FILEBROWSERPRIVATE_EXECUTETASK)
FileBrowserPrivateExecuteTaskFunction();
protected:
virtual ~FileBrowserPrivateExecuteTaskFunction();
virtual ~FileBrowserPrivateExecuteTaskFunction() {}
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......@@ -47,10 +45,8 @@ class FileBrowserPrivateGetFileTasksFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getFileTasks",
FILEBROWSERPRIVATE_GETFILETASKS)
FileBrowserPrivateGetFileTasksFunction();
protected:
virtual ~FileBrowserPrivateGetFileTasksFunction();
virtual ~FileBrowserPrivateGetFileTasksFunction() {}
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......@@ -62,10 +58,8 @@ class FileBrowserPrivateSetDefaultTaskFunction : public SyncExtensionFunction {
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.setDefaultTask",
FILEBROWSERPRIVATE_SETDEFAULTTASK)
FileBrowserPrivateSetDefaultTaskFunction();
protected:
virtual ~FileBrowserPrivateSetDefaultTaskFunction();
virtual ~FileBrowserPrivateSetDefaultTaskFunction() {}
// SyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......
......@@ -125,17 +125,6 @@ FullTaskDescriptor::FullTaskDescriptor(
is_default_(is_default){
}
scoped_ptr<base::DictionaryValue>
FullTaskDescriptor::AsDictionaryValue() const {
scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue);
dictionary->SetString("taskId", TaskDescriptorToId(task_descriptor_));
if (!icon_url_.is_empty())
dictionary->SetString("iconUrl", icon_url_.spec());
dictionary->SetString("title", task_title_);
dictionary->SetBoolean("isDefault", is_default_);
return dictionary.Pass();
}
void UpdateDefaultTask(PrefService* pref_service,
const std::string& task_id,
const std::set<std::string>& suffixes,
......
......@@ -169,7 +169,7 @@ class FullTaskDescriptor {
const TaskDescriptor& task_descriptor() const { return task_descriptor_; }
// The title of the task.
const std::string& task_title() { return task_title_; }
const std::string& task_title() const { return task_title_; }
// The icon URL for the task (ex. app icon)
const GURL& icon_url() const { return icon_url_; }
......@@ -177,20 +177,6 @@ class FullTaskDescriptor {
bool is_default() const { return is_default_; }
void set_is_default(bool is_default) { is_default_ = is_default; }
// Returns a DictionaryValue representation, which looks like:
//
// {
// "iconUrl": "<app_icon_url>",
// "isDefault": false,
// "taskId": "<drive_app_id>|drive|open-with",
// "title": "Drive App Name (ex. Pixlr Editor)"
// },
//
// "iconUrl" is omitted if icon_url_ is empty.
//
// This representation will be used to send task info to the JavaScript.
scoped_ptr<base::DictionaryValue> AsDictionaryValue() const;
private:
TaskDescriptor task_descriptor_;
std::string task_title_;
......
......@@ -56,23 +56,12 @@ TEST(FileManagerFileTasksTest,
GURL("http://example.com/icon.png"),
true /* is_default */);
scoped_ptr<base::DictionaryValue> dictionary(
full_descriptor.AsDictionaryValue());
std::string task_id;
EXPECT_TRUE(dictionary->GetString("taskId", &task_id));
const std::string task_id =
TaskDescriptorToId(full_descriptor.task_descriptor());
EXPECT_EQ("app-id|file|action-id", task_id);
std::string icon_url;
EXPECT_TRUE(dictionary->GetString("iconUrl", &icon_url));
EXPECT_EQ("http://example.com/icon.png", icon_url);
std::string title;
EXPECT_TRUE(dictionary->GetString("title", &title));
EXPECT_EQ("task title", title);
bool is_default = false;
EXPECT_TRUE(dictionary->GetBoolean("isDefault", &is_default));
EXPECT_TRUE(is_default);
EXPECT_EQ("http://example.com/icon.png", full_descriptor.icon_url().spec());
EXPECT_EQ("task title", full_descriptor.task_title());
EXPECT_TRUE(full_descriptor.is_default());
}
TEST(FileManagerFileTasksTest,
......@@ -85,22 +74,12 @@ TEST(FileManagerFileTasksTest,
GURL(), // No icon URL.
false /* is_default */);
scoped_ptr<base::DictionaryValue> dictionary(
full_descriptor.AsDictionaryValue());
std::string task_id;
EXPECT_TRUE(dictionary->GetString("taskId", &task_id));
const std::string task_id =
TaskDescriptorToId(full_descriptor.task_descriptor());
EXPECT_EQ("app-id|drive|action-id", task_id);
std::string icon_url;
EXPECT_FALSE(dictionary->GetString("iconUrl", &icon_url));
std::string title;
EXPECT_TRUE(dictionary->GetString("title", &title));
EXPECT_EQ("task title", title);
bool is_default = false;
EXPECT_TRUE(dictionary->GetBoolean("isDefault", &is_default));
EXPECT_FALSE(is_default);
EXPECT_TRUE(full_descriptor.icon_url().is_empty());
EXPECT_EQ("task title", full_descriptor.task_title());
EXPECT_FALSE(full_descriptor.is_default());
}
TEST(FileManagerFileTasksTest, MakeTaskID) {
......
......@@ -422,7 +422,7 @@
"description": "The unique identifier of task to execute."
},
{
"name": "fileURLs",
"name": "fileUrls",
"type": "array",
"description": "Array of file URLs",
"items": { "type": "string" }
......@@ -452,7 +452,7 @@
"description": "The unique identifier of task to mark as default."
},
{
"name": "fileURLs",
"name": "fileUrls",
"type": "array",
"description": "Array of selected file URLs to extract suffixes from.",
"items": { "type": "string" }
......@@ -477,7 +477,7 @@
"description": "Gets the list of tasks that can be performed over selected files.",
"parameters": [
{
"name": "fileURLs",
"name": "fileUrls",
"type": "array",
"description": "Array of selected file URLs",
"items": { "type": "string" }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment