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 18 matching lines...) Expand all Loading... |
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/bookmarks/imported_bookmark_entry.h" | 32 #include "chrome/browser/bookmarks/imported_bookmark_entry.h" |
33 #include "chrome/browser/favicon/favicon_util.h" | 33 #include "chrome/browser/favicon/favicon_util.h" |
34 #include "chrome/browser/favicon/imported_favicon_usage.h" | 34 #include "chrome/browser/favicon/imported_favicon_usage.h" |
35 #include "chrome/browser/importer/ie_importer_utils_win.h" | 35 #include "chrome/browser/importer/ie_importer_utils_win.h" |
36 #include "chrome/browser/importer/importer_bridge.h" | 36 #include "chrome/browser/importer/importer_bridge.h" |
37 #include "chrome/browser/importer/importer_data_types.h" | 37 #include "chrome/browser/importer/importer_data_types.h" |
38 #include "chrome/browser/importer/pstore_declarations.h" | 38 #include "chrome/browser/importer/pstore_declarations.h" |
39 #include "chrome/browser/search_engines/template_url.h" | |
40 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | |
41 #include "chrome/browser/search_engines/template_url_service.h" | |
42 #include "chrome/common/time_format.h" | 39 #include "chrome/common/time_format.h" |
43 #include "chrome/common/url_constants.h" | 40 #include "chrome/common/url_constants.h" |
44 #include "components/webdata/encryptor/ie7_password.h" | 41 #include "components/webdata/encryptor/ie7_password.h" |
45 #include "content/public/common/password_form.h" | 42 #include "content/public/common/password_form.h" |
46 #include "googleurl/src/gurl.h" | 43 #include "googleurl/src/gurl.h" |
47 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
48 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
49 | 46 |
50 namespace { | 47 namespace { |
51 | 48 |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 676 |
680 ++reg_iterator; | 677 ++reg_iterator; |
681 } | 678 } |
682 } | 679 } |
683 | 680 |
684 void IEImporter::ImportSearchEngines() { | 681 void IEImporter::ImportSearchEngines() { |
685 // On IE, search engines are stored in the registry, under: | 682 // On IE, search engines are stored in the registry, under: |
686 // Software\Microsoft\Internet Explorer\SearchScopes | 683 // Software\Microsoft\Internet Explorer\SearchScopes |
687 // Each key represents a search engine. The URL value contains the URL and | 684 // Each key represents a search engine. The URL value contains the URL and |
688 // the DisplayName the name. | 685 // the DisplayName the name. |
689 typedef std::map<std::string, TemplateURL*> SearchEnginesMap; | 686 typedef std::map<std::string, string16> SearchEnginesMap; |
690 SearchEnginesMap search_engines_map; | 687 SearchEnginesMap search_engines_map; |
691 for (base::win::RegistryKeyIterator key_iter(HKEY_CURRENT_USER, | 688 for (base::win::RegistryKeyIterator key_iter(HKEY_CURRENT_USER, |
692 kSearchScopePath); key_iter.Valid(); ++key_iter) { | 689 kSearchScopePath); key_iter.Valid(); ++key_iter) { |
693 string16 sub_key_name = kSearchScopePath; | 690 string16 sub_key_name = kSearchScopePath; |
694 sub_key_name.append(L"\\").append(key_iter.Name()); | 691 sub_key_name.append(L"\\").append(key_iter.Name()); |
695 base::win::RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(), | 692 base::win::RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(), |
696 KEY_READ); | 693 KEY_READ); |
697 string16 wide_url; | 694 string16 wide_url; |
698 if ((sub_key.ReadValue(L"URL", &wide_url) != ERROR_SUCCESS) || | 695 if ((sub_key.ReadValue(L"URL", &wide_url) != ERROR_SUCCESS) || |
699 wide_url.empty()) { | 696 wide_url.empty()) { |
(...skipping 12 matching lines...) Expand all Loading... |
712 continue; | 709 continue; |
713 } | 710 } |
714 } | 711 } |
715 | 712 |
716 std::string url(WideToUTF8(wide_url)); | 713 std::string url(WideToUTF8(wide_url)); |
717 SearchEnginesMap::iterator t_iter = search_engines_map.find(url); | 714 SearchEnginesMap::iterator t_iter = search_engines_map.find(url); |
718 if (t_iter == search_engines_map.end()) { | 715 if (t_iter == search_engines_map.end()) { |
719 // First time we see that URL. | 716 // First time we see that URL. |
720 GURL gurl(url); | 717 GURL gurl(url); |
721 if (gurl.is_valid()) { | 718 if (gurl.is_valid()) { |
722 TemplateURLData data; | 719 t_iter = search_engines_map.insert(std::make_pair(url, name)).first; |
723 data.short_name = name; | |
724 data.SetKeyword(TemplateURLService::GenerateKeyword(gurl)); | |
725 data.SetURL(url); | |
726 data.show_in_default_list = true; | |
727 t_iter = search_engines_map.insert(std::make_pair(url, | |
728 new TemplateURL(NULL, data))).first; | |
729 } | 720 } |
730 } | 721 } |
731 } | 722 } |
732 | |
733 // ProfileWriter::AddKeywords() requires a vector and we have a map. | 723 // ProfileWriter::AddKeywords() requires a vector and we have a map. |
734 std::vector<TemplateURL*> search_engines; | 724 std::vector<importer::URLKeywordInfo> url_keywords; |
735 for (SearchEnginesMap::iterator i = search_engines_map.begin(); | 725 for (SearchEnginesMap::iterator i = search_engines_map.begin(); |
736 i != search_engines_map.end(); ++i) | 726 i != search_engines_map.end(); ++i) { |
737 search_engines.push_back(i->second); | 727 importer::URLKeywordInfo url_keyword_info; |
738 | 728 url_keyword_info.url = GURL(i->first); |
739 bridge_->SetKeywords(search_engines, true); | 729 url_keyword_info.display_name = i->second; |
| 730 url_keywords.push_back(url_keyword_info); |
| 731 } |
| 732 bridge_->SetKeywords(url_keywords, true); |
740 } | 733 } |
741 | 734 |
742 void IEImporter::ImportHomepage() { | 735 void IEImporter::ImportHomepage() { |
743 const wchar_t* kIEHomepage = L"Start Page"; | 736 const wchar_t* kIEHomepage = L"Start Page"; |
744 const wchar_t* kIEDefaultHomepage = L"Default_Page_URL"; | 737 const wchar_t* kIEDefaultHomepage = L"Default_Page_URL"; |
745 | 738 |
746 base::win::RegKey key(HKEY_CURRENT_USER, kIESettingsMain, KEY_READ); | 739 base::win::RegKey key(HKEY_CURRENT_USER, kIESettingsMain, KEY_READ); |
747 string16 homepage_url; | 740 string16 homepage_url; |
748 if (key.ReadValue(kIEHomepage, &homepage_url) != ERROR_SUCCESS || | 741 if (key.ReadValue(kIEHomepage, &homepage_url) != ERROR_SUCCESS || |
749 homepage_url.empty()) | 742 homepage_url.empty()) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 static int version = -1; | 879 static int version = -1; |
887 if (version < 0) { | 880 if (version < 0) { |
888 wchar_t buffer[128]; | 881 wchar_t buffer[128]; |
889 DWORD buffer_length = sizeof(buffer); | 882 DWORD buffer_length = sizeof(buffer); |
890 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); | 883 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); |
891 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 884 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
892 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 885 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
893 } | 886 } |
894 return version; | 887 return version; |
895 } | 888 } |
OLD | NEW |