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/utility/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> |
11 #include <wininet.h> | 11 #include <wininet.h> |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
19 #include "base/files/file_enumerator.h" | 19 #include "base/files/file_enumerator.h" |
20 #include "base/files/file_path.h" | 20 #include "base/files/file_path.h" |
21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
26 #include "base/win/registry.h" | 26 #include "base/win/registry.h" |
27 #include "base/win/scoped_co_mem.h" | 27 #include "base/win/scoped_co_mem.h" |
28 #include "base/win/scoped_comptr.h" | 28 #include "base/win/scoped_comptr.h" |
29 #include "base/win/scoped_handle.h" | 29 #include "base/win/scoped_handle.h" |
30 #include "base/win/scoped_propvariant.h" | 30 #include "base/win/scoped_propvariant.h" |
31 #include "base/win/windows_version.h" | 31 #include "base/win/windows_version.h" |
32 #include "chrome/browser/favicon/favicon_util.h" | 32 #include "chrome/common/importer/ie_importer_utils_win.h" |
33 #include "chrome/browser/importer/ie_importer_utils_win.h" | |
34 #include "chrome/browser/importer/importer_bridge.h" | |
35 #include "chrome/browser/importer/pstore_declarations.h" | |
36 #include "chrome/common/importer/imported_bookmark_entry.h" | 33 #include "chrome/common/importer/imported_bookmark_entry.h" |
37 #include "chrome/common/importer/imported_favicon_usage.h" | 34 #include "chrome/common/importer/imported_favicon_usage.h" |
| 35 #include "chrome/common/importer/importer_bridge.h" |
38 #include "chrome/common/importer/importer_data_types.h" | 36 #include "chrome/common/importer/importer_data_types.h" |
39 #include "chrome/common/importer/importer_url_row.h" | 37 #include "chrome/common/importer/importer_url_row.h" |
| 38 #include "chrome/common/importer/pstore_declarations.h" |
40 #include "chrome/common/time_format.h" | 39 #include "chrome/common/time_format.h" |
41 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
| 41 #include "chrome/utility/importer/favicon_reencode.h" |
42 #include "content/public/common/password_form.h" | 42 #include "content/public/common/password_form.h" |
43 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
44 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
45 #include "url/gurl.h" | 45 #include "url/gurl.h" |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 // Registry key paths from which we import IE settings. | 49 // Registry key paths from which we import IE settings. |
50 const char16 kSearchScopePath[] = | 50 const char16 kSearchScopePath[] = |
51 L"Software\\Microsoft\\Internet Explorer\\SearchScopes"; | 51 L"Software\\Microsoft\\Internet Explorer\\SearchScopes"; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 const GURL& favicon_url, | 355 const GURL& favicon_url, |
356 std::vector<unsigned char>* data) { | 356 std::vector<unsigned char>* data) { |
357 std::string image_data; | 357 std::string image_data; |
358 if (!ReadFaviconDataFromInternetShortcut(file, &image_data) && | 358 if (!ReadFaviconDataFromInternetShortcut(file, &image_data) && |
359 !ReadFaviconDataFromCache(favicon_url, &image_data)) { | 359 !ReadFaviconDataFromCache(favicon_url, &image_data)) { |
360 return false; | 360 return false; |
361 } | 361 } |
362 | 362 |
363 const unsigned char* ptr = | 363 const unsigned char* ptr = |
364 reinterpret_cast<const unsigned char*>(image_data.c_str()); | 364 reinterpret_cast<const unsigned char*>(image_data.c_str()); |
365 return FaviconUtil::ReencodeFavicon(ptr, image_data.size(), data); | 365 return importer::ReencodeFavicon(ptr, image_data.size(), data); |
366 } | 366 } |
367 | 367 |
368 // Loads favicon image data and registers to |favicon_map|. | 368 // Loads favicon image data and registers to |favicon_map|. |
369 void UpdateFaviconMap( | 369 void UpdateFaviconMap( |
370 const string16& url_file, | 370 const string16& url_file, |
371 const GURL& url, | 371 const GURL& url, |
372 IUniformResourceLocator* url_locator, | 372 IUniformResourceLocator* url_locator, |
373 std::map<GURL, ImportedFaviconUsage>* favicon_map) { | 373 std::map<GURL, ImportedFaviconUsage>* favicon_map) { |
374 GURL favicon_url = ReadFaviconURLFromInternetShortcut(url_locator); | 374 GURL favicon_url = ReadFaviconURLFromInternetShortcut(url_locator); |
375 if (!favicon_url.is_valid()) | 375 if (!favicon_url.is_valid()) |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 row.visit_count = 1; | 515 row.visit_count = 1; |
516 row.hidden = false; | 516 row.hidden = false; |
517 } else { | 517 } else { |
518 row.hidden = true; | 518 row.hidden = true; |
519 } | 519 } |
520 | 520 |
521 rows.push_back(row); | 521 rows.push_back(row); |
522 } | 522 } |
523 | 523 |
524 if (!rows.empty() && !cancelled()) { | 524 if (!rows.empty() && !cancelled()) { |
525 bridge_->SetHistoryItems(rows, history::SOURCE_IE_IMPORTED); | 525 bridge_->SetHistoryItems(rows, IMPORTER_VISIT_SOURCE_IE_IMPORTED); |
526 } | 526 } |
527 } | 527 } |
528 } | 528 } |
529 | 529 |
530 void IEImporter::ImportPasswordsIE6() { | 530 void IEImporter::ImportPasswordsIE6() { |
531 GUID AutocompleteGUID = kPStoreAutocompleteGUID; | 531 GUID AutocompleteGUID = kPStoreAutocompleteGUID; |
532 if (!source_path_.empty()) { | 532 if (!source_path_.empty()) { |
533 // We supply a fake GUID for testting. | 533 // We supply a fake GUID for testting. |
534 AutocompleteGUID = kUnittestGUID; | 534 AutocompleteGUID = kUnittestGUID; |
535 } | 535 } |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 static int version = -1; | 875 static int version = -1; |
876 if (version < 0) { | 876 if (version < 0) { |
877 wchar_t buffer[128]; | 877 wchar_t buffer[128]; |
878 DWORD buffer_length = sizeof(buffer); | 878 DWORD buffer_length = sizeof(buffer); |
879 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); | 879 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); |
880 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 880 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
881 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 881 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
882 } | 882 } |
883 return version; | 883 return version; |
884 } | 884 } |
OLD | NEW |