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

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

Issue 513683002: [fsp] Add support for providing thumbnails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a test. Created 6 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_system_provider/fake_provided_file_system.h » ('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 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 28 matching lines...) Expand all
39 callback.Run(false, std::string()); 39 callback.Run(false, std::string());
40 return; 40 return;
41 } 41 }
42 callback.Run(true, entry->file_specific_info().content_mime_type()); 42 callback.Run(true, entry->file_specific_info().content_mime_type());
43 } 43 }
44 44
45 // Helper function used to implement GetNonNativeLocalPathMimeType. It extracts 45 // Helper function used to implement GetNonNativeLocalPathMimeType. It extracts
46 // the mime type from the passed metadata from a providing extension. 46 // the mime type from the passed metadata from a providing extension.
47 void GetMimeTypeAfterGetMetadataForProvidedFileSystem( 47 void GetMimeTypeAfterGetMetadataForProvidedFileSystem(
48 const base::Callback<void(bool, const std::string&)>& callback, 48 const base::Callback<void(bool, const std::string&)>& callback,
49 const chromeos::file_system_provider::EntryMetadata& metadata, 49 scoped_ptr<chromeos::file_system_provider::EntryMetadata> metadata,
50 base::File::Error result) { 50 base::File::Error result) {
51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
52 52
53 if (result != base::File::FILE_OK) { 53 if (result != base::File::FILE_OK) {
54 callback.Run(false, std::string()); 54 callback.Run(false, std::string());
55 return; 55 return;
56 } 56 }
57 callback.Run(true, metadata.mime_type); 57 callback.Run(true, metadata->mime_type);
58 } 58 }
59 59
60 // Helper function to converts a callback that takes boolean value to that takes 60 // 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. 61 // File::Error, by regarding FILE_OK as the only successful value.
62 void BoolCallbackAsFileErrorCallback( 62 void BoolCallbackAsFileErrorCallback(
63 const base::Callback<void(bool)>& callback, 63 const base::Callback<void(bool)>& callback,
64 base::File::Error error) { 64 base::File::Error error) {
65 return callback.Run(error == base::File::FILE_OK); 65 return callback.Run(error == base::File::FILE_OK);
66 } 66 }
67 67
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 if (!parser.Parse()) { 163 if (!parser.Parse()) {
164 content::BrowserThread::PostTask( 164 content::BrowserThread::PostTask(
165 content::BrowserThread::UI, 165 content::BrowserThread::UI,
166 FROM_HERE, 166 FROM_HERE,
167 base::Bind(callback, false, std::string())); 167 base::Bind(callback, false, std::string()));
168 return; 168 return;
169 } 169 }
170 170
171 parser.file_system()->GetMetadata( 171 parser.file_system()->GetMetadata(
172 parser.file_path(), 172 parser.file_path(),
173 chromeos::file_system_provider::ProvidedFileSystemInterface::
174 METADATA_FIELD_DEFAULT,
173 base::Bind(&GetMimeTypeAfterGetMetadataForProvidedFileSystem, 175 base::Bind(&GetMimeTypeAfterGetMetadataForProvidedFileSystem,
174 callback)); 176 callback));
175 return; 177 return;
176 } 178 }
177 179
178 // As a fallback just return success with an empty mime type value. 180 // As a fallback just return success with an empty mime type value.
179 content::BrowserThread::PostTask( 181 content::BrowserThread::PostTask(
180 content::BrowserThread::UI, 182 content::BrowserThread::UI,
181 FROM_HERE, 183 FROM_HERE,
182 base::Bind(callback, true /* success */, std::string())); 184 base::Bind(callback, true /* success */, std::string()));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 content::BrowserThread::IO, 238 content::BrowserThread::IO,
237 FROM_HERE, 239 FROM_HERE,
238 base::Bind(&PrepareFileOnIOThread, 240 base::Bind(&PrepareFileOnIOThread,
239 make_scoped_refptr(context), 241 make_scoped_refptr(context),
240 context->CrackURL(url), 242 context->CrackURL(url),
241 google_apis::CreateRelayCallback(callback))); 243 google_apis::CreateRelayCallback(callback)));
242 } 244 }
243 245
244 } // namespace util 246 } // namespace util
245 } // namespace file_manager 247 } // namespace file_manager
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/file_system_provider/fake_provided_file_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698