| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/importer/firefox_importer_utils.h" | 5 #include "chrome/common/importer/firefox_importer_utils.h" |
| 6 | 6 |
| 7 #include <shlobj.h> | 7 #include <shlobj.h> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 &ver_buffer_length, NULL); | 40 &ver_buffer_length, NULL); |
| 41 if (result != ERROR_SUCCESS) | 41 if (result != ERROR_SUCCESS) |
| 42 continue; | 42 continue; |
| 43 highest_version = std::max(highest_version, _wtoi(ver_buffer)); | 43 highest_version = std::max(highest_version, _wtoi(ver_buffer)); |
| 44 } | 44 } |
| 45 return highest_version; | 45 return highest_version; |
| 46 } | 46 } |
| 47 | 47 |
| 48 base::FilePath GetFirefoxInstallPathFromRegistry() { | 48 base::FilePath GetFirefoxInstallPathFromRegistry() { |
| 49 // Detects the path that Firefox is installed in. | 49 // Detects the path that Firefox is installed in. |
| 50 string16 registry_path = kFirefoxPath; | 50 base::string16 registry_path = kFirefoxPath; |
| 51 wchar_t buffer[MAX_PATH]; | 51 wchar_t buffer[MAX_PATH]; |
| 52 DWORD buffer_length = sizeof(buffer); | 52 DWORD buffer_length = sizeof(buffer); |
| 53 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, registry_path.c_str(), | 53 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, registry_path.c_str(), |
| 54 KEY_READ); | 54 KEY_READ); |
| 55 LONG result = reg_key.ReadValue(kCurrentVersion, buffer, | 55 LONG result = reg_key.ReadValue(kCurrentVersion, buffer, |
| 56 &buffer_length, NULL); | 56 &buffer_length, NULL); |
| 57 if (result != ERROR_SUCCESS) | 57 if (result != ERROR_SUCCESS) |
| 58 return base::FilePath(); | 58 return base::FilePath(); |
| 59 | 59 |
| 60 registry_path += L"\\" + string16(buffer) + L"\\Main"; | 60 registry_path += L"\\" + base::string16(buffer) + L"\\Main"; |
| 61 buffer_length = sizeof(buffer); | 61 buffer_length = sizeof(buffer); |
| 62 base::win::RegKey reg_key_directory(HKEY_LOCAL_MACHINE, | 62 base::win::RegKey reg_key_directory(HKEY_LOCAL_MACHINE, |
| 63 registry_path.c_str(), KEY_READ); | 63 registry_path.c_str(), KEY_READ); |
| 64 result = reg_key_directory.ReadValue(L"Install Directory", buffer, | 64 result = reg_key_directory.ReadValue(L"Install Directory", buffer, |
| 65 &buffer_length, NULL); | 65 &buffer_length, NULL); |
| 66 | 66 |
| 67 return (result != ERROR_SUCCESS) ? base::FilePath() : base::FilePath(buffer); | 67 return (result != ERROR_SUCCESS) ? base::FilePath() : base::FilePath(buffer); |
| 68 } | 68 } |
| 69 | 69 |
| 70 base::FilePath GetProfilesINI() { | 70 base::FilePath GetProfilesINI() { |
| 71 base::FilePath ini_file; | 71 base::FilePath ini_file; |
| 72 // The default location of the profile folder containing user data is | 72 // The default location of the profile folder containing user data is |
| 73 // under the "Application Data" folder in Windows XP, Vista, and 7. | 73 // under the "Application Data" folder in Windows XP, Vista, and 7. |
| 74 if (!PathService::Get(base::DIR_APP_DATA, &ini_file)) | 74 if (!PathService::Get(base::DIR_APP_DATA, &ini_file)) |
| 75 return base::FilePath(); | 75 return base::FilePath(); |
| 76 | 76 |
| 77 ini_file = ini_file.AppendASCII("Mozilla"); | 77 ini_file = ini_file.AppendASCII("Mozilla"); |
| 78 ini_file = ini_file.AppendASCII("Firefox"); | 78 ini_file = ini_file.AppendASCII("Firefox"); |
| 79 ini_file = ini_file.AppendASCII("profiles.ini"); | 79 ini_file = ini_file.AppendASCII("profiles.ini"); |
| 80 | 80 |
| 81 return base::PathExists(ini_file) ? ini_file : base::FilePath(); | 81 return base::PathExists(ini_file) ? ini_file : base::FilePath(); |
| 82 } | 82 } |
| OLD | NEW |