OLD | NEW |
| (Empty) |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "webkit/default_plugin/activex_installer.h" | |
6 #include "base/string_util.h" | |
7 | |
8 ActiveXInstaller::ActiveXInstaller() | |
9 : wnd_(NULL), | |
10 notification_msg_(0) { | |
11 } | |
12 | |
13 void ActiveXInstaller::Cleanup() { | |
14 if (bind_ctx_ != NULL) { | |
15 RevokeBindStatusCallback(bind_ctx_, this); | |
16 bind_ctx_.Release(); | |
17 } | |
18 } | |
19 | |
20 HRESULT ActiveXInstaller::StartDownload(const std::string& clsid, | |
21 const std::string& codebase, | |
22 HWND wnd, | |
23 UINT notification_msg) { | |
24 wnd_ = wnd; | |
25 notification_msg_ = notification_msg; | |
26 | |
27 HRESULT hr = E_FAIL; | |
28 do { | |
29 CLSID id; | |
30 hr = CLSIDFromString(const_cast<LPOLESTR>(ASCIIToWide(clsid).c_str()), &id); | |
31 if (FAILED(hr)) | |
32 break; | |
33 | |
34 // Create the bind context, register it with myself (status callback). | |
35 hr = CreateBindCtx(0, bind_ctx_.Receive()); | |
36 if (FAILED(hr)) | |
37 break; | |
38 BIND_OPTS opts; | |
39 opts.cbStruct = sizeof(opts); | |
40 bind_ctx_->GetBindOptions(&opts); | |
41 opts.grfFlags |= BIND_MAYBOTHERUSER; | |
42 bind_ctx_->SetBindOptions(&opts); | |
43 | |
44 hr = RegisterBindStatusCallback(bind_ctx_, this, 0, 0); | |
45 if (FAILED(hr)) | |
46 break; | |
47 CComPtr<IClassFactory> class_factory; | |
48 hr = CoGetClassObjectFromURL(id, ASCIIToWide(codebase).c_str(), 0xffffffff, | |
49 0xffffffff, NULL, bind_ctx_, | |
50 CLSCTX_INPROC_HANDLER | CLSCTX_INPROC_SERVER, | |
51 0, IID_IClassFactory, (void**)&class_factory); | |
52 } while(false); | |
53 | |
54 switch (hr) { | |
55 case S_OK: | |
56 PostMessage(wnd_, notification_msg_, hr, 0); | |
57 break; | |
58 case MK_S_ASYNCHRONOUS: | |
59 // Still need to wait until IBindStatusCallback is updated. | |
60 break; | |
61 default: | |
62 PostMessage(wnd_, notification_msg_, hr, 0); | |
63 break; | |
64 } | |
65 return hr; | |
66 } | |
67 | |
68 HRESULT STDMETHODCALLTYPE ActiveXInstaller::OnStartBinding(DWORD dw_reserved, | |
69 IBinding* pib) { | |
70 return S_OK; | |
71 } | |
72 | |
73 HRESULT STDMETHODCALLTYPE ActiveXInstaller::GetPriority(LONG* pn_priority) { | |
74 return E_NOTIMPL; | |
75 } | |
76 | |
77 HRESULT STDMETHODCALLTYPE ActiveXInstaller::OnLowResource(DWORD reserved) { | |
78 return E_NOTIMPL; | |
79 } | |
80 | |
81 HRESULT STDMETHODCALLTYPE ActiveXInstaller::OnProgress(ULONG ul_progress, | |
82 ULONG ul_progress_max, | |
83 ULONG ul_status_code, | |
84 LPCWSTR sz_status_text) { | |
85 return S_OK; | |
86 } | |
87 | |
88 HRESULT STDMETHODCALLTYPE ActiveXInstaller::OnStopBinding(HRESULT hresult, | |
89 LPCWSTR sz_error) { | |
90 if (wnd_) | |
91 PostMessage(wnd_, notification_msg_, hresult, 0); | |
92 return S_OK; | |
93 } | |
94 | |
95 HRESULT STDMETHODCALLTYPE ActiveXInstaller::GetBindInfo(DWORD* grf_bindf, | |
96 BINDINFO* pbindinfo) { | |
97 return S_OK; | |
98 } | |
99 | |
100 HRESULT STDMETHODCALLTYPE ActiveXInstaller::OnDataAvailable( | |
101 DWORD grf_bscf, | |
102 DWORD dw_size, | |
103 FORMATETC* pformatetc, | |
104 STGMEDIUM* pstgmed) { | |
105 return S_OK; | |
106 } | |
107 | |
108 HRESULT STDMETHODCALLTYPE ActiveXInstaller::OnObjectAvailable(REFIID riid, | |
109 IUnknown* punk) { | |
110 return S_OK; | |
111 } | |
112 | |
113 HRESULT STDMETHODCALLTYPE ActiveXInstaller::GetWindow(REFGUID rguid_reason, | |
114 HWND* phwnd) { | |
115 *phwnd = wnd_; | |
116 return S_OK; | |
117 } | |
OLD | NEW |