Chromium Code Reviews| Index: net/base/platform_mime_util_win.cc |
| =================================================================== |
| --- net/base/platform_mime_util_win.cc (revision 71345) |
| +++ net/base/platform_mime_util_win.cc (working copy) |
| @@ -16,8 +16,10 @@ |
| // check windows registry for file extension's mime type (registry key |
| // names are not case-sensitive). |
| std::wstring value, key = L"." + ext; |
| - base::win::RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).ReadValue( |
| - L"Content Type", &value); |
| + base::win::RegKey mime_key; |
| + LONG ret = mime_key.Open(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ); |
|
grt (UTC plus 2)
2011/01/14 15:53:43
What's the benefit to making this code bigger like
amit
2011/01/15 01:28:11
reverted
|
| + if (ret == ERROR_SUCCESS) |
| + ret = mime_key.ReadValue(L"Content Type", &value); |
| if (!value.empty()) { |
| *result = WideToUTF8(value); |
| return true; |
| @@ -28,8 +30,11 @@ |
| bool PlatformMimeUtil::GetPreferredExtensionForMimeType( |
| const std::string& mime_type, FilePath::StringType* ext) const { |
| std::wstring key(L"MIME\\Database\\Content Type\\" + UTF8ToWide(mime_type)); |
| - if (!base::win::RegKey(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ).ReadValue( |
| - L"Extension", ext)) { |
| + base::win::RegKey extension_key; |
| + LONG ret = extension_key.Open(HKEY_CLASSES_ROOT, key.c_str(), KEY_READ); |
| + if (ret == ERROR_SUCCESS) |
|
grt (UTC plus 2)
2011/01/14 15:53:43
Same comment.
amit
2011/01/15 01:28:11
Done.
|
| + ret = extension_key.ReadValue(L"Extension", ext); |
| + if (ret != ERROR_SUCCESS) { |
| return false; |
| } |
| // Strip off the leading dot, this should always be the case. |