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

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

Issue 1077823005: Declare providing extension capabilities in the manifest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed tests. Created 5 years, 7 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
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 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 scoped_ptr<ProvidedFileSystemObserver::Changes> ParseChanges( 63 scoped_ptr<ProvidedFileSystemObserver::Changes> ParseChanges(
64 const IDLChanges& changes) { 64 const IDLChanges& changes) {
65 scoped_ptr<ProvidedFileSystemObserver::Changes> results( 65 scoped_ptr<ProvidedFileSystemObserver::Changes> results(
66 new ProvidedFileSystemObserver::Changes); 66 new ProvidedFileSystemObserver::Changes);
67 for (const auto& change : changes) { 67 for (const auto& change : changes) {
68 results->push_back(ParseChange(*change)); 68 results->push_back(ParseChange(*change));
69 } 69 }
70 return results; 70 return results;
71 } 71 }
72 72
73 // Converts the file system source from the IDL type to a native type.
74 chromeos::file_system_provider::Source ParseSource(
75 const api::file_system_provider::FileSystemSource& source) {
76 switch (source) {
77 case api::file_system_provider::FILE_SYSTEM_SOURCE_FILE:
78 return chromeos::file_system_provider::SOURCE_FILE;
79 case api::file_system_provider::FILE_SYSTEM_SOURCE_DEVICE:
80 return chromeos::file_system_provider::SOURCE_DEVICE;
81 case api::file_system_provider::FILE_SYSTEM_SOURCE_NETWORK:
82 return chromeos::file_system_provider::SOURCE_NETWORK;
83 case api::file_system_provider::FILE_SYSTEM_SOURCE_NONE:
84 return chromeos::file_system_provider::SOURCE_UNKNOWN;
85 }
86 return chromeos::file_system_provider::SOURCE_UNKNOWN;
87 }
88
89 // Fills the IDL's FileSystemInfo with FSP's ProvidedFileSystemInfo and 73 // Fills the IDL's FileSystemInfo with FSP's ProvidedFileSystemInfo and
90 // Watchers. 74 // Watchers.
91 void FillFileSystemInfo(const ProvidedFileSystemInfo& file_system_info, 75 void FillFileSystemInfo(const ProvidedFileSystemInfo& file_system_info,
92 const Watchers& watchers, 76 const Watchers& watchers,
93 const OpenedFiles& opened_files, 77 const OpenedFiles& opened_files,
94 api::file_system_provider::FileSystemInfo* output) { 78 api::file_system_provider::FileSystemInfo* output) {
95 using api::file_system_provider::Watcher; 79 using api::file_system_provider::Watcher;
96 using api::file_system_provider::OpenedFile; 80 using api::file_system_provider::OpenedFile;
97 81
98 output->file_system_id = file_system_info.file_system_id(); 82 output->file_system_id = file_system_info.file_system_id();
99 output->display_name = file_system_info.display_name(); 83 output->display_name = file_system_info.display_name();
100 output->writable = file_system_info.writable(); 84 output->writable = file_system_info.writable();
101 output->opened_files_limit = file_system_info.opened_files_limit(); 85 output->opened_files_limit = file_system_info.opened_files_limit();
102 switch (file_system_info.source()) {
103 case chromeos::file_system_provider::SOURCE_FILE:
104 output->source = api::file_system_provider::FILE_SYSTEM_SOURCE_FILE;
105 break;
106 case chromeos::file_system_provider::SOURCE_DEVICE:
107 output->source = api::file_system_provider::FILE_SYSTEM_SOURCE_DEVICE;
108 break;
109 case chromeos::file_system_provider::SOURCE_NETWORK:
110 output->source = api::file_system_provider::FILE_SYSTEM_SOURCE_NETWORK;
111 break;
112 case chromeos::file_system_provider::SOURCE_UNKNOWN:
113 output->source = api::file_system_provider::FILE_SYSTEM_SOURCE_NONE;
114 break;
115 }
116 86
117 std::vector<linked_ptr<Watcher>> watcher_items; 87 std::vector<linked_ptr<Watcher>> watcher_items;
118 for (const auto& watcher : watchers) { 88 for (const auto& watcher : watchers) {
119 const linked_ptr<Watcher> watcher_item(new Watcher); 89 const linked_ptr<Watcher> watcher_item(new Watcher);
120 watcher_item->entry_path = watcher.second.entry_path.value(); 90 watcher_item->entry_path = watcher.second.entry_path.value();
121 watcher_item->recursive = watcher.second.recursive; 91 watcher_item->recursive = watcher.second.recursive;
122 if (!watcher.second.last_tag.empty()) 92 if (!watcher.second.last_tag.empty())
123 watcher_item->last_tag.reset(new std::string(watcher.second.last_tag)); 93 watcher_item->last_tag.reset(new std::string(watcher.second.last_tag));
124 watcher_items.push_back(watcher_item); 94 watcher_items.push_back(watcher_item);
125 } 95 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 DCHECK(service); 145 DCHECK(service);
176 146
177 MountOptions options; 147 MountOptions options;
178 options.file_system_id = params->options.file_system_id; 148 options.file_system_id = params->options.file_system_id;
179 options.display_name = params->options.display_name; 149 options.display_name = params->options.display_name;
180 options.writable = params->options.writable; 150 options.writable = params->options.writable;
181 options.opened_files_limit = params->options.opened_files_limit.get() 151 options.opened_files_limit = params->options.opened_files_limit.get()
182 ? *params->options.opened_files_limit.get() 152 ? *params->options.opened_files_limit.get()
183 : 0; 153 : 0;
184 options.supports_notify_tag = params->options.supports_notify_tag; 154 options.supports_notify_tag = params->options.supports_notify_tag;
185 options.source = ParseSource(params->options.source);
186 155
187 const base::File::Error result = 156 const base::File::Error result =
188 service->MountFileSystem(extension_id(), options); 157 service->MountFileSystem(extension_id(), options);
189 if (result != base::File::FILE_OK) { 158 if (result != base::File::FILE_OK) {
190 SetError(FileErrorToString(result)); 159 SetError(FileErrorToString(result));
191 return false; 160 return false;
192 } 161 }
193 162
194 return true; 163 return true;
195 } 164 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 using api::file_system_provider_internal::OperationRequestedError::Params; 338 using api::file_system_provider_internal::OperationRequestedError::Params;
370 scoped_ptr<Params> params(Params::Create(*args_)); 339 scoped_ptr<Params> params(Params::Create(*args_));
371 EXTENSION_FUNCTION_VALIDATE(params); 340 EXTENSION_FUNCTION_VALIDATE(params);
372 341
373 const base::File::Error error = ProviderErrorToFileError(params->error); 342 const base::File::Error error = ProviderErrorToFileError(params->error);
374 return RejectRequest(RequestValue::CreateForOperationError(params.Pass()), 343 return RejectRequest(RequestValue::CreateForOperationError(params.Pass()),
375 error); 344 error);
376 } 345 }
377 346
378 } // namespace extensions 347 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698