OLD | NEW |
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> | |
8 #include <utility> | 7 #include <utility> |
9 | 8 |
10 #include "base/bind.h" | 9 #include "base/bind.h" |
11 #include "base/callback.h" | 10 #include "base/callback.h" |
12 #include "base/files/file.h" | 11 #include "base/files/file.h" |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/stl_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 "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
22 using content::BrowserThread; | 22 using content::BrowserThread; |
23 using EntryList = storage::AsyncFileUtil::EntryList; | 23 using EntryList = storage::AsyncFileUtil::EntryList; |
24 | 24 |
(...skipping 22 matching lines...) Expand all Loading... |
47 // type. | 47 // type. |
48 // For example, Audio Media Provider presents a music file with its title as | 48 // For example, Audio Media Provider presents a music file with its title as |
49 // the file name. | 49 // the file name. |
50 base::FilePath::StringType extension = | 50 base::FilePath::StringType extension = |
51 base::ToLowerASCII(base::FilePath(filename).Extension()); | 51 base::ToLowerASCII(base::FilePath(filename).Extension()); |
52 if (!extension.empty()) | 52 if (!extension.empty()) |
53 extension = extension.substr(1); // Strip the leading dot. | 53 extension = extension.substr(1); // Strip the leading dot. |
54 std::vector<base::FilePath::StringType> possible_extensions = | 54 std::vector<base::FilePath::StringType> possible_extensions = |
55 GetExtensionsForArcMimeType(document->mime_type); | 55 GetExtensionsForArcMimeType(document->mime_type); |
56 if (!possible_extensions.empty() && | 56 if (!possible_extensions.empty() && |
57 std::find(possible_extensions.begin(), possible_extensions.end(), | 57 !base::ContainsValue(possible_extensions, extension)) { |
58 extension) == possible_extensions.end()) { | |
59 filename = | 58 filename = |
60 base::FilePath(filename).AddExtension(possible_extensions[0]).value(); | 59 base::FilePath(filename).AddExtension(possible_extensions[0]).value(); |
61 } | 60 } |
62 | 61 |
63 return filename; | 62 return filename; |
64 } | 63 } |
65 | 64 |
66 } // namespace | 65 } // namespace |
67 | 66 |
68 // static | 67 // static |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 423 |
425 mapping[filename] = | 424 mapping[filename] = |
426 ThinDocument{document->document_id, | 425 ThinDocument{document->document_id, |
427 document->mime_type == kAndroidDirectoryMimeType}; | 426 document->mime_type == kAndroidDirectoryMimeType}; |
428 } | 427 } |
429 | 428 |
430 callback.Run(base::File::FILE_OK, std::move(mapping)); | 429 callback.Run(base::File::FILE_OK, std::move(mapping)); |
431 } | 430 } |
432 | 431 |
433 } // namespace arc | 432 } // namespace arc |
OLD | NEW |