| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 std::wstring default_homepage_url; | 455 std::wstring default_homepage_url; |
| 456 LONG result = keyDefault.ReadValue(kIEDefaultHomepage, &default_homepage_url); | 456 LONG result = keyDefault.ReadValue(kIEDefaultHomepage, &default_homepage_url); |
| 457 if (result == ERROR_SUCCESS && !default_homepage_url.empty()) { | 457 if (result == ERROR_SUCCESS && !default_homepage_url.empty()) { |
| 458 if (homepage.spec() == GURL(default_homepage_url).spec()) | 458 if (homepage.spec() == GURL(default_homepage_url).spec()) |
| 459 return; | 459 return; |
| 460 } | 460 } |
| 461 | 461 |
| 462 bridge_->AddHomePage(homepage); | 462 bridge_->AddHomePage(homepage); |
| 463 } | 463 } |
| 464 | 464 |
| 465 std::wstring IEImporter::ResolveInternetShortcut(const std::wstring& file) { | 465 string16 IEImporter::ResolveInternetShortcut(const string16& file) { |
| 466 base::win::ScopedCoMem<wchar_t> url; | 466 base::win::ScopedCoMem<wchar_t> url; |
| 467 base::win::ScopedComPtr<IUniformResourceLocator> url_locator; | 467 base::win::ScopedComPtr<IUniformResourceLocator> url_locator; |
| 468 HRESULT result = url_locator.CreateInstance(CLSID_InternetShortcut, NULL, | 468 HRESULT result = url_locator.CreateInstance(CLSID_InternetShortcut, NULL, |
| 469 CLSCTX_INPROC_SERVER); | 469 CLSCTX_INPROC_SERVER); |
| 470 if (FAILED(result)) | 470 if (FAILED(result)) |
| 471 return std::wstring(); | 471 return string16(); |
| 472 | 472 |
| 473 base::win::ScopedComPtr<IPersistFile> persist_file; | 473 base::win::ScopedComPtr<IPersistFile> persist_file; |
| 474 result = persist_file.QueryFrom(url_locator); | 474 result = persist_file.QueryFrom(url_locator); |
| 475 if (FAILED(result)) | 475 if (FAILED(result)) |
| 476 return std::wstring(); | 476 return string16(); |
| 477 | 477 |
| 478 // Loads the Internet Shortcut from persistent storage. | 478 // Loads the Internet Shortcut from persistent storage. |
| 479 result = persist_file->Load(file.c_str(), STGM_READ); | 479 result = persist_file->Load(file.c_str(), STGM_READ); |
| 480 if (FAILED(result)) | 480 if (FAILED(result)) |
| 481 return std::wstring(); | 481 return string16(); |
| 482 | 482 |
| 483 result = url_locator->GetURL(&url); | 483 result = url_locator->GetURL(&url); |
| 484 // GetURL can return S_FALSE (FAILED(S_FALSE) is false) when url == NULL. | 484 // GetURL can return S_FALSE (FAILED(S_FALSE) is false) when url == NULL. |
| 485 if (FAILED(result) || (url == NULL)) | 485 if (FAILED(result) || (url == NULL)) |
| 486 return std::wstring(); | 486 return string16(); |
| 487 | 487 |
| 488 return std::wstring(url); | 488 return string16(url); |
| 489 } | 489 } |
| 490 | 490 |
| 491 bool IEImporter::GetFavoritesInfo(IEImporter::FavoritesInfo* info) { | 491 bool IEImporter::GetFavoritesInfo(IEImporter::FavoritesInfo* info) { |
| 492 if (!source_path_.empty()) { | 492 if (!source_path_.empty()) { |
| 493 // Source path exists during testing. | 493 // Source path exists during testing. |
| 494 info->path = source_path_; | 494 info->path = source_path_; |
| 495 info->path = info->path.AppendASCII("Favorites"); | 495 info->path = info->path.AppendASCII("Favorites"); |
| 496 info->links_folder = L"Links"; | 496 info->links_folder = L"Links"; |
| 497 return true; | 497 return true; |
| 498 } | 498 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 if (version < 0) { | 588 if (version < 0) { |
| 589 wchar_t buffer[128]; | 589 wchar_t buffer[128]; |
| 590 DWORD buffer_length = sizeof(buffer); | 590 DWORD buffer_length = sizeof(buffer); |
| 591 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, | 591 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, |
| 592 L"Software\\Microsoft\\Internet Explorer", KEY_READ); | 592 L"Software\\Microsoft\\Internet Explorer", KEY_READ); |
| 593 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 593 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
| 594 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 594 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
| 595 } | 595 } |
| 596 return version; | 596 return version; |
| 597 } | 597 } |
| OLD | NEW |