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

https://codereview.chromium.org/2894483002
This commit is contained in:
Aleksei Kuzmin 2017-09-10 17:10:26 +02:00 committed by Cheng Zhao
parent 79e59a88b4
commit 7f5fbb04e2
4 changed files with 14 additions and 7 deletions

View file

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

View file

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

View file

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

View file

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