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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_tasks.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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
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_manager/private_api_tasks.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_tasks.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "chrome/browser/chromeos/drive/file_system_util.h" 11 #include "chrome/browser/chromeos/drive/file_system_util.h"
12 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 12 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
13 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" 13 #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
14 #include "chrome/browser/extensions/api/file_handlers/mime_util.h" 14 #include "chrome/browser/extensions/api/file_handlers/mime_util.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "net/base/filename_util.h" 17 #include "net/base/filename_util.h"
18 #include "webkit/browser/fileapi/file_system_context.h" 18 #include "storage/browser/fileapi/file_system_context.h"
19 #include "webkit/browser/fileapi/file_system_url.h" 19 #include "storage/browser/fileapi/file_system_url.h"
20 20
21 using content::BrowserThread; 21 using content::BrowserThread;
22 using fileapi::FileSystemURL; 22 using storage::FileSystemURL;
23 23
24 namespace extensions { 24 namespace extensions {
25 namespace { 25 namespace {
26 26
27 // Error messages. 27 // Error messages.
28 const char kInvalidTask[] = "Invalid task: "; 28 const char kInvalidTask[] = "Invalid task: ";
29 const char kInvalidFileUrl[] = "Invalid file URL"; 29 const char kInvalidFileUrl[] = "Invalid file URL";
30 30
31 // Make a set of unique filename suffixes out of the list of file URLs. 31 // Make a set of unique filename suffixes out of the list of file URLs.
32 std::set<std::string> GetUniqueSuffixes( 32 std::set<std::string> GetUniqueSuffixes(
33 const std::vector<std::string>& file_url_list, 33 const std::vector<std::string>& file_url_list,
34 const fileapi::FileSystemContext* context) { 34 const storage::FileSystemContext* context) {
35 std::set<std::string> suffixes; 35 std::set<std::string> suffixes;
36 for (size_t i = 0; i < file_url_list.size(); ++i) { 36 for (size_t i = 0; i < file_url_list.size(); ++i) {
37 const FileSystemURL url = context->CrackURL(GURL(file_url_list[i])); 37 const FileSystemURL url = context->CrackURL(GURL(file_url_list[i]));
38 if (!url.is_valid() || url.path().empty()) 38 if (!url.is_valid() || url.path().empty())
39 return std::set<std::string>(); 39 return std::set<std::string>();
40 // We'll skip empty suffixes. 40 // We'll skip empty suffixes.
41 if (!url.path().Extension().empty()) 41 if (!url.path().Extension().empty())
42 suffixes.insert(url.path().Extension()); 42 suffixes.insert(url.path().Extension());
43 } 43 }
44 return suffixes; 44 return suffixes;
(...skipping 27 matching lines...) Expand all
72 Create(extensions::api::file_browser_private::TASK_RESULT_FAILED); 72 Create(extensions::api::file_browser_private::TASK_RESULT_FAILED);
73 return false; 73 return false;
74 } 74 }
75 75
76 if (params->file_urls.empty()) { 76 if (params->file_urls.empty()) {
77 results_ = Create(extensions::api::file_browser_private::TASK_RESULT_EMPTY); 77 results_ = Create(extensions::api::file_browser_private::TASK_RESULT_EMPTY);
78 SendResponse(true); 78 SendResponse(true);
79 return true; 79 return true;
80 } 80 }
81 81
82 const scoped_refptr<fileapi::FileSystemContext> file_system_context = 82 const scoped_refptr<storage::FileSystemContext> file_system_context =
83 file_manager::util::GetFileSystemContextForRenderViewHost( 83 file_manager::util::GetFileSystemContextForRenderViewHost(
84 GetProfile(), render_view_host()); 84 GetProfile(), render_view_host());
85 85
86 std::vector<FileSystemURL> file_urls; 86 std::vector<FileSystemURL> file_urls;
87 for (size_t i = 0; i < params->file_urls.size(); i++) { 87 for (size_t i = 0; i < params->file_urls.size(); i++) {
88 const FileSystemURL url = 88 const FileSystemURL url =
89 file_system_context->CrackURL(GURL(params->file_urls[i])); 89 file_system_context->CrackURL(GURL(params->file_urls[i]));
90 if (!chromeos::FileSystemBackend::CanHandleURL(url)) { 90 if (!chromeos::FileSystemBackend::CanHandleURL(url)) {
91 SetError(kInvalidFileUrl); 91 SetError(kInvalidFileUrl);
92 results_ = 92 results_ =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 128
129 bool FileBrowserPrivateGetFileTasksFunction::RunAsync() { 129 bool FileBrowserPrivateGetFileTasksFunction::RunAsync() {
130 using extensions::api::file_browser_private::GetFileTasks::Params; 130 using extensions::api::file_browser_private::GetFileTasks::Params;
131 const scoped_ptr<Params> params(Params::Create(*args_)); 131 const scoped_ptr<Params> params(Params::Create(*args_));
132 EXTENSION_FUNCTION_VALIDATE(params); 132 EXTENSION_FUNCTION_VALIDATE(params);
133 133
134 if (params->file_urls.empty()) 134 if (params->file_urls.empty())
135 return false; 135 return false;
136 136
137 const scoped_refptr<fileapi::FileSystemContext> file_system_context = 137 const scoped_refptr<storage::FileSystemContext> file_system_context =
138 file_manager::util::GetFileSystemContextForRenderViewHost( 138 file_manager::util::GetFileSystemContextForRenderViewHost(
139 GetProfile(), render_view_host()); 139 GetProfile(), render_view_host());
140 140
141 // Collect all the URLs, convert them to GURLs, and crack all the urls into 141 // Collect all the URLs, convert them to GURLs, and crack all the urls into
142 // file paths. 142 // file paths.
143 for (size_t i = 0; i < params->file_urls.size(); ++i) { 143 for (size_t i = 0; i < params->file_urls.size(); ++i) {
144 const GURL file_url(params->file_urls[i]); 144 const GURL file_url(params->file_urls[i]);
145 fileapi::FileSystemURL file_system_url( 145 storage::FileSystemURL file_system_url(
146 file_system_context->CrackURL(file_url)); 146 file_system_context->CrackURL(file_url));
147 if (!chromeos::FileSystemBackend::CanHandleURL(file_system_url)) 147 if (!chromeos::FileSystemBackend::CanHandleURL(file_system_url))
148 continue; 148 continue;
149 file_urls_.push_back(file_url); 149 file_urls_.push_back(file_url);
150 local_paths_.push_back(file_system_url.path()); 150 local_paths_.push_back(file_system_url.path());
151 } 151 }
152 152
153 collector_.reset(new app_file_handler_util::MimeTypeCollector(GetProfile())); 153 collector_.reset(new app_file_handler_util::MimeTypeCollector(GetProfile()));
154 collector_->CollectForLocalPaths( 154 collector_->CollectForLocalPaths(
155 local_paths_, 155 local_paths_,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 results_ = extensions::api::file_browser_private::GetFileTasks::Results:: 192 results_ = extensions::api::file_browser_private::GetFileTasks::Results::
193 Create(results); 193 Create(results);
194 SendResponse(true); 194 SendResponse(true);
195 } 195 }
196 196
197 bool FileBrowserPrivateSetDefaultTaskFunction::RunSync() { 197 bool FileBrowserPrivateSetDefaultTaskFunction::RunSync() {
198 using extensions::api::file_browser_private::SetDefaultTask::Params; 198 using extensions::api::file_browser_private::SetDefaultTask::Params;
199 const scoped_ptr<Params> params(Params::Create(*args_)); 199 const scoped_ptr<Params> params(Params::Create(*args_));
200 EXTENSION_FUNCTION_VALIDATE(params); 200 EXTENSION_FUNCTION_VALIDATE(params);
201 201
202 const scoped_refptr<fileapi::FileSystemContext> file_system_context = 202 const scoped_refptr<storage::FileSystemContext> file_system_context =
203 file_manager::util::GetFileSystemContextForRenderViewHost( 203 file_manager::util::GetFileSystemContextForRenderViewHost(
204 GetProfile(), render_view_host()); 204 GetProfile(), render_view_host());
205 205
206 const std::set<std::string> suffixes = 206 const std::set<std::string> suffixes =
207 GetUniqueSuffixes(params->file_urls, file_system_context.get()); 207 GetUniqueSuffixes(params->file_urls, file_system_context.get());
208 208
209 // MIME types are an optional parameter. 209 // MIME types are an optional parameter.
210 std::set<std::string> mime_types; 210 std::set<std::string> mime_types;
211 if (params->mime_types && !params->mime_types->empty()) { 211 if (params->mime_types && !params->mime_types->empty()) {
212 if (params->mime_types->size() != params->file_urls.size()) 212 if (params->mime_types->size() != params->file_urls.size())
(...skipping 11 matching lines...) Expand all
224 SetResult(new base::FundamentalValue(true)); 224 SetResult(new base::FundamentalValue(true));
225 return true; 225 return true;
226 } 226 }
227 227
228 file_manager::file_tasks::UpdateDefaultTask( 228 file_manager::file_tasks::UpdateDefaultTask(
229 GetProfile()->GetPrefs(), params->task_id, suffixes, mime_types); 229 GetProfile()->GetPrefs(), params->task_id, suffixes, mime_types);
230 return true; 230 return true;
231 } 231 }
232 232
233 } // namespace extensions 233 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698