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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/operations/get_actions.cc

Issue 1151763007: Add the boilerplate for actions to File System Provider API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 5 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/file_system_provider/operations/get_actions.h"
6
7 #include <algorithm>
8 #include <string>
9
10 #include "chrome/common/extensions/api/file_system_provider.h"
11 #include "chrome/common/extensions/api/file_system_provider_internal.h"
12
13 namespace chromeos {
14 namespace file_system_provider {
15 namespace operations {
16 namespace {
17
18 // Convert the request |value| into a list of actions.
19 Actions ConvertRequestValueToActions(scoped_ptr<RequestValue> value) {
20 using extensions::api::file_system_provider_internal::
21 GetActionsRequestedSuccess::Params;
22
23 const Params* params = value->get_actions_success_params();
24 DCHECK(params);
25
26 Actions result;
27 for (const auto& idl_action : params->actions) {
28 Action action;
29 action.id = idl_action->id;
30 action.title = idl_action->title.get() ? *idl_action->title : std::string();
31 result.push_back(action);
32 }
33
34 return result;
35 }
36
37 } // namespace
38
39 GetActions::GetActions(
40 extensions::EventRouter* event_router,
41 const ProvidedFileSystemInfo& file_system_info,
42 const base::FilePath& entry_path,
43 const ProvidedFileSystemInterface::GetActionsCallback& callback)
44 : Operation(event_router, file_system_info),
45 entry_path_(entry_path),
46 callback_(callback) {
47 }
48
49 GetActions::~GetActions() {
50 }
51
52 bool GetActions::Execute(int request_id) {
53 using extensions::api::file_system_provider::GetActionsRequestedOptions;
54
55 GetActionsRequestedOptions options;
56 options.file_system_id = file_system_info_.file_system_id();
57 options.request_id = request_id;
58 options.entry_path = entry_path_.AsUTF8Unsafe();
59
60 return SendEvent(
61 request_id,
62 extensions::api::file_system_provider::OnGetActionsRequested::kEventName,
63 extensions::api::file_system_provider::OnGetActionsRequested::Create(
64 options));
65 }
66
67 void GetActions::OnSuccess(int /* request_id */,
68 scoped_ptr<RequestValue> result,
69 bool has_more) {
70 callback_.Run(ConvertRequestValueToActions(result.Pass()),
71 base::File::FILE_OK);
72 }
73
74 void GetActions::OnError(int /* request_id */,
75 scoped_ptr<RequestValue> /* result */,
76 base::File::Error error) {
77 callback_.Run(Actions(), error);
78 }
79
80 } // namespace operations
81 } // namespace file_system_provider
82 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698