| OLD | NEW |
| 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 "content/public/common/drop_data.h" | 5 #include "content/public/common/drop_data.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/mime_util/mime_util.h" |
| 9 #include "net/base/filename_util.h" |
| 10 #include "net/base/mime_util.h" |
| 11 |
| 7 namespace content { | 12 namespace content { |
| 8 | 13 |
| 9 DropData::DropData() | |
| 10 : did_originate_from_renderer(false), | |
| 11 referrer_policy(blink::WebReferrerPolicyDefault), | |
| 12 key_modifiers(0) {} | |
| 13 | |
| 14 DropData::DropData(const DropData& other) = default; | |
| 15 | |
| 16 DropData::~DropData() { | |
| 17 } | |
| 18 | |
| 19 DropData::Metadata::Metadata() {} | 14 DropData::Metadata::Metadata() {} |
| 20 | 15 |
| 21 // static | 16 // static |
| 22 DropData::Metadata DropData::Metadata::CreateForMimeType( | 17 DropData::Metadata DropData::Metadata::CreateForMimeType( |
| 23 const Kind& kind, | 18 const Kind& kind, |
| 24 const base::string16& mime_type) { | 19 const base::string16& mime_type) { |
| 25 Metadata metadata; | 20 Metadata metadata; |
| 26 metadata.kind = kind; | 21 metadata.kind = kind; |
| 27 metadata.mime_type = mime_type; | 22 metadata.mime_type = mime_type; |
| 28 return metadata; | 23 return metadata; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 43 Metadata metadata; | 38 Metadata metadata; |
| 44 metadata.kind = Kind::FILESYSTEMFILE; | 39 metadata.kind = Kind::FILESYSTEMFILE; |
| 45 metadata.file_system_url = file_system_url; | 40 metadata.file_system_url = file_system_url; |
| 46 return metadata; | 41 return metadata; |
| 47 } | 42 } |
| 48 | 43 |
| 49 DropData::Metadata::Metadata(const DropData::Metadata& other) = default; | 44 DropData::Metadata::Metadata(const DropData::Metadata& other) = default; |
| 50 | 45 |
| 51 DropData::Metadata::~Metadata() {} | 46 DropData::Metadata::~Metadata() {} |
| 52 | 47 |
| 48 DropData::DropData() |
| 49 : did_originate_from_renderer(false), |
| 50 referrer_policy(blink::WebReferrerPolicyDefault), |
| 51 key_modifiers(0) {} |
| 52 |
| 53 DropData::DropData(const DropData& other) = default; |
| 54 |
| 55 DropData::~DropData() {} |
| 56 |
| 57 base::Optional<base::FilePath> DropData::GetSafeFilenameForImageFileContents() |
| 58 const { |
| 59 base::FilePath file_name = net::GenerateFileName( |
| 60 file_contents_source_url, file_contents_content_disposition, |
| 61 std::string(), // referrer_charset |
| 62 std::string(), // suggested_name |
| 63 std::string(), // mime_type |
| 64 std::string()); // default_name |
| 65 std::string mime_type; |
| 66 if (net::GetWellKnownMimeTypeFromExtension(file_contents_filename_extension, |
| 67 &mime_type) && |
| 68 mime_util::IsSupportedImageMimeType(mime_type)) { |
| 69 return file_name.ReplaceExtension(file_contents_filename_extension); |
| 70 } |
| 71 return base::nullopt; |
| 72 } |
| 73 |
| 53 } // namespace content | 74 } // namespace content |
| OLD | NEW |