Browse Source

Migrate from ScopedComPtr::CreateInstance() to CoCreateInstance in chrome/...

https://codereview.chromium.org/2894483002
Aleksei Kuzmin 7 years ago
parent
commit
7f5fbb04e2

+ 4 - 2
atom/browser/native_window_views.cc

@@ -4,6 +4,7 @@
 
 #include "atom/browser/native_window_views.h"
 
+#include <objbase.h>
 #include <string>
 #include <vector>
 
@@ -756,8 +757,9 @@ void NativeWindowViews::FlashFrame(bool flash) {
 void NativeWindowViews::SetSkipTaskbar(bool skip) {
 #if defined(OS_WIN)
   base::win::ScopedComPtr<ITaskbarList> taskbar;
-  if (FAILED(taskbar.CreateInstance(CLSID_TaskbarList, NULL,
-                                    CLSCTX_INPROC_SERVER)) ||
+  if (FAILED(::CoCreateInstance(CLSID_TaskbarList, nullptr,
+                                CLSCTX_INPROC_SERVER,
+                                IID_PPV_ARGS(&taskbar))) ||
       FAILED(taskbar->HrInit()))
     return;
   if (skip) {

+ 4 - 3
atom/browser/ui/win/taskbar_host.cc

@@ -4,6 +4,7 @@
 
 #include "atom/browser/ui/win/taskbar_host.h"
 
+#include <objbase.h>
 #include <string>
 
 #include "atom/browser/native_window.h"
@@ -203,9 +204,9 @@ bool TaskbarHost::HandleThumbarButtonEvent(int button_id) {
 }
 
 bool TaskbarHost::InitializeTaskbar() {
-  if (FAILED(taskbar_.CreateInstance(CLSID_TaskbarList,
-                                     nullptr,
-                                     CLSCTX_INPROC_SERVER)) ||
+  if (FAILED(::CoCreateInstance(CLSID_TaskbarList, nullptr,
+                                CLSCTX_INPROC_SERVER,
+                                IID_PPV_ARGS(&taskbar_))) ||
       FAILED(taskbar_->HrInit())) {
     return false;
   } else {

+ 3 - 1
atom/common/platform_util_win.cc

@@ -10,6 +10,7 @@
 #include <comdef.h>
 #include <commdlg.h>
 #include <dwmapi.h>
+#include <objbase.h>
 #include <shellapi.h>
 #include <shlobj.h>
 
@@ -328,7 +329,8 @@ bool MoveItemToTrash(const base::FilePath& path) {
     return false;
 
   base::win::ScopedComPtr<IFileOperation> pfo;
-  if (FAILED(pfo.CreateInstance(CLSID_FileOperation)))
+  if (FAILED(::CoCreateInstance(CLSID_FileOperation, nullptr, CLSCTX_ALL,
+                                IID_PPV_ARGS(&pfo))))
     return false;
 
   // Elevation prompt enabled for UAC protected files.  This overrides the

+ 3 - 1
chromium_src/chrome/browser/speech/tts_win.cc

@@ -3,6 +3,7 @@
 // found in the LICENSE file.
 
 #include <math.h>
+#include <objbase.h>
 #include <sapi.h>
 
 #include "base/memory/singleton.h"
@@ -232,7 +233,8 @@ TtsPlatformImplWin::TtsPlatformImplWin()
     stream_number_(0),
     char_position_(0),
     paused_(false) {
-  speech_synthesizer_.CreateInstance(CLSID_SpVoice);
+  ::CoCreateInstance(CLSID_SpVoice, nullptr, CLSCTX_ALL,
+                     IID_PPV_ARGS(&speech_synthesizer_));
   if (speech_synthesizer_.Get()) {
     ULONGLONG event_mask =
         SPFEI(SPEI_START_INPUT_STREAM) |