OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <pstore.h> | 9 #include <pstore.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
11 #include <urlhist.h> | 11 #include <urlhist.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 "app/l10n_util.h" | 18 #include "app/l10n_util.h" |
19 #include "app/win_util.h" | 19 #include "app/win_util.h" |
20 #include "base/file_path.h" | 20 #include "base/file_path.h" |
21 #include "base/file_util.h" | 21 #include "base/file_util.h" |
22 #include "base/registry.h" | |
23 #include "base/scoped_comptr_win.h" | 22 #include "base/scoped_comptr_win.h" |
24 #include "base/string_split.h" | 23 #include "base/string_split.h" |
25 #include "base/string_util.h" | 24 #include "base/string_util.h" |
26 #include "base/time.h" | 25 #include "base/time.h" |
27 #include "base/values.h" | 26 #include "base/values.h" |
28 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
| 28 #include "base/win/registry.h" |
29 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
30 #include "chrome/browser/bookmarks/bookmark_model.h" | 30 #include "chrome/browser/bookmarks/bookmark_model.h" |
31 #include "chrome/browser/importer/importer_bridge.h" | 31 #include "chrome/browser/importer/importer_bridge.h" |
32 #include "chrome/browser/importer/importer_data_types.h" | 32 #include "chrome/browser/importer/importer_data_types.h" |
33 #include "chrome/browser/password_manager/ie7_password.h" | 33 #include "chrome/browser/password_manager/ie7_password.h" |
34 #include "chrome/browser/search_engines/template_url.h" | 34 #include "chrome/browser/search_engines/template_url.h" |
35 #include "chrome/browser/search_engines/template_url_model.h" | 35 #include "chrome/browser/search_engines/template_url_model.h" |
36 #include "chrome/common/time_format.h" | 36 #include "chrome/common/time_format.h" |
37 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
38 #include "googleurl/src/gurl.h" | 38 #include "googleurl/src/gurl.h" |
39 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
40 #include "webkit/glue/password_form.h" | 40 #include "webkit/glue/password_form.h" |
41 | 41 |
42 using base::Time; | 42 using base::Time; |
| 43 using base::win::RegKey; |
| 44 using base::win::RegistryValueIterator; |
43 using webkit_glue::PasswordForm; | 45 using webkit_glue::PasswordForm; |
44 | 46 |
45 namespace { | 47 namespace { |
46 | 48 |
47 // Gets the creation time of the given file or directory. | 49 // Gets the creation time of the given file or directory. |
48 static Time GetFileCreationTime(const std::wstring& file) { | 50 static Time GetFileCreationTime(const std::wstring& file) { |
49 Time creation_time; | 51 Time creation_time; |
50 ScopedHandle file_handle( | 52 ScopedHandle file_handle( |
51 CreateFile(file.c_str(), GENERIC_READ, | 53 CreateFile(file.c_str(), GENERIC_READ, |
52 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | 54 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 // the DisplayName the name. | 349 // the DisplayName the name. |
348 // The default key's name is contained under DefaultScope. | 350 // The default key's name is contained under DefaultScope. |
349 const wchar_t kSearchScopePath[] = | 351 const wchar_t kSearchScopePath[] = |
350 L"Software\\Microsoft\\Internet Explorer\\SearchScopes"; | 352 L"Software\\Microsoft\\Internet Explorer\\SearchScopes"; |
351 | 353 |
352 RegKey key(HKEY_CURRENT_USER, kSearchScopePath, KEY_READ); | 354 RegKey key(HKEY_CURRENT_USER, kSearchScopePath, KEY_READ); |
353 std::wstring default_search_engine_name; | 355 std::wstring default_search_engine_name; |
354 const TemplateURL* default_search_engine = NULL; | 356 const TemplateURL* default_search_engine = NULL; |
355 std::map<std::string, TemplateURL*> search_engines_map; | 357 std::map<std::string, TemplateURL*> search_engines_map; |
356 key.ReadValue(L"DefaultScope", &default_search_engine_name); | 358 key.ReadValue(L"DefaultScope", &default_search_engine_name); |
357 RegistryKeyIterator key_iterator(HKEY_CURRENT_USER, kSearchScopePath); | 359 base::win::RegistryKeyIterator key_iterator(HKEY_CURRENT_USER, |
| 360 kSearchScopePath); |
358 while (key_iterator.Valid()) { | 361 while (key_iterator.Valid()) { |
359 std::wstring sub_key_name = kSearchScopePath; | 362 std::wstring sub_key_name = kSearchScopePath; |
360 sub_key_name.append(L"\\").append(key_iterator.Name()); | 363 sub_key_name.append(L"\\").append(key_iterator.Name()); |
361 RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(), KEY_READ); | 364 RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(), KEY_READ); |
362 std::wstring wide_url; | 365 std::wstring wide_url; |
363 if (!sub_key.ReadValue(L"URL", &wide_url) || wide_url.empty()) { | 366 if (!sub_key.ReadValue(L"URL", &wide_url) || wide_url.empty()) { |
364 LOG(INFO) << "No URL for IE search engine at " << key_iterator.Name(); | 367 LOG(INFO) << "No URL for IE search engine at " << key_iterator.Name(); |
365 ++key_iterator; | 368 ++key_iterator; |
366 continue; | 369 continue; |
367 } | 370 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 if (version < 0) { | 579 if (version < 0) { |
577 wchar_t buffer[128]; | 580 wchar_t buffer[128]; |
578 DWORD buffer_length = sizeof(buffer); | 581 DWORD buffer_length = sizeof(buffer); |
579 RegKey reg_key(HKEY_LOCAL_MACHINE, | 582 RegKey reg_key(HKEY_LOCAL_MACHINE, |
580 L"Software\\Microsoft\\Internet Explorer", KEY_READ); | 583 L"Software\\Microsoft\\Internet Explorer", KEY_READ); |
581 bool result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 584 bool result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
582 version = (result ? _wtoi(buffer) : 0); | 585 version = (result ? _wtoi(buffer) : 0); |
583 } | 586 } |
584 return version; | 587 return version; |
585 } | 588 } |
OLD | NEW |