summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 18:09:12 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-10 18:09:12 +0000
commite28b0fbbcde1c08e4dfbff7d4bd8e1f292892b9c (patch)
treef95fb6c3e7fad45259ac16ca3c8fccc9fde5d312 /chrome
parent8416157dd9a3e5bd61f605e1d420d8cf6a4ef9ca (diff)
downloadchromium_src-e28b0fbbcde1c08e4dfbff7d4bd8e1f292892b9c.zip
chromium_src-e28b0fbbcde1c08e4dfbff7d4bd8e1f292892b9c.tar.gz
chromium_src-e28b0fbbcde1c08e4dfbff7d4bd8e1f292892b9c.tar.bz2
Use Scoped[Bstr,ComPtr,Variant] instead of their ATL equivalents to reduce dependencies on ATL.
BUG=5027 TEST=none Review URL: http://codereview.chromium.org/200045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25879 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_accessibility.cc11
-rw-r--r--chrome/browser/browser_accessibility.cc12
-rw-r--r--chrome/browser/history/history_publisher_win.cc30
-rw-r--r--chrome/browser/importer/ie_importer.cc36
4 files changed, 47 insertions, 42 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_accessibility.cc b/chrome/browser/autocomplete/autocomplete_accessibility.cc
index 5a9c3c6..1344e4f 100644
--- a/chrome/browser/autocomplete/autocomplete_accessibility.cc
+++ b/chrome/browser/autocomplete/autocomplete_accessibility.cc
@@ -99,7 +99,7 @@ STDMETHODIMP AutocompleteAccessibility::get_accName(VARIANT var_id,
if (!temp_name.empty()) {
// Return name retrieved.
- *name = CComBSTR(temp_name.c_str()).Detach();
+ *name = SysAllocString(temp_name.c_str());
} else {
// If no name is found, return S_FALSE.
return S_FALSE;
@@ -127,20 +127,19 @@ STDMETHODIMP AutocompleteAccessibility::get_accValue(VARIANT var_id,
std::wstring temp_value;
if (var_id.lVal != CHILDID_SELF)
- return E_INVALIDARG;
+ return E_INVALIDARG;
// Edit box has no children, only handle self.
temp_value = edit_box_->GetText();
if (temp_value.empty())
- return S_FALSE;
+ return S_FALSE;
- // Return value retrieved.
- *value = CComBSTR(temp_value.c_str()).Detach();
+ // Return value retrieved.
+ *value = SysAllocString(temp_value.c_str());
DCHECK(*value);
return S_OK;
-
}
STDMETHODIMP AutocompleteAccessibility::get_accState(VARIANT var_id,
diff --git a/chrome/browser/browser_accessibility.cc b/chrome/browser/browser_accessibility.cc
index c2a65c1b..2bae8f4 100644
--- a/chrome/browser/browser_accessibility.cc
+++ b/chrome/browser/browser_accessibility.cc
@@ -254,7 +254,7 @@ STDMETHODIMP BrowserAccessibility::get_accDefaultAction(VARIANT var_id,
return S_FALSE;
}
- *def_action = CComBSTR(response().output_string.c_str()).Detach();
+ *def_action = SysAllocString(response().output_string.c_str());
DCHECK(*def_action);
return S_OK;
@@ -280,7 +280,7 @@ STDMETHODIMP BrowserAccessibility::get_accDescription(VARIANT var_id,
return S_FALSE;
}
- *desc = CComBSTR(response().output_string.c_str()).Detach();
+ *desc = SysAllocString(response().output_string.c_str());
DCHECK(*desc);
return S_OK;
@@ -342,7 +342,7 @@ STDMETHODIMP BrowserAccessibility::get_accHelp(VARIANT var_id, BSTR* help) {
return S_FALSE;
}
- *help = CComBSTR(response().output_string.c_str()).Detach();
+ *help = SysAllocString(response().output_string.c_str());
DCHECK(*help);
return S_OK;
@@ -368,7 +368,7 @@ STDMETHODIMP BrowserAccessibility::get_accKeyboardShortcut(VARIANT var_id,
return S_FALSE;
}
- *acc_key = CComBSTR(response().output_string.c_str()).Detach();
+ *acc_key = SysAllocString(response().output_string.c_str());
DCHECK(*acc_key);
return S_OK;
@@ -393,7 +393,7 @@ STDMETHODIMP BrowserAccessibility::get_accName(VARIANT var_id, BSTR* name) {
return S_FALSE;
}
- *name = CComBSTR(response().output_string.c_str()).Detach();
+ *name = SysAllocString(response().output_string.c_str());
DCHECK(*name);
return S_OK;
@@ -504,7 +504,7 @@ STDMETHODIMP BrowserAccessibility::get_accValue(VARIANT var_id, BSTR* value) {
return S_FALSE;
}
- *value = CComBSTR(response().output_string.c_str()).Detach();
+ *value = SysAllocString(response().output_string.c_str());
DCHECK(*value);
return S_OK;
diff --git a/chrome/browser/history/history_publisher_win.cc b/chrome/browser/history/history_publisher_win.cc
index 54e9da4..cbde619 100644
--- a/chrome/browser/history/history_publisher_win.cc
+++ b/chrome/browser/history/history_publisher_win.cc
@@ -10,7 +10,10 @@
#include <wtypes.h>
#include "base/registry.h"
+#include "base/scoped_bstr_win.h"
#include "base/scoped_comptr_win.h"
+#include "base/scoped_variant_win.h"
+#include "base/string_util.h"
#include "base/time.h"
#include "googleurl/src/gurl.h"
@@ -107,30 +110,29 @@ void HistoryPublisher::PublishDataToIndexers(const PageData& page_data)
CComSafeArray<unsigned char> thumbnail_arr;
if (page_data.thumbnail) {
- for(size_t i = 0; i < page_data.thumbnail->size(); ++i)
+ for (size_t i = 0; i < page_data.thumbnail->size(); ++i)
thumbnail_arr.Add((*page_data.thumbnail)[i]);
}
// Send data to registered indexers.
- for(size_t i = 0; i < indexers_.size(); ++i) {
- indexers_[i]->SendPageData(
- CComVariant(var_time, VT_DATE),
- CComBSTR(page_data.url.spec().c_str()),
- CComBSTR(page_data.html),
- CComBSTR(page_data.title),
- CComBSTR(page_data.thumbnail_format),
- CComVariant(thumbnail_arr.m_psa));
+ ScopedVariant time(var_time, VT_DATE);
+ ScopedBstr url(ASCIIToWide(page_data.url.spec()).c_str());
+ ScopedBstr html(page_data.html);
+ ScopedBstr title(page_data.title);
+ ScopedBstr format(ASCIIToWide(page_data.thumbnail_format).c_str());
+ ScopedVariant psa(thumbnail_arr.m_psa);
+ for (size_t i = 0; i < indexers_.size(); ++i) {
+ indexers_[i]->SendPageData(time, url, html, title, format, psa);
}
}
void HistoryPublisher::DeleteUserHistoryBetween(const base::Time& begin_time,
const base::Time& end_time)
const {
- double var_begin_time = TimeToUTCVariantTime(begin_time);
- double var_end_time = TimeToUTCVariantTime(end_time);
- for(size_t i = 0; i < indexers_.size(); ++i) {
- indexers_[i]->DeleteUserHistoryBetween(CComVariant(var_begin_time, VT_DATE),
- CComVariant(var_end_time, VT_DATE));
+ ScopedVariant var_begin_time(TimeToUTCVariantTime(begin_time), VT_DATE);
+ ScopedVariant var_end_time(TimeToUTCVariantTime(end_time), VT_DATE);
+ for (size_t i = 0; i < indexers_.size(); ++i) {
+ indexers_[i]->DeleteUserHistoryBetween(var_begin_time, var_end_time);
}
}
diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc
index ac345a7..2d979ad 100644
--- a/chrome/browser/importer/ie_importer.cc
+++ b/chrome/browser/importer/ie_importer.cc
@@ -4,19 +4,23 @@
#include "chrome/browser/importer/ie_importer.h"
-#include <atlbase.h>
+#include <ole2.h>
#include <intshcut.h>
#include <pstore.h>
#include <shlobj.h>
#include <urlhist.h>
#include <algorithm>
+#include <map>
+#include <string>
+#include <vector>
#include "app/l10n_util.h"
#include "app/win_util.h"
#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"
@@ -69,7 +73,7 @@ void IEImporter::StartImport(ProfileInfo profile_info,
NotifyStarted();
- // Some IE settings (such as Protected Storage) is obtained via COM APIs.
+ // Some IE settings (such as Protected Storage) are obtained via COM APIs.
win_util::ScopedCOMInitializer com_initializer;
if ((items & HOME_PAGE) && !cancelled())
@@ -142,8 +146,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 +156,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 +286,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 +545,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();