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

Side by Side Diff: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.cc

Issue 2661003003: mediaview: Recognize more MIME types. (Closed)
Patch Set: Created 3 years, 10 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/arc/fileapi/arc_documents_provider_util.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/arc/fileapi/arc_documents_provider_root.h" 5 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file.h" 12 #include "base/files/file.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" 18 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h"
19 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_u til.h" 19 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_u til.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "net/base/mime_util.h"
22 #include "url/gurl.h" 21 #include "url/gurl.h"
23 22
24 using content::BrowserThread; 23 using content::BrowserThread;
25 using EntryList = storage::AsyncFileUtil::EntryList; 24 using EntryList = storage::AsyncFileUtil::EntryList;
26 25
27 namespace arc { 26 namespace arc {
28 27
29 namespace { 28 namespace {
30 29
31 // Computes a file name for a document. 30 // Computes a file name for a document.
(...skipping 14 matching lines...) Expand all
46 45
47 // Since Chrome detects MIME type from file name extensions, we need to change 46 // Since Chrome detects MIME type from file name extensions, we need to change
48 // the file name extension of the document if it does not match with its MIME 47 // the file name extension of the document if it does not match with its MIME
49 // type. 48 // type.
50 // For example, Audio Media Provider presents a music file with its title as 49 // For example, Audio Media Provider presents a music file with its title as
51 // the file name. 50 // the file name.
52 base::FilePath::StringType extension = 51 base::FilePath::StringType extension =
53 base::ToLowerASCII(base::FilePath(filename).Extension()); 52 base::ToLowerASCII(base::FilePath(filename).Extension());
54 if (!extension.empty()) 53 if (!extension.empty())
55 extension = extension.substr(1); // Strip the leading dot. 54 extension = extension.substr(1); // Strip the leading dot.
56 std::vector<base::FilePath::StringType> possible_extensions; 55 std::vector<base::FilePath::StringType> possible_extensions =
57 net::GetExtensionsForMimeType(document->mime_type, &possible_extensions); 56 GetExtensionsForArcMimeType(document->mime_type);
58 if (!possible_extensions.empty() && 57 if (!possible_extensions.empty() &&
59 std::find(possible_extensions.begin(), possible_extensions.end(), 58 std::find(possible_extensions.begin(), possible_extensions.end(),
60 extension) == possible_extensions.end()) { 59 extension) == possible_extensions.end()) {
61 base::FilePath::StringType new_extension; 60 filename =
62 if (!net::GetPreferredExtensionForMimeType(document->mime_type, 61 base::FilePath(filename).AddExtension(possible_extensions[0]).value();
63 &new_extension)) {
64 new_extension = possible_extensions[0];
65 }
66 filename = base::FilePath(filename).AddExtension(new_extension).value();
67 } 62 }
68 63
69 return filename; 64 return filename;
70 } 65 }
71 66
72 } // namespace 67 } // namespace
73 68
74 ArcDocumentsProviderRoot::ArcDocumentsProviderRoot( 69 ArcDocumentsProviderRoot::ArcDocumentsProviderRoot(
75 const std::string& authority, 70 const std::string& authority,
76 const std::string& root_document_id) 71 const std::string& root_document_id)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 291
297 mapping[filename] = 292 mapping[filename] =
298 ThinDocument{document->document_id, 293 ThinDocument{document->document_id,
299 document->mime_type == kAndroidDirectoryMimeType}; 294 document->mime_type == kAndroidDirectoryMimeType};
300 } 295 }
301 296
302 callback.Run(base::File::FILE_OK, std::move(mapping)); 297 callback.Run(base::File::FILE_OK, std::move(mapping));
303 } 298 }
304 299
305 } // namespace arc 300 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698