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_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> |
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/importer/ie_importer_utils_win.h" | 32 #include "chrome/common/importer/ie_importer_utils_win.h" |
33 #include "chrome/browser/importer/importer_bridge.h" | |
34 #include "chrome/browser/importer/pstore_declarations.h" | |
35 #include "chrome/browser/importer/reencode_favicon.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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // examine the IE cache. | 353 // examine the IE cache. |
354 bool ReadReencodedFaviconData(const string16& file, | 354 bool ReadReencodedFaviconData(const string16& file, |
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 return ReencodeFavicon(reinterpret_cast<const uint8*>(image_data.c_str()), | 363 const unsigned char* ptr = |
364 image_data.size(), data); | 364 reinterpret_cast<const unsigned char*>(image_data.c_str()); |
| 365 return importer::ReencodeFavicon(ptr, image_data.size(), data); |
365 } | 366 } |
366 | 367 |
367 // Loads favicon image data and registers to |favicon_map|. | 368 // Loads favicon image data and registers to |favicon_map|. |
368 void UpdateFaviconMap( | 369 void UpdateFaviconMap( |
369 const string16& url_file, | 370 const string16& url_file, |
370 const GURL& url, | 371 const GURL& url, |
371 IUniformResourceLocator* url_locator, | 372 IUniformResourceLocator* url_locator, |
372 std::map<GURL, ImportedFaviconUsage>* favicon_map) { | 373 std::map<GURL, ImportedFaviconUsage>* favicon_map) { |
373 GURL favicon_url = ReadFaviconURLFromInternetShortcut(url_locator); | 374 GURL favicon_url = ReadFaviconURLFromInternetShortcut(url_locator); |
374 if (!favicon_url.is_valid()) | 375 if (!favicon_url.is_valid()) |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 static int version = -1; | 875 static int version = -1; |
875 if (version < 0) { | 876 if (version < 0) { |
876 wchar_t buffer[128]; | 877 wchar_t buffer[128]; |
877 DWORD buffer_length = sizeof(buffer); | 878 DWORD buffer_length = sizeof(buffer); |
878 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); | 879 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); |
879 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 880 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
880 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 881 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
881 } | 882 } |
882 return version; | 883 return version; |
883 } | 884 } |
OLD | NEW |