summaryrefslogtreecommitdiffstats
path: root/webkit/activex_shim
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 21:01:28 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 21:01:28 +0000
commit86351070b0f0a5822ca7f24dcf6421a5415912cd (patch)
tree5a379786fccbc0530509f3b6e0dade8ff35d7981 /webkit/activex_shim
parentcb3e11bc3f429e536d6366ffc7d1fe899eb8c8c0 (diff)
downloadchromium_src-86351070b0f0a5822ca7f24dcf6421a5415912cd.zip
chromium_src-86351070b0f0a5822ca7f24dcf6421a5415912cd.tar.gz
chromium_src-86351070b0f0a5822ca7f24dcf6421a5415912cd.tar.bz2
Use ScopedComPtr instead of CComPtr to remove a dependency on ATL.
BUG=5024 TEST=none Review URL: http://codereview.chromium.org/172105 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25239 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/activex_shim')
-rw-r--r--webkit/activex_shim/activex_plugin.cc25
-rw-r--r--webkit/activex_shim/activex_util.cc52
-rw-r--r--webkit/activex_shim/web_activex_container.cc7
-rw-r--r--webkit/activex_shim/web_activex_site.cc21
-rw-r--r--webkit/activex_shim/web_activex_site.h18
5 files changed, 72 insertions, 51 deletions
diff --git a/webkit/activex_shim/activex_plugin.cc b/webkit/activex_shim/activex_plugin.cc
index e033d4c..5c96b44 100644
--- a/webkit/activex_shim/activex_plugin.cc
+++ b/webkit/activex_shim/activex_plugin.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/fix_wp64.h"
+#include "base/scoped_comptr_win.h"
#include "base/string_util.h"
#include "googleurl/src/gurl.h"
#include "webkit/activex_shim/activex_shared.h"
@@ -277,12 +278,16 @@ NPError ActiveXPlugin::NPP_SetWindow(NPWindow* window) {
GetWindowLong(hwnd, GWL_STYLE) | WS_CLIPCHILDREN |
WS_CLIPSIBLINGS);
// If the control has a window, we need to subclass it.
- CComQIPtr<IOleWindow> ole_window = container_->GetFirstControl();
- if (ole_window != NULL) {
- HWND control_wnd = NULL;
- hr = ole_window->GetWindow(&control_wnd);
- if (SUCCEEDED(hr)) {
- SubclassWindow(control_wnd, ControlWindowProc);
+ IUnknown* control = container_->GetFirstControl();
+ if (control) {
+ ScopedComPtr<IOleWindow> ole_window;
+ ole_window.QueryFrom(control);
+ if (ole_window != NULL) {
+ HWND control_wnd = NULL;
+ hr = ole_window->GetWindow(&control_wnd);
+ if (SUCCEEDED(hr)) {
+ SubclassWindow(control_wnd, ControlWindowProc);
+ }
}
}
}
@@ -441,11 +446,11 @@ void ActiveXPlugin::Draw(HDC dc, RECT* lprc, RECT* lpclip) {
}
IDispatch* ActiveXPlugin::GetDispatch() {
- if (container_ == NULL)
+ if (container_ == NULL || container_->GetFirstControl() == NULL)
return NULL;
- IUnknown* unk = container_->GetFirstControl();
- CComQIPtr<IDispatch> disp = unk;
- if (disp == NULL)
+ ScopedComPtr<IDispatch> disp;
+ disp.QueryFrom(container_->GetFirstControl());
+ if (!disp)
return NULL;
IDispatch* res = disp.Detach();
res->Release();
diff --git a/webkit/activex_shim/activex_util.cc b/webkit/activex_shim/activex_util.cc
index 674c53f..4b16764 100644
--- a/webkit/activex_shim/activex_util.cc
+++ b/webkit/activex_shim/activex_util.cc
@@ -8,6 +8,7 @@
#include <math.h>
#include <ocmm.h>
+#include "base/scoped_comptr_win.h"
#include "base/string_util.h"
#include "webkit/activex_shim/npp_impl.h"
#include "webkit/activex_shim/activex_plugin.h"
@@ -104,10 +105,10 @@ static bool DispGetFuncDesc(IDispatch* disp, const wchar_t* name,
if (disp == NULL)
return false;
bool res = false;
- CComPtr<ITypeInfo> tpi;
+ ScopedComPtr<ITypeInfo> tpi;
TYPEATTR* typeattr = NULL;
do {
- HRESULT hr = disp->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &tpi);
+ HRESULT hr = disp->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, tpi.Receive());
if (FAILED(hr))
break;
hr = tpi->GetTypeAttr(&typeattr);
@@ -238,37 +239,42 @@ bool TestAndSetObjectSafetyOption(IObjectSafety* object_safety,
}
unsigned long GetAndSetObjectSafetyOptions(IUnknown* control) {
- unsigned long ret = 0;
+ if (!control)
+ return 0;
// If we have the interface then check that first.
- CComQIPtr<IObjectSafety> object_safety = control;
- if (object_safety != NULL) {
- // Some controls only claim IPersistPropertyBag is safe. The best way
- // would be checking if an interface is safe only when we use it. In reality
- // this is sufficient enough, considering we have a whitelist.
- static IID persist_iids[] = {IID_IPersist, IID_IPersistPropertyBag,
- IID_IPersistPropertyBag2};
- for (int i = 0; i < arraysize(persist_iids); ++i) {
- if (TestAndSetObjectSafetyOption(object_safety, persist_iids[i],
- INTERFACESAFE_FOR_UNTRUSTED_DATA)) {
- ret |= SAFE_FOR_INITIALIZING;
- break;
- }
+ ScopedComPtr<IObjectSafety> object_safety;
+ object_safety.QueryFrom(control);
+ if (!object_safety)
+ return 0;
+
+ unsigned long ret = 0;
+
+ // Some controls only claim IPersistPropertyBag is safe. The best way
+ // would be checking if an interface is safe only when we use it. In reality
+ // this is sufficient enough, considering we have a whitelist.
+ static IID persist_iids[] = {IID_IPersist, IID_IPersistPropertyBag,
+ IID_IPersistPropertyBag2};
+ for (int i = 0; i < arraysize(persist_iids); ++i) {
+ if (TestAndSetObjectSafetyOption(object_safety, persist_iids[i],
+ INTERFACESAFE_FOR_UNTRUSTED_DATA)) {
+ ret |= SAFE_FOR_INITIALIZING;
+ break;
}
- if (TestAndSetObjectSafetyOption(object_safety, IID_IDispatch,
- INTERFACESAFE_FOR_UNTRUSTED_CALLER))
- ret |= SAFE_FOR_SCRIPTING;
}
+ if (TestAndSetObjectSafetyOption(object_safety, IID_IDispatch,
+ INTERFACESAFE_FOR_UNTRUSTED_CALLER))
+ ret |= SAFE_FOR_SCRIPTING;
+
return ret;
}
unsigned long GetRegisteredObjectSafetyOptions(const CLSID& clsid) {
unsigned long ret = 0;
HRESULT hr;
- CComPtr<ICatInformation> cat_info;
- hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,
- NULL, CLSCTX_INPROC_SERVER, IID_ICatInformation,
- reinterpret_cast<void**>(&cat_info));
+ ScopedComPtr<ICatInformation> cat_info;
+ hr = cat_info.CreateInstance(CLSID_StdComponentCategoriesMgr,
+ NULL, CLSCTX_INPROC_SERVER);
DCHECK(SUCCEEDED(hr));
if (FAILED(hr))
return ret;
diff --git a/webkit/activex_shim/web_activex_container.cc b/webkit/activex_shim/web_activex_container.cc
index 60a120c..4038f78 100644
--- a/webkit/activex_shim/web_activex_container.cc
+++ b/webkit/activex_shim/web_activex_container.cc
@@ -4,6 +4,7 @@
#include "webkit/activex_shim/web_activex_container.h"
+#include "base/scoped_comptr_win.h"
#include "webkit/activex_shim/activex_plugin.h"
#include "webkit/activex_shim/activex_util.h"
#include "webkit/activex_shim/npn_scripting.h"
@@ -307,7 +308,11 @@ bool WebActiveXContainer::OnWindowMessage(UINT msg, WPARAM wparam,
HRESULT hr;
for (unsigned int i = 0; i < sites_.size(); i++) {
WebActiveXSite* site = sites_[i];
- CComQIPtr<IOleInPlaceObjectWindowless> windowless = site->control_;
+ if (!site->control_)
+ continue;
+
+ ScopedComPtr<IOleInPlaceObjectWindowless> windowless;
+ windowless.QueryFrom(site->control_);
if (windowless == NULL)
continue;
diff --git a/webkit/activex_shim/web_activex_site.cc b/webkit/activex_shim/web_activex_site.cc
index 8b26313..f3610d38 100644
--- a/webkit/activex_shim/web_activex_site.cc
+++ b/webkit/activex_shim/web_activex_site.cc
@@ -32,13 +32,14 @@ WebActiveXSite::~WebActiveXSite() {
}
void WebActiveXSite::Init(WebActiveXContainer* container, IUnknown* control) {
+ DCHECK(control);
container_ = container;
control_.Attach(control);
- dispatch_ = control;
- ole_object_ = control;
- inplace_object_ = control;
- view_object_ = control;
- inplace_object_windowless_ = control;
+ dispatch_.QueryFrom(control);
+ ole_object_.QueryFrom(control);
+ inplace_object_.QueryFrom(control);
+ view_object_.QueryFrom(control);
+ inplace_object_windowless_.QueryFrom(control);
}
void WebActiveXSite::FinalRelease() {
@@ -76,6 +77,8 @@ void WebActiveXSite::FinalRelease() {
HRESULT WebActiveXSite::ActivateControl(
int x, int y, int width, int height,
const std::vector<ControlParam>& params) {
+ DCHECK(control_);
+
// Set the rect size of site first before SetClientSite. Otherwise the
// control may query the site for such information during SetClientSite.
rect_.left = x;
@@ -92,8 +95,10 @@ HRESULT WebActiveXSite::ActivateControl(
SetExtent(width, height);
// Set initial properties.
- CComQIPtr<IPersistPropertyBag> persist_property_bag = control_;
- CComQIPtr<IPersistPropertyBag2> persist_property_bag2 = control_;
+ ScopedComPtr<IPersistPropertyBag> persist_property_bag;
+ persist_property_bag.QueryFrom(control_);
+ ScopedComPtr<IPersistPropertyBag2> persist_property_bag2;
+ persist_property_bag2.QueryFrom(control_);
if (persist_property_bag2 != NULL || persist_property_bag != NULL) {
// Use property bag for initialization. This is the preferred way.
initial_params_ = params;
@@ -203,7 +208,7 @@ HRESULT STDMETHODCALLTYPE WebActiveXSite::QueryInterface(REFIID iid,
// IOleClientSite
HRESULT STDMETHODCALLTYPE WebActiveXSite::SaveObject() {
- // Do not support saving object to persistant storage.
+ // Do not support saving object to persistent storage.
return E_NOTIMPL;
}
diff --git a/webkit/activex_shim/web_activex_site.h b/webkit/activex_shim/web_activex_site.h
index b3201dc..456e3db 100644
--- a/webkit/activex_shim/web_activex_site.h
+++ b/webkit/activex_shim/web_activex_site.h
@@ -5,11 +5,11 @@
#ifndef WEBKIT_ACTIVEX_SHIM_WEB_ACTIVEX_SITE_H__
#define WEBKIT_ACTIVEX_SHIM_WEB_ACTIVEX_SITE_H__
-#include <atlbase.h>
-#include <atlcom.h>
#include <objsafe.h>
#include <map>
#include <vector>
+
+#include "base/scoped_comptr_win.h"
#include "webkit/activex_shim/activex_util.h"
namespace activex_shim {
@@ -198,15 +198,15 @@ class WebActiveXSite : public MinimumIDispatchImpl,
WebActiveXContainer* container_;
// Theorectically the control could support only IUnknown interface. This is
- // is the minimum requirement.
- CComPtr<IUnknown> control_;
+ // the minimum requirement.
+ ScopedComPtr<IUnknown> control_;
// These are all optional interfaces and they could be NULL even if we have
// created the control successfully.
- CComQIPtr<IDispatch> dispatch_;
- CComQIPtr<IOleObject> ole_object_;
- CComQIPtr<IOleInPlaceObject> inplace_object_;
- CComQIPtr<IViewObject> view_object_;
- CComQIPtr<IOleInPlaceObjectWindowless> inplace_object_windowless_;
+ ScopedComPtr<IDispatch> dispatch_;
+ ScopedComPtr<IOleObject> ole_object_;
+ ScopedComPtr<IOleInPlaceObject> inplace_object_;
+ ScopedComPtr<IViewObject> view_object_;
+ ScopedComPtr<IOleInPlaceObjectWindowless> inplace_object_windowless_;
RECT rect_;
// We need to remember whether we are activated so we can decide whether to
// deactivate during destruction.