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

Side by Side Diff: chrome/browser/chromeos/extensions/file_system_provider/file_system_provider_api.cc

Issue 329483002: [fsp] Group arguments for API methods and events in dictionaries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_system_provider/operations/close_file.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/extensions/file_system_provider/file_system_pr ovider_api.h" 5 #include "chrome/browser/chromeos/extensions/file_system_provider/file_system_pr ovider_api.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h" 11 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte rface.h"
12 #include "chrome/browser/chromeos/file_system_provider/request_manager.h" 12 #include "chrome/browser/chromeos/file_system_provider/request_manager.h"
13 #include "chrome/browser/chromeos/file_system_provider/request_value.h" 13 #include "chrome/browser/chromeos/file_system_provider/request_value.h"
14 #include "chrome/browser/chromeos/file_system_provider/service.h" 14 #include "chrome/browser/chromeos/file_system_provider/service.h"
15 #include "chrome/common/extensions/api/file_system_provider.h" 15 #include "chrome/common/extensions/api/file_system_provider.h"
16 #include "chrome/common/extensions/api/file_system_provider_internal.h" 16 #include "chrome/common/extensions/api/file_system_provider_internal.h"
17 17
18 using chromeos::file_system_provider::ProvidedFileSystemInterface; 18 using chromeos::file_system_provider::ProvidedFileSystemInterface;
19 using chromeos::file_system_provider::RequestValue; 19 using chromeos::file_system_provider::RequestValue;
20 using chromeos::file_system_provider::Service; 20 using chromeos::file_system_provider::Service;
21 21
22 namespace extensions { 22 namespace extensions {
23 23
24 bool FileSystemProviderMountFunction::RunSync() { 24 bool FileSystemProviderMountFunction::RunSync() {
25 using api::file_system_provider::Mount::Params; 25 using api::file_system_provider::Mount::Params;
26 const scoped_ptr<Params> params(Params::Create(*args_)); 26 const scoped_ptr<Params> params(Params::Create(*args_));
27 EXTENSION_FUNCTION_VALIDATE(params); 27 EXTENSION_FUNCTION_VALIDATE(params);
28 28
29 // It's an error if the file system Id is empty. 29 // It's an error if the file system Id is empty.
30 if (params->file_system_id.empty()) { 30 if (params->options.file_system_id.empty()) {
31 base::ListValue* result = new base::ListValue(); 31 base::ListValue* result = new base::ListValue();
32 result->Append(CreateError(kSecurityErrorName, kEmptyIdErrorMessage)); 32 result->Append(CreateError(kSecurityErrorName, kEmptyIdErrorMessage));
33 SetResult(result); 33 SetResult(result);
34 return true; 34 return true;
35 } 35 }
36 36
37 // It's an error if the display name is empty. 37 // It's an error if the display name is empty.
38 if (params->display_name.empty()) { 38 if (params->options.display_name.empty()) {
39 base::ListValue* result = new base::ListValue(); 39 base::ListValue* result = new base::ListValue();
40 result->Append(CreateError(kSecurityErrorName, 40 result->Append(CreateError(kSecurityErrorName,
41 kEmptyNameErrorMessage)); 41 kEmptyNameErrorMessage));
42 SetResult(result); 42 SetResult(result);
43 return true; 43 return true;
44 } 44 }
45 45
46 Service* service = Service::Get(GetProfile()); 46 Service* service = Service::Get(GetProfile());
47 DCHECK(service); 47 DCHECK(service);
48 if (!service) 48 if (!service)
49 return false; 49 return false;
50 50
51 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. 51 // TODO(mtomasz): Pass more detailed errors, rather than just a bool.
52 if (!service->MountFileSystem( 52 if (!service->MountFileSystem(extension_id(),
53 extension_id(), params->file_system_id, params->display_name)) { 53 params->options.file_system_id,
54 params->options.display_name)) {
54 base::ListValue* result = new base::ListValue(); 55 base::ListValue* result = new base::ListValue();
55 result->Append(CreateError(kSecurityErrorName, kMountFailedErrorMessage)); 56 result->Append(CreateError(kSecurityErrorName, kMountFailedErrorMessage));
56 SetResult(result); 57 SetResult(result);
57 return true; 58 return true;
58 } 59 }
59 60
60 base::ListValue* result = new base::ListValue(); 61 base::ListValue* result = new base::ListValue();
61 SetResult(result); 62 SetResult(result);
62 return true; 63 return true;
63 } 64 }
64 65
65 bool FileSystemProviderUnmountFunction::RunSync() { 66 bool FileSystemProviderUnmountFunction::RunSync() {
66 using api::file_system_provider::Unmount::Params; 67 using api::file_system_provider::Unmount::Params;
67 scoped_ptr<Params> params(Params::Create(*args_)); 68 scoped_ptr<Params> params(Params::Create(*args_));
68 EXTENSION_FUNCTION_VALIDATE(params); 69 EXTENSION_FUNCTION_VALIDATE(params);
69 70
70 Service* service = Service::Get(GetProfile()); 71 Service* service = Service::Get(GetProfile());
71 DCHECK(service); 72 DCHECK(service);
72 if (!service) 73 if (!service)
73 return false; 74 return false;
74 75
75 if (!service->UnmountFileSystem(extension_id(), params->file_system_id)) { 76 if (!service->UnmountFileSystem(extension_id(),
77 params->options.file_system_id)) {
76 // TODO(mtomasz): Pass more detailed errors, rather than just a bool. 78 // TODO(mtomasz): Pass more detailed errors, rather than just a bool.
77 base::ListValue* result = new base::ListValue(); 79 base::ListValue* result = new base::ListValue();
78 result->Append(CreateError(kSecurityErrorName, kUnmountFailedErrorMessage)); 80 result->Append(CreateError(kSecurityErrorName, kUnmountFailedErrorMessage));
79 SetResult(result); 81 SetResult(result);
80 return true; 82 return true;
81 } 83 }
82 84
83 base::ListValue* result = new base::ListValue(); 85 base::ListValue* result = new base::ListValue();
84 SetResult(result); 86 SetResult(result);
85 return true; 87 return true;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 bool FileSystemProviderInternalReadFileRequestedErrorFunction::RunWhenValid() { 205 bool FileSystemProviderInternalReadFileRequestedErrorFunction::RunWhenValid() {
204 using api::file_system_provider_internal::ReadFileRequestedError::Params; 206 using api::file_system_provider_internal::ReadFileRequestedError::Params;
205 const scoped_ptr<Params> params(Params::Create(*args_)); 207 const scoped_ptr<Params> params(Params::Create(*args_));
206 EXTENSION_FUNCTION_VALIDATE(params); 208 EXTENSION_FUNCTION_VALIDATE(params);
207 209
208 RejectRequest(ProviderErrorToFileError(params->error)); 210 RejectRequest(ProviderErrorToFileError(params->error));
209 return true; 211 return true;
210 } 212 }
211 213
212 } // namespace extensions 214 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_system_provider/operations/close_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698