OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "net/base/platform_mime_util.h" | 7 #include "net/base/platform_mime_util.h" |
8 | 8 |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 if (!value.empty()) { | 21 if (!value.empty()) { |
22 *result = WideToUTF8(value); | 22 *result = WideToUTF8(value); |
23 return true; | 23 return true; |
24 } | 24 } |
25 return false; | 25 return false; |
26 } | 26 } |
27 | 27 |
28 bool PlatformMimeUtil::GetPreferredExtensionForMimeType( | 28 bool PlatformMimeUtil::GetPreferredExtensionForMimeType( |
29 const std::string& mime_type, FilePath::StringType* ext) const { | 29 const std::string& mime_type, FilePath::StringType* ext) const { |
30 std::wstring key(L"MIME\\Database\\Content Type\\" + UTF8ToWide(mime_type)); | 30 std::wstring key(L"MIME\\Database\\Content Type\\" + UTF8ToWide(mime_type)); |
31 if (!base::win::RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).ReadValue( | 31 if (base::win::RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).ReadValue( |
32 L"Extension", ext)) { | 32 L"Extension", ext) != ERROR_SUCCESS) { |
33 return false; | 33 return false; |
34 } | 34 } |
35 // Strip off the leading dot, this should always be the case. | 35 // Strip off the leading dot, this should always be the case. |
36 if (!ext->empty() && ext->at(0) == L'.') | 36 if (!ext->empty() && ext->at(0) == L'.') |
37 ext->erase(ext->begin()); | 37 ext->erase(ext->begin()); |
38 | 38 |
39 return true; | 39 return true; |
40 } | 40 } |
41 | 41 |
42 } // namespace net | 42 } // namespace net |
OLD | NEW |