diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 20:04:07 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 20:04:07 +0000 |
commit | 530f43f302f1eef9d3530767015891f1db1f1272 (patch) | |
tree | 2006b20ca4022116b5d8c04784cec8802fb4d262 /chrome/browser/importer | |
parent | 0b9158f07ac7c5ed1dc1c166e4a1513d6fbbb9e9 (diff) | |
download | chromium_src-530f43f302f1eef9d3530767015891f1db1f1272.zip chromium_src-530f43f302f1eef9d3530767015891f1db1f1272.tar.gz chromium_src-530f43f302f1eef9d3530767015891f1db1f1272.tar.bz2 |
Use ScopedComPtr instead of CComPtr to reduce a dependency on ATL.
BUG=5027
TEST=none
Review URL: http://codereview.chromium.org/201012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r-- | chrome/browser/importer/ie_importer.cc | 30 | ||||
-rw-r--r-- | chrome/browser/importer/importer_unittest.cc | 27 |
2 files changed, 28 insertions, 29 deletions
diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index ac345a7..1a0d86a 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -4,7 +4,6 @@ #include "chrome/browser/importer/ie_importer.h" -#include <atlbase.h> #include <intshcut.h> #include <pstore.h> #include <shlobj.h> @@ -17,6 +16,7 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/registry.h" +#include "base/scoped_comptr_win.h" #include "base/string_util.h" #include "base/time.h" #include "base/win_util.h" @@ -142,8 +142,8 @@ void IEImporter::ImportPasswordsIE6() { return; } - CComPtr<IPStore> pstore; - HRESULT result = PStoreCreateInstance(&pstore, 0, 0, 0); + ScopedComPtr<IPStore, &IID_IPStore> pstore; + HRESULT result = PStoreCreateInstance(pstore.Receive(), 0, 0, 0); if (result != S_OK) { FreeLibrary(pstorec_dll); return; @@ -152,9 +152,9 @@ void IEImporter::ImportPasswordsIE6() { std::vector<AutoCompleteInfo> ac_list; // Enumerates AutoComplete items in the protected database. - CComPtr<IEnumPStoreItems> item; + ScopedComPtr<IEnumPStoreItems, &IID_IEnumPStoreItems> item; result = pstore->EnumItems(0, &AutocompleteGUID, - &AutocompleteGUID, 0, &item); + &AutocompleteGUID, 0, item.Receive()); if (result != PST_E_OK) { pstore.Release(); FreeLibrary(pstorec_dll); @@ -282,14 +282,14 @@ void IEImporter::ImportHistory() { chrome::kFileScheme}; int total_schemes = arraysize(kSchemes); - CComPtr<IUrlHistoryStg2> url_history_stg2; + ScopedComPtr<IUrlHistoryStg2> url_history_stg2; HRESULT result; - result = url_history_stg2.CoCreateInstance(CLSID_CUrlHistory, NULL, - CLSCTX_INPROC_SERVER); + result = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, + CLSCTX_INPROC_SERVER); if (FAILED(result)) return; - CComPtr<IEnumSTATURL> enum_url; - if (SUCCEEDED(result = url_history_stg2->EnumUrls(&enum_url))) { + ScopedComPtr<IEnumSTATURL> enum_url; + if (SUCCEEDED(result = url_history_stg2->EnumUrls(enum_url.Receive()))) { std::vector<history::URLRow> rows; STATURL stat_url; ULONG fetched; @@ -541,14 +541,14 @@ void IEImporter::ParseFavoritesFolder(const FavoritesInfo& info, std::wstring IEImporter::ResolveInternetShortcut(const std::wstring& file) { win_util::CoMemReleaser<wchar_t> url; - CComPtr<IUniformResourceLocator> url_locator; - HRESULT result = url_locator.CoCreateInstance(CLSID_InternetShortcut, NULL, - CLSCTX_INPROC_SERVER); + ScopedComPtr<IUniformResourceLocator> url_locator; + HRESULT result = url_locator.CreateInstance(CLSID_InternetShortcut, NULL, + CLSCTX_INPROC_SERVER); if (FAILED(result)) return std::wstring(); - CComPtr<IPersistFile> persist_file; - result = url_locator.QueryInterface(&persist_file); + ScopedComPtr<IPersistFile> persist_file; + result = persist_file.QueryFrom(url_locator); if (FAILED(result)) return std::wstring(); diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index 6fb452f..20581a1 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -4,7 +4,6 @@ #include "testing/gtest/include/gtest/gtest.h" -#include <atlbase.h> #include <windows.h> #include <unknwn.h> #include <intshcut.h> @@ -17,6 +16,7 @@ #include "base/file_util.h" #include "base/message_loop.h" #include "base/path_service.h" +#include "base/scoped_comptr_win.h" #include "base/stl_util-inl.h" #include "chrome/browser/importer/ie_importer.h" #include "chrome/browser/importer/importer.h" @@ -258,14 +258,13 @@ class TestObserver : public ProfileWriter, }; bool CreateUrlFile(std::wstring file, std::wstring url) { - CComPtr<IUniformResourceLocator> locator; - HRESULT result = locator.CoCreateInstance(CLSID_InternetShortcut, NULL, - CLSCTX_INPROC_SERVER); + ScopedComPtr<IUniformResourceLocator> locator; + HRESULT result = locator.CreateInstance(CLSID_InternetShortcut, NULL, + CLSCTX_INPROC_SERVER); if (FAILED(result)) return false; - CComPtr<IPersistFile> persist_file; - result = locator->QueryInterface(IID_IPersistFile, - reinterpret_cast<void**>(&persist_file)); + ScopedComPtr<IPersistFile> persist_file; + result = persist_file.QueryFrom(locator); if (FAILED(result)) return false; result = locator->SetURL(url.c_str(), 0); @@ -278,8 +277,8 @@ bool CreateUrlFile(std::wstring file, std::wstring url) { } void ClearPStoreType(IPStore* pstore, const GUID* type, const GUID* subtype) { - CComPtr<IEnumPStoreItems> item; - HRESULT result = pstore->EnumItems(0, type, subtype, 0, &item); + ScopedComPtr<IEnumPStoreItems, NULL> item; + HRESULT result = pstore->EnumItems(0, type, subtype, 0, item.Receive()); if (result == PST_E_OK) { wchar_t* item_name; while (SUCCEEDED(item->Next(1, &item_name, 0))) { @@ -347,7 +346,7 @@ TEST_F(ImporterTest, IEImporter) { // Sets up dummy password data. HRESULT res; #if 0 // This part of the test is disabled. See bug #2466 - CComPtr<IPStore> pstore; + ScopedComPtr<IPStore> pstore; HMODULE pstorec_dll; GUID type = IEImporter::kUnittestGUID; GUID subtype = IEImporter::kUnittestGUID; @@ -357,7 +356,7 @@ TEST_F(ImporterTest, IEImporter) { pstorec_dll = LoadLibrary(L"pstorec.dll"); PStoreCreateFunc PStoreCreateInstance = (PStoreCreateFunc)GetProcAddress(pstorec_dll, "PStoreCreateInstance"); - res = PStoreCreateInstance(&pstore, 0, 0, 0); + res = PStoreCreateInstance(pstore.Receive(), 0, 0, 0); ASSERT_TRUE(res == S_OK); ClearPStoreType(pstore, &type, &subtype); PST_TYPEINFO type_info; @@ -370,9 +369,9 @@ TEST_F(ImporterTest, IEImporter) { #endif // Sets up a special history link. - CComPtr<IUrlHistoryStg2> url_history_stg2; - res = url_history_stg2.CoCreateInstance(CLSID_CUrlHistory, NULL, - CLSCTX_INPROC_SERVER); + ScopedComPtr<IUrlHistoryStg2> url_history_stg2; + res = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, + CLSCTX_INPROC_SERVER); ASSERT_TRUE(res == S_OK); res = url_history_stg2->AddUrl(kIEIdentifyUrl, kIEIdentifyTitle, 0); ASSERT_TRUE(res == S_OK); |