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/utility/importer/ie_importer_win.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> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 const char16 kIEVersionKey[] = | 51 const char16 kIEVersionKey[] = |
52 L"Software\\Microsoft\\Internet Explorer"; | 52 L"Software\\Microsoft\\Internet Explorer"; |
53 const char16 kIEToolbarKey[] = | 53 const char16 kIEToolbarKey[] = |
54 L"Software\\Microsoft\\Internet Explorer\\Toolbar"; | 54 L"Software\\Microsoft\\Internet Explorer\\Toolbar"; |
55 | 55 |
56 // NTFS stream name of favicon image data. | 56 // NTFS stream name of favicon image data. |
57 const char16 kFaviconStreamName[] = L":favicon:$DATA"; | 57 const char16 kFaviconStreamName[] = L":favicon:$DATA"; |
58 | 58 |
59 // A struct that hosts the information of AutoComplete data in PStore. | 59 // A struct that hosts the information of AutoComplete data in PStore. |
60 struct AutoCompleteInfo { | 60 struct AutoCompleteInfo { |
61 string16 key; | 61 base::string16 key; |
62 std::vector<string16> data; | 62 std::vector<base::string16> data; |
63 bool is_url; | 63 bool is_url; |
64 }; | 64 }; |
65 | 65 |
66 // Gets the creation time of the given file or directory. | 66 // Gets the creation time of the given file or directory. |
67 base::Time GetFileCreationTime(const string16& file) { | 67 base::Time GetFileCreationTime(const base::string16& file) { |
68 base::Time creation_time; | 68 base::Time creation_time; |
69 base::win::ScopedHandle file_handle( | 69 base::win::ScopedHandle file_handle( |
70 CreateFile(file.c_str(), GENERIC_READ, | 70 CreateFile(file.c_str(), GENERIC_READ, |
71 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | 71 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
72 NULL, OPEN_EXISTING, | 72 NULL, OPEN_EXISTING, |
73 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL)); | 73 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL)); |
74 FILETIME creation_filetime; | 74 FILETIME creation_filetime; |
75 if (GetFileTime(file_handle, &creation_filetime, NULL, NULL)) | 75 if (GetFileTime(file_handle, &creation_filetime, NULL, NULL)) |
76 creation_time = base::Time::FromFileTime(creation_filetime); | 76 creation_time = base::Time::FromFileTime(creation_filetime); |
77 return creation_time; | 77 return creation_time; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 std::map<base::FilePath, uint32> sort_index; | 259 std::map<base::FilePath, uint32> sort_index; |
260 if (!ParseFavoritesOrderInfo(importer, &sort_index)) | 260 if (!ParseFavoritesOrderInfo(importer, &sort_index)) |
261 return; | 261 return; |
262 IEOrderBookmarkComparator compare = {&sort_index}; | 262 IEOrderBookmarkComparator compare = {&sort_index}; |
263 std::sort(bookmarks->begin(), bookmarks->end(), compare); | 263 std::sort(bookmarks->begin(), bookmarks->end(), compare); |
264 } | 264 } |
265 | 265 |
266 // Reads an internet shortcut (*.url) |file| and returns a COM object | 266 // Reads an internet shortcut (*.url) |file| and returns a COM object |
267 // representing it. | 267 // representing it. |
268 bool LoadInternetShortcut( | 268 bool LoadInternetShortcut( |
269 const string16& file, | 269 const base::string16& file, |
270 base::win::ScopedComPtr<IUniformResourceLocator>* shortcut) { | 270 base::win::ScopedComPtr<IUniformResourceLocator>* shortcut) { |
271 base::win::ScopedComPtr<IUniformResourceLocator> url_locator; | 271 base::win::ScopedComPtr<IUniformResourceLocator> url_locator; |
272 if (FAILED(url_locator.CreateInstance(CLSID_InternetShortcut, NULL, | 272 if (FAILED(url_locator.CreateInstance(CLSID_InternetShortcut, NULL, |
273 CLSCTX_INPROC_SERVER))) | 273 CLSCTX_INPROC_SERVER))) |
274 return false; | 274 return false; |
275 | 275 |
276 base::win::ScopedComPtr<IPersistFile> persist_file; | 276 base::win::ScopedComPtr<IPersistFile> persist_file; |
277 if (FAILED(persist_file.QueryFrom(url_locator))) | 277 if (FAILED(persist_file.QueryFrom(url_locator))) |
278 return false; | 278 return false; |
279 | 279 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // ReadMultiple can return S_FALSE (FAILED(S_FALSE) is false) when the | 313 // ReadMultiple can return S_FALSE (FAILED(S_FALSE) is false) when the |
314 // property is not found, in which case output[0].vt is set to VT_EMPTY. | 314 // property is not found, in which case output[0].vt is set to VT_EMPTY. |
315 if (FAILED(property_storage->ReadMultiple(1, properties, output.Receive())) || | 315 if (FAILED(property_storage->ReadMultiple(1, properties, output.Receive())) || |
316 output.get().vt != VT_LPWSTR) | 316 output.get().vt != VT_LPWSTR) |
317 return GURL(); | 317 return GURL(); |
318 return GURL(WideToUTF16(output.get().pwszVal)); | 318 return GURL(WideToUTF16(output.get().pwszVal)); |
319 } | 319 } |
320 | 320 |
321 // Reads the favicon imaga data in an NTFS alternate data stream. This is where | 321 // Reads the favicon imaga data in an NTFS alternate data stream. This is where |
322 // IE7 and above store the data. | 322 // IE7 and above store the data. |
323 bool ReadFaviconDataFromInternetShortcut(const string16& file, | 323 bool ReadFaviconDataFromInternetShortcut(const base::string16& file, |
324 std::string* data) { | 324 std::string* data) { |
325 return base::ReadFileToString( | 325 return base::ReadFileToString( |
326 base::FilePath(file + kFaviconStreamName), data); | 326 base::FilePath(file + kFaviconStreamName), data); |
327 } | 327 } |
328 | 328 |
329 // Reads the favicon imaga data in the Internet cache. IE6 doesn't hold the data | 329 // Reads the favicon imaga data in the Internet cache. IE6 doesn't hold the data |
330 // explicitly, but it might be found in the cache. | 330 // explicitly, but it might be found in the cache. |
331 bool ReadFaviconDataFromCache(const GURL& favicon_url, std::string* data) { | 331 bool ReadFaviconDataFromCache(const GURL& favicon_url, std::string* data) { |
332 std::wstring url_wstring(UTF8ToWide(favicon_url.spec())); | 332 std::wstring url_wstring(UTF8ToWide(favicon_url.spec())); |
333 DWORD info_size = 0; | 333 DWORD info_size = 0; |
334 GetUrlCacheEntryInfoEx(url_wstring.c_str(), NULL, &info_size, NULL, NULL, | 334 GetUrlCacheEntryInfoEx(url_wstring.c_str(), NULL, &info_size, NULL, NULL, |
335 NULL, 0); | 335 NULL, 0); |
336 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) | 336 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) |
337 return false; | 337 return false; |
338 | 338 |
339 std::vector<char> buf(info_size); | 339 std::vector<char> buf(info_size); |
340 INTERNET_CACHE_ENTRY_INFO* cache = | 340 INTERNET_CACHE_ENTRY_INFO* cache = |
341 reinterpret_cast<INTERNET_CACHE_ENTRY_INFO*>(&buf[0]); | 341 reinterpret_cast<INTERNET_CACHE_ENTRY_INFO*>(&buf[0]); |
342 if (!GetUrlCacheEntryInfoEx(url_wstring.c_str(), cache, &info_size, NULL, | 342 if (!GetUrlCacheEntryInfoEx(url_wstring.c_str(), cache, &info_size, NULL, |
343 NULL, NULL, 0)) { | 343 NULL, NULL, 0)) { |
344 return false; | 344 return false; |
345 } | 345 } |
346 return base::ReadFileToString(base::FilePath(cache->lpszLocalFileName), data); | 346 return base::ReadFileToString(base::FilePath(cache->lpszLocalFileName), data); |
347 } | 347 } |
348 | 348 |
349 // Reads the binary image data of favicon of an internet shortcut file |file|. | 349 // Reads the binary image data of favicon of an internet shortcut file |file|. |
350 // |favicon_url| read by ReadFaviconURLFromInternetShortcut is also needed to | 350 // |favicon_url| read by ReadFaviconURLFromInternetShortcut is also needed to |
351 // examine the IE cache. | 351 // examine the IE cache. |
352 bool ReadReencodedFaviconData(const string16& file, | 352 bool ReadReencodedFaviconData(const base::string16& file, |
353 const GURL& favicon_url, | 353 const GURL& favicon_url, |
354 std::vector<unsigned char>* data) { | 354 std::vector<unsigned char>* data) { |
355 std::string image_data; | 355 std::string image_data; |
356 if (!ReadFaviconDataFromInternetShortcut(file, &image_data) && | 356 if (!ReadFaviconDataFromInternetShortcut(file, &image_data) && |
357 !ReadFaviconDataFromCache(favicon_url, &image_data)) { | 357 !ReadFaviconDataFromCache(favicon_url, &image_data)) { |
358 return false; | 358 return false; |
359 } | 359 } |
360 | 360 |
361 const unsigned char* ptr = | 361 const unsigned char* ptr = |
362 reinterpret_cast<const unsigned char*>(image_data.c_str()); | 362 reinterpret_cast<const unsigned char*>(image_data.c_str()); |
363 return importer::ReencodeFavicon(ptr, image_data.size(), data); | 363 return importer::ReencodeFavicon(ptr, image_data.size(), data); |
364 } | 364 } |
365 | 365 |
366 // Loads favicon image data and registers to |favicon_map|. | 366 // Loads favicon image data and registers to |favicon_map|. |
367 void UpdateFaviconMap( | 367 void UpdateFaviconMap(const base::string16& url_file, |
368 const string16& url_file, | 368 const GURL& url, |
369 const GURL& url, | 369 IUniformResourceLocator* url_locator, |
370 IUniformResourceLocator* url_locator, | 370 std::map<GURL, ImportedFaviconUsage>* favicon_map) { |
371 std::map<GURL, ImportedFaviconUsage>* favicon_map) { | |
372 GURL favicon_url = ReadFaviconURLFromInternetShortcut(url_locator); | 371 GURL favicon_url = ReadFaviconURLFromInternetShortcut(url_locator); |
373 if (!favicon_url.is_valid()) | 372 if (!favicon_url.is_valid()) |
374 return; | 373 return; |
375 | 374 |
376 std::map<GURL, ImportedFaviconUsage>::iterator it = | 375 std::map<GURL, ImportedFaviconUsage>::iterator it = |
377 favicon_map->find(favicon_url); | 376 favicon_map->find(favicon_url); |
378 if (it != favicon_map->end()) { | 377 if (it != favicon_map->end()) { |
379 // Known favicon URL. | 378 // Known favicon URL. |
380 it->second.urls.insert(url); | 379 it->second.urls.insert(url); |
381 } else { | 380 } else { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 void IEImporter::ImportFavorites() { | 452 void IEImporter::ImportFavorites() { |
454 FavoritesInfo info; | 453 FavoritesInfo info; |
455 if (!GetFavoritesInfo(&info)) | 454 if (!GetFavoritesInfo(&info)) |
456 return; | 455 return; |
457 | 456 |
458 BookmarkVector bookmarks; | 457 BookmarkVector bookmarks; |
459 std::vector<ImportedFaviconUsage> favicons; | 458 std::vector<ImportedFaviconUsage> favicons; |
460 ParseFavoritesFolder(info, &bookmarks, &favicons); | 459 ParseFavoritesFolder(info, &bookmarks, &favicons); |
461 | 460 |
462 if (!bookmarks.empty() && !cancelled()) { | 461 if (!bookmarks.empty() && !cancelled()) { |
463 const string16& first_folder_name = | 462 const base::string16& first_folder_name = |
464 l10n_util::GetStringUTF16(IDS_BOOKMARK_GROUP_FROM_IE); | 463 l10n_util::GetStringUTF16(IDS_BOOKMARK_GROUP_FROM_IE); |
465 bridge_->AddBookmarks(bookmarks, first_folder_name); | 464 bridge_->AddBookmarks(bookmarks, first_folder_name); |
466 } | 465 } |
467 if (!favicons.empty() && !cancelled()) | 466 if (!favicons.empty() && !cancelled()) |
468 bridge_->SetFavicons(favicons); | 467 bridge_->SetFavicons(favicons); |
469 } | 468 } |
470 | 469 |
471 void IEImporter::ImportHistory() { | 470 void IEImporter::ImportHistory() { |
472 const std::string kSchemes[] = {content::kHttpScheme, | 471 const std::string kSchemes[] = {content::kHttpScheme, |
473 content::kHttpsScheme, | 472 content::kHttpsScheme, |
474 content::kFtpScheme, | 473 content::kFtpScheme, |
475 chrome::kFileScheme}; | 474 chrome::kFileScheme}; |
476 int total_schemes = arraysize(kSchemes); | 475 int total_schemes = arraysize(kSchemes); |
477 | 476 |
478 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; | 477 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; |
479 HRESULT result; | 478 HRESULT result; |
480 result = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, | 479 result = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, |
481 CLSCTX_INPROC_SERVER); | 480 CLSCTX_INPROC_SERVER); |
482 if (FAILED(result)) | 481 if (FAILED(result)) |
483 return; | 482 return; |
484 base::win::ScopedComPtr<IEnumSTATURL> enum_url; | 483 base::win::ScopedComPtr<IEnumSTATURL> enum_url; |
485 if (SUCCEEDED(result = url_history_stg2->EnumUrls(enum_url.Receive()))) { | 484 if (SUCCEEDED(result = url_history_stg2->EnumUrls(enum_url.Receive()))) { |
486 std::vector<ImporterURLRow> rows; | 485 std::vector<ImporterURLRow> rows; |
487 STATURL stat_url; | 486 STATURL stat_url; |
488 ULONG fetched; | 487 ULONG fetched; |
489 while (!cancelled() && | 488 while (!cancelled() && |
490 (result = enum_url->Next(1, &stat_url, &fetched)) == S_OK) { | 489 (result = enum_url->Next(1, &stat_url, &fetched)) == S_OK) { |
491 string16 url_string; | 490 base::string16 url_string; |
492 if (stat_url.pwcsUrl) { | 491 if (stat_url.pwcsUrl) { |
493 url_string = stat_url.pwcsUrl; | 492 url_string = stat_url.pwcsUrl; |
494 CoTaskMemFree(stat_url.pwcsUrl); | 493 CoTaskMemFree(stat_url.pwcsUrl); |
495 } | 494 } |
496 string16 title_string; | 495 base::string16 title_string; |
497 if (stat_url.pwcsTitle) { | 496 if (stat_url.pwcsTitle) { |
498 title_string = stat_url.pwcsTitle; | 497 title_string = stat_url.pwcsTitle; |
499 CoTaskMemFree(stat_url.pwcsTitle); | 498 CoTaskMemFree(stat_url.pwcsTitle); |
500 } | 499 } |
501 | 500 |
502 GURL url(url_string); | 501 GURL url(url_string); |
503 // Skips the URLs that are invalid or have other schemes. | 502 // Skips the URLs that are invalid or have other schemes. |
504 if (!url.is_valid() || | 503 if (!url.is_valid() || |
505 (std::find(kSchemes, kSchemes + total_schemes, url.scheme()) == | 504 (std::find(kSchemes, kSchemes + total_schemes, url.scheme()) == |
506 kSchemes + total_schemes)) | 505 kSchemes + total_schemes)) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 567 |
569 wchar_t* item_name; | 568 wchar_t* item_name; |
570 while (!cancelled() && SUCCEEDED(item->Next(1, &item_name, 0))) { | 569 while (!cancelled() && SUCCEEDED(item->Next(1, &item_name, 0))) { |
571 DWORD length = 0; | 570 DWORD length = 0; |
572 unsigned char* buffer = NULL; | 571 unsigned char* buffer = NULL; |
573 result = pstore->ReadItem(0, &AutocompleteGUID, &AutocompleteGUID, | 572 result = pstore->ReadItem(0, &AutocompleteGUID, &AutocompleteGUID, |
574 item_name, &length, &buffer, NULL, 0); | 573 item_name, &length, &buffer, NULL, 0); |
575 if (SUCCEEDED(result)) { | 574 if (SUCCEEDED(result)) { |
576 AutoCompleteInfo ac; | 575 AutoCompleteInfo ac; |
577 ac.key = item_name; | 576 ac.key = item_name; |
578 string16 data; | 577 base::string16 data; |
579 data.insert(0, reinterpret_cast<wchar_t*>(buffer), | 578 data.insert(0, reinterpret_cast<wchar_t*>(buffer), |
580 length / sizeof(wchar_t)); | 579 length / sizeof(wchar_t)); |
581 | 580 |
582 // The key name is always ended with ":StringData". | 581 // The key name is always ended with ":StringData". |
583 const wchar_t kDataSuffix[] = L":StringData"; | 582 const wchar_t kDataSuffix[] = L":StringData"; |
584 size_t i = ac.key.rfind(kDataSuffix); | 583 size_t i = ac.key.rfind(kDataSuffix); |
585 if (i != string16::npos && ac.key.substr(i) == kDataSuffix) { | 584 if (i != base::string16::npos && ac.key.substr(i) == kDataSuffix) { |
586 ac.key.erase(i); | 585 ac.key.erase(i); |
587 ac.is_url = (ac.key.find(L"://") != string16::npos); | 586 ac.is_url = (ac.key.find(L"://") != base::string16::npos); |
588 ac_list.push_back(ac); | 587 ac_list.push_back(ac); |
589 base::SplitString(data, L'\0', &ac_list[ac_list.size() - 1].data); | 588 base::SplitString(data, L'\0', &ac_list[ac_list.size() - 1].data); |
590 } | 589 } |
591 CoTaskMemFree(buffer); | 590 CoTaskMemFree(buffer); |
592 } | 591 } |
593 CoTaskMemFree(item_name); | 592 CoTaskMemFree(item_name); |
594 } | 593 } |
595 // Releases them before unload the dll. | 594 // Releases them before unload the dll. |
596 item.Release(); | 595 item.Release(); |
597 pstore.Release(); | 596 pstore.Release(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 668 |
670 ++reg_iterator; | 669 ++reg_iterator; |
671 } | 670 } |
672 } | 671 } |
673 | 672 |
674 void IEImporter::ImportSearchEngines() { | 673 void IEImporter::ImportSearchEngines() { |
675 // On IE, search engines are stored in the registry, under: | 674 // On IE, search engines are stored in the registry, under: |
676 // Software\Microsoft\Internet Explorer\SearchScopes | 675 // Software\Microsoft\Internet Explorer\SearchScopes |
677 // Each key represents a search engine. The URL value contains the URL and | 676 // Each key represents a search engine. The URL value contains the URL and |
678 // the DisplayName the name. | 677 // the DisplayName the name. |
679 typedef std::map<std::string, string16> SearchEnginesMap; | 678 typedef std::map<std::string, base::string16> SearchEnginesMap; |
680 SearchEnginesMap search_engines_map; | 679 SearchEnginesMap search_engines_map; |
681 for (base::win::RegistryKeyIterator key_iter(HKEY_CURRENT_USER, | 680 for (base::win::RegistryKeyIterator key_iter(HKEY_CURRENT_USER, |
682 kSearchScopePath); key_iter.Valid(); ++key_iter) { | 681 kSearchScopePath); key_iter.Valid(); ++key_iter) { |
683 string16 sub_key_name = kSearchScopePath; | 682 base::string16 sub_key_name = kSearchScopePath; |
684 sub_key_name.append(L"\\").append(key_iter.Name()); | 683 sub_key_name.append(L"\\").append(key_iter.Name()); |
685 base::win::RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(), | 684 base::win::RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(), |
686 KEY_READ); | 685 KEY_READ); |
687 string16 wide_url; | 686 base::string16 wide_url; |
688 if ((sub_key.ReadValue(L"URL", &wide_url) != ERROR_SUCCESS) || | 687 if ((sub_key.ReadValue(L"URL", &wide_url) != ERROR_SUCCESS) || |
689 wide_url.empty()) { | 688 wide_url.empty()) { |
690 VLOG(1) << "No URL for IE search engine at " << key_iter.Name(); | 689 VLOG(1) << "No URL for IE search engine at " << key_iter.Name(); |
691 continue; | 690 continue; |
692 } | 691 } |
693 // For the name, we try the default value first (as Live Search uses a | 692 // For the name, we try the default value first (as Live Search uses a |
694 // non displayable name in DisplayName, and the readable name under the | 693 // non displayable name in DisplayName, and the readable name under the |
695 // default value). | 694 // default value). |
696 string16 name; | 695 base::string16 name; |
697 if ((sub_key.ReadValue(NULL, &name) != ERROR_SUCCESS) || name.empty()) { | 696 if ((sub_key.ReadValue(NULL, &name) != ERROR_SUCCESS) || name.empty()) { |
698 // Try the displayable name. | 697 // Try the displayable name. |
699 if ((sub_key.ReadValue(L"DisplayName", &name) != ERROR_SUCCESS) || | 698 if ((sub_key.ReadValue(L"DisplayName", &name) != ERROR_SUCCESS) || |
700 name.empty()) { | 699 name.empty()) { |
701 VLOG(1) << "No name for IE search engine at " << key_iter.Name(); | 700 VLOG(1) << "No name for IE search engine at " << key_iter.Name(); |
702 continue; | 701 continue; |
703 } | 702 } |
704 } | 703 } |
705 | 704 |
706 std::string url(WideToUTF8(wide_url)); | 705 std::string url(WideToUTF8(wide_url)); |
(...skipping 18 matching lines...) Expand all Loading... |
725 bridge_->SetKeywords(url_keywords, true); | 724 bridge_->SetKeywords(url_keywords, true); |
726 } | 725 } |
727 | 726 |
728 void IEImporter::ImportHomepage() { | 727 void IEImporter::ImportHomepage() { |
729 const wchar_t* kIEHomepage = L"Start Page"; | 728 const wchar_t* kIEHomepage = L"Start Page"; |
730 const wchar_t* kIEDefaultHomepage = L"Default_Page_URL"; | 729 const wchar_t* kIEDefaultHomepage = L"Default_Page_URL"; |
731 | 730 |
732 base::string16 key_path(importer::GetIESettingsKey()); | 731 base::string16 key_path(importer::GetIESettingsKey()); |
733 | 732 |
734 base::win::RegKey key(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ); | 733 base::win::RegKey key(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ); |
735 string16 homepage_url; | 734 base::string16 homepage_url; |
736 if (key.ReadValue(kIEHomepage, &homepage_url) != ERROR_SUCCESS || | 735 if (key.ReadValue(kIEHomepage, &homepage_url) != ERROR_SUCCESS || |
737 homepage_url.empty()) | 736 homepage_url.empty()) |
738 return; | 737 return; |
739 | 738 |
740 GURL homepage = GURL(homepage_url); | 739 GURL homepage = GURL(homepage_url); |
741 if (!homepage.is_valid()) | 740 if (!homepage.is_valid()) |
742 return; | 741 return; |
743 | 742 |
744 // Check to see if this is the default website and skip import. | 743 // Check to see if this is the default website and skip import. |
745 base::win::RegKey keyDefault(HKEY_LOCAL_MACHINE, key_path.c_str(), KEY_READ); | 744 base::win::RegKey keyDefault(HKEY_LOCAL_MACHINE, key_path.c_str(), KEY_READ); |
746 string16 default_homepage_url; | 745 base::string16 default_homepage_url; |
747 LONG result = keyDefault.ReadValue(kIEDefaultHomepage, &default_homepage_url); | 746 LONG result = keyDefault.ReadValue(kIEDefaultHomepage, &default_homepage_url); |
748 if (result == ERROR_SUCCESS && !default_homepage_url.empty()) { | 747 if (result == ERROR_SUCCESS && !default_homepage_url.empty()) { |
749 if (homepage.spec() == GURL(default_homepage_url).spec()) | 748 if (homepage.spec() == GURL(default_homepage_url).spec()) |
750 return; | 749 return; |
751 } | 750 } |
752 bridge_->AddHomePage(homepage); | 751 bridge_->AddHomePage(homepage); |
753 } | 752 } |
754 | 753 |
755 bool IEImporter::GetFavoritesInfo(IEImporter::FavoritesInfo* info) { | 754 bool IEImporter::GetFavoritesInfo(IEImporter::FavoritesInfo* info) { |
756 if (!source_path_.empty()) { | 755 if (!source_path_.empty()) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 static int version = -1; | 872 static int version = -1; |
874 if (version < 0) { | 873 if (version < 0) { |
875 wchar_t buffer[128]; | 874 wchar_t buffer[128]; |
876 DWORD buffer_length = sizeof(buffer); | 875 DWORD buffer_length = sizeof(buffer); |
877 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); | 876 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); |
878 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 877 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
879 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 878 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
880 } | 879 } |
881 return version; | 880 return version; |
882 } | 881 } |
OLD | NEW |