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/browser/importer/ie_importer.h" | 5 #include "chrome/browser/importer/ie_importer.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 13 matching lines...) Expand all Loading... |
24 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
25 #include "base/win/registry.h" | 25 #include "base/win/registry.h" |
26 #include "base/win/scoped_co_mem.h" | 26 #include "base/win/scoped_co_mem.h" |
27 #include "base/win/scoped_comptr.h" | 27 #include "base/win/scoped_comptr.h" |
28 #include "base/win/scoped_handle.h" | 28 #include "base/win/scoped_handle.h" |
29 #include "base/win/scoped_propvariant.h" | 29 #include "base/win/scoped_propvariant.h" |
30 #include "base/win/windows_version.h" | 30 #include "base/win/windows_version.h" |
31 #include "chrome/browser/bookmarks/imported_bookmark_entry.h" | 31 #include "chrome/browser/bookmarks/imported_bookmark_entry.h" |
32 #include "chrome/browser/favicon/favicon_util.h" | 32 #include "chrome/browser/favicon/favicon_util.h" |
33 #include "chrome/browser/favicon/imported_favicon_usage.h" | 33 #include "chrome/browser/favicon/imported_favicon_usage.h" |
| 34 #include "chrome/browser/importer/ie_importer_utils_win.h" |
34 #include "chrome/browser/importer/importer_bridge.h" | 35 #include "chrome/browser/importer/importer_bridge.h" |
35 #include "chrome/browser/importer/importer_data_types.h" | 36 #include "chrome/browser/importer/importer_data_types.h" |
36 #include "chrome/browser/importer/pstore_declarations.h" | 37 #include "chrome/browser/importer/pstore_declarations.h" |
37 #include "chrome/browser/search_engines/template_url.h" | 38 #include "chrome/browser/search_engines/template_url.h" |
38 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 39 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
39 #include "chrome/browser/search_engines/template_url_service.h" | 40 #include "chrome/browser/search_engines/template_url_service.h" |
40 #include "chrome/common/time_format.h" | 41 #include "chrome/common/time_format.h" |
41 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
42 #include "components/webdata/encryptor/ie7_password.h" | 43 #include "components/webdata/encryptor/ie7_password.h" |
43 #include "content/public/common/password_form.h" | 44 #include "content/public/common/password_form.h" |
44 #include "googleurl/src/gurl.h" | 45 #include "googleurl/src/gurl.h" |
45 #include "grit/generated_resources.h" | 46 #include "grit/generated_resources.h" |
46 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
47 | 48 |
48 namespace { | 49 namespace { |
49 | 50 |
50 // Registry key paths from which we import IE settings. | 51 // Registry key paths from which we import IE settings. |
51 const char16 kStorage2Path[] = | 52 const char16 kStorage2Path[] = |
52 L"Software\\Microsoft\\Internet Explorer\\IntelliForms\\Storage2"; | 53 L"Software\\Microsoft\\Internet Explorer\\IntelliForms\\Storage2"; |
53 const char16 kSearchScopePath[] = | 54 const char16 kSearchScopePath[] = |
54 L"Software\\Microsoft\\Internet Explorer\\SearchScopes"; | 55 L"Software\\Microsoft\\Internet Explorer\\SearchScopes"; |
55 const char16 kIESettingsMain[] = | 56 const char16 kIESettingsMain[] = |
56 L"Software\\Microsoft\\Internet Explorer\\Main"; | 57 L"Software\\Microsoft\\Internet Explorer\\Main"; |
57 const char16 kIEFavoritesOrderKey[] = | |
58 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\" | |
59 L"MenuOrder\\Favorites"; | |
60 const char16 kIEVersionKey[] = | 58 const char16 kIEVersionKey[] = |
61 L"Software\\Microsoft\\Internet Explorer"; | 59 L"Software\\Microsoft\\Internet Explorer"; |
62 const char16 kIEToolbarKey[] = | 60 const char16 kIEToolbarKey[] = |
63 L"Software\\Microsoft\\Internet Explorer\\Toolbar"; | 61 L"Software\\Microsoft\\Internet Explorer\\Toolbar"; |
64 | 62 |
65 // NTFS stream name of favicon image data. | 63 // NTFS stream name of favicon image data. |
66 const char16 kFaviconStreamName[] = L":favicon:$DATA"; | 64 const char16 kFaviconStreamName[] = L":favicon:$DATA"; |
67 | 65 |
68 // A struct that hosts the information of AutoComplete data in PStore. | 66 // A struct that hosts the information of AutoComplete data in PStore. |
69 struct AutoCompleteInfo { | 67 struct AutoCompleteInfo { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return false; | 243 return false; |
246 } | 244 } |
247 } | 245 } |
248 } | 246 } |
249 return true; | 247 return true; |
250 } | 248 } |
251 | 249 |
252 bool ParseFavoritesOrderInfo( | 250 bool ParseFavoritesOrderInfo( |
253 const Importer* importer, | 251 const Importer* importer, |
254 std::map<base::FilePath, uint32>* sort_index) WARN_UNUSED_RESULT { | 252 std::map<base::FilePath, uint32>* sort_index) WARN_UNUSED_RESULT { |
255 base::win::RegKey key(HKEY_CURRENT_USER, kIEFavoritesOrderKey, KEY_READ); | 253 base::string16 key_path(importer::GetIEFavoritesOrderKey()); |
| 254 base::win::RegKey key(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ); |
256 if (!key.Valid()) | 255 if (!key.Valid()) |
257 return false; | 256 return false; |
258 return ParseFavoritesOrderRegistryTree(importer, key, base::FilePath(), | 257 return ParseFavoritesOrderRegistryTree(importer, key, base::FilePath(), |
259 sort_index); | 258 sort_index); |
260 } | 259 } |
261 | 260 |
262 // Reads the sort order from registry. If failed, we don't touch the list | 261 // Reads the sort order from registry. If failed, we don't touch the list |
263 // and use the default (alphabetical) order. | 262 // and use the default (alphabetical) order. |
264 void SortBookmarksInIEOrder( | 263 void SortBookmarksInIEOrder( |
265 const Importer* importer, | 264 const Importer* importer, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 413 |
415 IEImporter::IEImporter() { | 414 IEImporter::IEImporter() { |
416 } | 415 } |
417 | 416 |
418 void IEImporter::StartImport(const importer::SourceProfile& source_profile, | 417 void IEImporter::StartImport(const importer::SourceProfile& source_profile, |
419 uint16 items, | 418 uint16 items, |
420 ImporterBridge* bridge) { | 419 ImporterBridge* bridge) { |
421 bridge_ = bridge; | 420 bridge_ = bridge; |
422 source_path_ = source_profile.source_path; | 421 source_path_ = source_profile.source_path; |
423 | 422 |
424 // If there is indication that an override is required, but we fail to set it, | |
425 // prefer returning early to running the test with whatever is in the real | |
426 // registry. | |
427 if (!test_registry_overrider_.StartRegistryOverrideIfNeeded()) { | |
428 NOTREACHED(); | |
429 return; | |
430 } | |
431 | |
432 bridge_->NotifyStarted(); | 423 bridge_->NotifyStarted(); |
433 | 424 |
434 if ((items & importer::HOME_PAGE) && !cancelled()) | 425 if ((items & importer::HOME_PAGE) && !cancelled()) |
435 ImportHomepage(); // Doesn't have a UI item. | 426 ImportHomepage(); // Doesn't have a UI item. |
436 // The order here is important! | 427 // The order here is important! |
437 if ((items & importer::HISTORY) && !cancelled()) { | 428 if ((items & importer::HISTORY) && !cancelled()) { |
438 bridge_->NotifyItemStarted(importer::HISTORY); | 429 bridge_->NotifyItemStarted(importer::HISTORY); |
439 ImportHistory(); | 430 ImportHistory(); |
440 bridge_->NotifyItemEnded(importer::HISTORY); | 431 bridge_->NotifyItemEnded(importer::HISTORY); |
441 } | 432 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 static int version = -1; | 885 static int version = -1; |
895 if (version < 0) { | 886 if (version < 0) { |
896 wchar_t buffer[128]; | 887 wchar_t buffer[128]; |
897 DWORD buffer_length = sizeof(buffer); | 888 DWORD buffer_length = sizeof(buffer); |
898 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); | 889 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); |
899 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 890 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
900 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 891 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
901 } | 892 } |
902 return version; | 893 return version; |
903 } | 894 } |
OLD | NEW |