summaryrefslogtreecommitdiffstats
path: root/chrome/browser/jumplist_win.cc
diff options
context:
space:
mode:
authorgab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-03 07:29:56 +0000
committergab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-03 07:29:56 +0000
commit76602ffe79164dfcc39b001e15d9950418bb7998 (patch)
treeadf004a007a8793f3d74f135a84ec8a4d653e3eb /chrome/browser/jumplist_win.cc
parentfae2fb0a99eec92ee3d1024b181c47fda265bdb5 (diff)
downloadchromium_src-76602ffe79164dfcc39b001e15d9950418bb7998.zip
chromium_src-76602ffe79164dfcc39b001e15d9950418bb7998.tar.gz
chromium_src-76602ffe79164dfcc39b001e15d9950418bb7998.tar.bz2
Replace all PROPVARIANTs by base::win::ScopedPropVariant across the entire codebase.
Follow-up to crrev.com/177951. Fixes a memory leak in ie_importer.cc. BUG=None Review URL: https://chromiumcodereview.appspot.com/12092077 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/jumplist_win.cc')
-rw-r--r--chrome/browser/jumplist_win.cc47
1 files changed, 10 insertions, 37 deletions
diff --git a/chrome/browser/jumplist_win.cc b/chrome/browser/jumplist_win.cc
index 660c9b6..97891f9 100644
--- a/chrome/browser/jumplist_win.cc
+++ b/chrome/browser/jumplist_win.cc
@@ -21,6 +21,7 @@
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
#include "base/win/scoped_comptr.h"
+#include "base/win/scoped_propvariant.h"
#include "base/win/windows_version.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
@@ -140,40 +141,6 @@ const CLSID CLSID_EnumerableObjectCollection = {
namespace {
-// Represents a class which encapsulates a PROPVARIANT object containing a
-// string for AddShellLink().
-// This class automatically deletes all the resources attached to the
-// PROPVARIANT object in its destructor.
-class PropVariantString {
- public:
- PropVariantString() {
- property_.vt = VT_EMPTY;
- }
-
- HRESULT Init(const std::wstring& value) {
- // Call InitPropVariantFromString() to initialize this PROPVARIANT object.
- // To read <propvarutil.h>, it seems InitPropVariantFromString() is an
- // inline function that initialize a PROPVARIANT object and calls
- // SHStrDupW() to set a copy of its input string.
- // So, we just calls it without creating a copy.
- return InitPropVariantFromString(value.c_str(), &property_);
- }
-
- ~PropVariantString() {
- if (property_.vt != VT_EMPTY)
- PropVariantClear(&property_);
- }
-
- const PROPVARIANT& Get() {
- return property_;
- }
-
- private:
- PROPVARIANT property_;
-
- DISALLOW_COPY_AND_ASSIGN(PropVariantString);
-};
-
// Creates an IShellLink object.
// An IShellLink object is almost the same as an application shortcut, and it
// requires three items: the absolute path to an application, an argument
@@ -233,12 +200,18 @@ HRESULT AddShellLink(base::win::ScopedComPtr<IObjectCollection> collection,
if (FAILED(result))
return result;
- PropVariantString property_title;
- result = property_title.Init(item->title());
+ base::win::ScopedPropVariant property_title;
+ // Call InitPropVariantFromString() to initialize |property_title|. Reading
+ // <propvarutil.h>, it seems InitPropVariantFromString() is an inline function
+ // that initializes a PROPVARIANT object and calls SHStrDupW() to set a copy
+ // of its input string. It is thus safe to call it without first creating a
+ // copy here.
+ result = InitPropVariantFromString(item->title().c_str(),
+ property_title.Receive());
if (FAILED(result))
return result;
- result = property_store->SetValue(PKEY_Title, property_title.Get());
+ result = property_store->SetValue(PKEY_Title, property_title.get());
if (FAILED(result))
return result;