| 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/utility/importer/ie_importer_win.h" | 5 #include "chrome/utility/importer/ie_importer_win.h" |
| 6 | 6 |
| 7 #include <ole2.h> | 7 #include <ole2.h> |
| 8 #include <intshcut.h> | 8 #include <intshcut.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #include <urlhist.h> | 10 #include <urlhist.h> |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 std::vector<uint8> blob(blob_length); | 218 std::vector<uint8> blob(blob_length); |
| 219 if (blob_length > 0 && | 219 if (blob_length > 0 && |
| 220 key.ReadValue(L"Order", reinterpret_cast<DWORD*>(&blob[0]), | 220 key.ReadValue(L"Order", reinterpret_cast<DWORD*>(&blob[0]), |
| 221 &blob_length, NULL) == ERROR_SUCCESS) { | 221 &blob_length, NULL) == ERROR_SUCCESS) { |
| 222 if (!ParseFavoritesOrderBlob(importer, blob, path, sort_index)) | 222 if (!ParseFavoritesOrderBlob(importer, blob, path, sort_index)) |
| 223 return false; | 223 return false; |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 | 226 |
| 227 // Recursively parse subfolders. | 227 // Recursively parse subfolders. |
| 228 for (base::win::RegistryKeyIterator child(key.Handle(), L""); | 228 for (base::win::RegistryKeyIterator child(key.Handle(), L"", 0); |
| 229 child.Valid() && !importer->cancelled(); | 229 child.Valid() && !importer->cancelled(); |
| 230 ++child) { | 230 ++child) { |
| 231 base::win::RegKey subkey(key.Handle(), child.Name(), KEY_READ); | 231 base::win::RegKey subkey(key.Handle(), child.Name(), KEY_READ); |
| 232 if (subkey.Valid()) { | 232 if (subkey.Valid()) { |
| 233 base::FilePath subpath(path.Append(child.Name())); | 233 base::FilePath subpath(path.Append(child.Name())); |
| 234 if (!ParseFavoritesOrderRegistryTree(importer, subkey, subpath, | 234 if (!ParseFavoritesOrderRegistryTree(importer, subkey, subpath, |
| 235 sort_index)) { | 235 sort_index)) { |
| 236 return false; | 236 return false; |
| 237 } | 237 } |
| 238 } | 238 } |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 } | 639 } |
| 640 } | 640 } |
| 641 | 641 |
| 642 bridge_->SetPasswordForm(form); | 642 bridge_->SetPasswordForm(form); |
| 643 } | 643 } |
| 644 } | 644 } |
| 645 | 645 |
| 646 void IEImporter::ImportPasswordsIE7() { | 646 void IEImporter::ImportPasswordsIE7() { |
| 647 base::string16 key_path(importer::GetIE7PasswordsKey()); | 647 base::string16 key_path(importer::GetIE7PasswordsKey()); |
| 648 base::win::RegKey key(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ); | 648 base::win::RegKey key(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ); |
| 649 base::win::RegistryValueIterator reg_iterator(HKEY_CURRENT_USER, | 649 base::win::RegistryValueIterator reg_iterator( |
| 650 key_path.c_str()); | 650 HKEY_CURRENT_USER, key_path.c_str(), 0); |
| 651 importer::ImporterIE7PasswordInfo password_info; | 651 importer::ImporterIE7PasswordInfo password_info; |
| 652 while (reg_iterator.Valid() && !cancelled()) { | 652 while (reg_iterator.Valid() && !cancelled()) { |
| 653 // Get the size of the encrypted data. | 653 // Get the size of the encrypted data. |
| 654 DWORD value_len = 0; | 654 DWORD value_len = 0; |
| 655 key.ReadValue(reg_iterator.Name(), NULL, &value_len, NULL); | 655 key.ReadValue(reg_iterator.Name(), NULL, &value_len, NULL); |
| 656 if (value_len) { | 656 if (value_len) { |
| 657 // Query the encrypted data. | 657 // Query the encrypted data. |
| 658 password_info.encrypted_data.resize(value_len); | 658 password_info.encrypted_data.resize(value_len); |
| 659 if (key.ReadValue(reg_iterator.Name(), | 659 if (key.ReadValue(reg_iterator.Name(), |
| 660 &password_info.encrypted_data.front(), | 660 &password_info.encrypted_data.front(), |
| 661 &value_len, NULL) == ERROR_SUCCESS) { | 661 &value_len, NULL) == ERROR_SUCCESS) { |
| 662 password_info.url_hash = reg_iterator.Name(); | 662 password_info.url_hash = reg_iterator.Name(); |
| 663 password_info.date_created = base::Time::Now(); | 663 password_info.date_created = base::Time::Now(); |
| 664 | 664 |
| 665 bridge_->AddIE7PasswordInfo(password_info); | 665 bridge_->AddIE7PasswordInfo(password_info); |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 | 668 |
| 669 ++reg_iterator; | 669 ++reg_iterator; |
| 670 } | 670 } |
| 671 } | 671 } |
| 672 | 672 |
| 673 void IEImporter::ImportSearchEngines() { | 673 void IEImporter::ImportSearchEngines() { |
| 674 // On IE, search engines are stored in the registry, under: | 674 // On IE, search engines are stored in the registry, under: |
| 675 // Software\Microsoft\Internet Explorer\SearchScopes | 675 // Software\Microsoft\Internet Explorer\SearchScopes |
| 676 // Each key represents a search engine. The URL value contains the URL and | 676 // Each key represents a search engine. The URL value contains the URL and |
| 677 // the DisplayName the name. | 677 // the DisplayName the name. |
| 678 typedef std::map<std::string, base::string16> SearchEnginesMap; | 678 typedef std::map<std::string, base::string16> SearchEnginesMap; |
| 679 SearchEnginesMap search_engines_map; | 679 SearchEnginesMap search_engines_map; |
| 680 for (base::win::RegistryKeyIterator key_iter(HKEY_CURRENT_USER, | 680 for (base::win::RegistryKeyIterator key_iter( |
| 681 kSearchScopePath); key_iter.Valid(); ++key_iter) { | 681 HKEY_CURRENT_USER, kSearchScopePath, 0); |
| 682 key_iter.Valid(); |
| 683 ++key_iter) { |
| 682 base::string16 sub_key_name = kSearchScopePath; | 684 base::string16 sub_key_name = kSearchScopePath; |
| 683 sub_key_name.append(L"\\").append(key_iter.Name()); | 685 sub_key_name.append(L"\\").append(key_iter.Name()); |
| 684 base::win::RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(), | 686 base::win::RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(), |
| 685 KEY_READ); | 687 KEY_READ); |
| 686 base::string16 wide_url; | 688 base::string16 wide_url; |
| 687 if ((sub_key.ReadValue(L"URL", &wide_url) != ERROR_SUCCESS) || | 689 if ((sub_key.ReadValue(L"URL", &wide_url) != ERROR_SUCCESS) || |
| 688 wide_url.empty()) { | 690 wide_url.empty()) { |
| 689 VLOG(1) << "No URL for IE search engine at " << key_iter.Name(); | 691 VLOG(1) << "No URL for IE search engine at " << key_iter.Name(); |
| 690 continue; | 692 continue; |
| 691 } | 693 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 static int version = -1; | 874 static int version = -1; |
| 873 if (version < 0) { | 875 if (version < 0) { |
| 874 wchar_t buffer[128]; | 876 wchar_t buffer[128]; |
| 875 DWORD buffer_length = sizeof(buffer); | 877 DWORD buffer_length = sizeof(buffer); |
| 876 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); | 878 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); |
| 877 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 879 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
| 878 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 880 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
| 879 } | 881 } |
| 880 return version; | 882 return version; |
| 881 } | 883 } |
| OLD | NEW |