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

Side by Side Diff: chrome/browser/chromeos/file_manager/filesystem_api_util.cc

Issue 589473002: Files.app: Enable externalfile: protocol for MTP volumes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit fix Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/file_manager/filesystem_api_util.h" 5 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 17 matching lines...) Expand all
28 namespace { 28 namespace {
29 29
30 // Helper function used to implement GetNonNativeLocalPathMimeType. It extracts 30 // Helper function used to implement GetNonNativeLocalPathMimeType. It extracts
31 // the mime type from the passed Drive resource entry. 31 // the mime type from the passed Drive resource entry.
32 void GetMimeTypeAfterGetResourceEntryForDrive( 32 void GetMimeTypeAfterGetResourceEntryForDrive(
33 const base::Callback<void(bool, const std::string&)>& callback, 33 const base::Callback<void(bool, const std::string&)>& callback,
34 drive::FileError error, 34 drive::FileError error,
35 scoped_ptr<drive::ResourceEntry> entry) { 35 scoped_ptr<drive::ResourceEntry> entry) {
36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
37 37
38 if (error != drive::FILE_ERROR_OK || !entry->has_file_specific_info()) { 38 if (error != drive::FILE_ERROR_OK || !entry->has_file_specific_info() ||
39 entry->file_specific_info().content_mime_type().empty()) {
mtomasz 2014/09/25 06:48:09 Could you please extract it into a separate CL? Th
hirono 2014/09/25 07:38:07 I got it. Let me separate.
39 callback.Run(false, std::string()); 40 callback.Run(false, std::string());
40 return; 41 return;
41 } 42 }
42 callback.Run(true, entry->file_specific_info().content_mime_type()); 43 callback.Run(true, entry->file_specific_info().content_mime_type());
43 } 44 }
44 45
45 // Helper function used to implement GetNonNativeLocalPathMimeType. It extracts 46 // Helper function used to implement GetNonNativeLocalPathMimeType. It extracts
46 // the mime type from the passed metadata from a providing extension. 47 // the mime type from the passed metadata from a providing extension.
47 void GetMimeTypeAfterGetMetadataForProvidedFileSystem( 48 void GetMimeTypeAfterGetMetadataForProvidedFileSystem(
48 const base::Callback<void(bool, const std::string&)>& callback, 49 const base::Callback<void(bool, const std::string&)>& callback,
49 scoped_ptr<chromeos::file_system_provider::EntryMetadata> metadata, 50 scoped_ptr<chromeos::file_system_provider::EntryMetadata> metadata,
50 base::File::Error result) { 51 base::File::Error result) {
51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 52 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
52 53
53 if (result != base::File::FILE_OK) { 54 if (result != base::File::FILE_OK || metadata->mime_type.empty()) {
54 callback.Run(false, std::string()); 55 callback.Run(false, std::string());
55 return; 56 return;
56 } 57 }
57 callback.Run(true, metadata->mime_type); 58 callback.Run(true, metadata->mime_type);
58 } 59 }
59 60
60 // Helper function to converts a callback that takes boolean value to that takes 61 // Helper function to converts a callback that takes boolean value to that takes
61 // File::Error, by regarding FILE_OK as the only successful value. 62 // File::Error, by regarding FILE_OK as the only successful value.
62 void BoolCallbackAsFileErrorCallback( 63 void BoolCallbackAsFileErrorCallback(
63 const base::Callback<void(bool)>& callback, 64 const base::Callback<void(bool)>& callback,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 171
171 parser.file_system()->GetMetadata( 172 parser.file_system()->GetMetadata(
172 parser.file_path(), 173 parser.file_path(),
173 chromeos::file_system_provider::ProvidedFileSystemInterface:: 174 chromeos::file_system_provider::ProvidedFileSystemInterface::
174 METADATA_FIELD_DEFAULT, 175 METADATA_FIELD_DEFAULT,
175 base::Bind(&GetMimeTypeAfterGetMetadataForProvidedFileSystem, 176 base::Bind(&GetMimeTypeAfterGetMetadataForProvidedFileSystem,
176 callback)); 177 callback));
177 return; 178 return;
178 } 179 }
179 180
180 // As a fallback just return success with an empty mime type value. 181 // As a fallback just return failure with an empty mime type value.
mtomasz 2014/09/25 06:48:09 nit: The comment doesn't make much sense anymore.
hirono 2014/09/25 07:38:07 Let me handle this in the extracted patch.
181 content::BrowserThread::PostTask( 182 content::BrowserThread::PostTask(
182 content::BrowserThread::UI, 183 content::BrowserThread::UI,
183 FROM_HERE, 184 FROM_HERE,
184 base::Bind(callback, true /* success */, std::string())); 185 base::Bind(callback, false /* failure */, std::string()));
185 } 186 }
186 187
187 void IsNonNativeLocalPathDirectory( 188 void IsNonNativeLocalPathDirectory(
188 Profile* profile, 189 Profile* profile,
189 const base::FilePath& path, 190 const base::FilePath& path,
190 const base::Callback<void(bool)>& callback) { 191 const base::Callback<void(bool)>& callback) {
191 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 192 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
192 DCHECK(IsUnderNonNativeLocalPath(profile, path)); 193 DCHECK(IsUnderNonNativeLocalPath(profile, path));
193 194
194 GURL url; 195 GURL url;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 content::BrowserThread::IO, 239 content::BrowserThread::IO,
239 FROM_HERE, 240 FROM_HERE,
240 base::Bind(&PrepareFileOnIOThread, 241 base::Bind(&PrepareFileOnIOThread,
241 make_scoped_refptr(context), 242 make_scoped_refptr(context),
242 context->CrackURL(url), 243 context->CrackURL(url),
243 google_apis::CreateRelayCallback(callback))); 244 google_apis::CreateRelayCallback(callback)));
244 } 245 }
245 246
246 } // namespace util 247 } // namespace util
247 } // namespace file_manager 248 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698