OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginClient.h" | 3 #include "PluginClient.h" |
4 #include "PluginSettings.h" | 4 #include "PluginSettings.h" |
5 #ifdef SUPPORT_CONFIG | 5 #ifdef SUPPORT_CONFIG |
6 #include "PluginConfig.h" | 6 #include "PluginConfig.h" |
7 #endif | 7 #endif |
8 #include "PluginTab.h" | 8 #include "PluginTab.h" |
9 #include "PluginDomTraverser.h" | 9 #include "PluginDomTraverser.h" |
10 #include "PluginClass.h" | 10 #include "PluginClass.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 ResetEvent(m_filter->hideFiltersLoadedEvent); | 104 ResetEvent(m_filter->hideFiltersLoadedEvent); |
105 CreateThread(NULL, NULL, &FilterLoader, this, NULL, NULL); | 105 CreateThread(NULL, NULL, &FilterLoader, this, NULL, NULL); |
106 | 106 |
107 #ifdef SUPPORT_DOM_TRAVERSER | 107 #ifdef SUPPORT_DOM_TRAVERSER |
108 m_traverser->ClearCache(); | 108 m_traverser->ClearCache(); |
109 #endif | 109 #endif |
110 } | 110 } |
111 | 111 |
112 void CPluginTabBase::InjectABP(IWebBrowser2* browser) | 112 void CPluginTabBase::InjectABP(IWebBrowser2* browser) |
113 { | 113 { |
| 114 CriticalSection::Lock lock(m_csInject); |
114 CString url = GetDocumentUrl(); | 115 CString url = GetDocumentUrl(); |
115 CString log; | 116 CString log; |
116 log.Format(L"Current URL: %s, settings URL: %s", url, UserSettingsFileUrl().c_
str()); | 117 log.Format(L"InjectABP. Current URL: %s, settings URL: %s", url, UserSettingsF
ileUrl().c_str()); |
117 DEBUG_GENERAL(log); | 118 DEBUG_GENERAL(log); |
118 if (!(0 == url.CompareNoCase(CString(UserSettingsFileUrl().c_str())) || | 119 if (!(0 == url.CompareNoCase(CString(UserSettingsFileUrl().c_str())) || |
119 0 == url.CompareNoCase(CString(FirstRunPageFileUrl().c_str())))) | 120 0 == url.CompareNoCase(CString(FirstRunPageFileUrl().c_str())))) |
120 { | 121 { |
| 122 DEBUG_GENERAL(L"Not injecting"); |
121 return; | 123 return; |
122 } | 124 } |
| 125 DEBUG_GENERAL(L"Going to inject"); |
123 CComPtr<IDispatch> pDocDispatch; | 126 CComPtr<IDispatch> pDocDispatch; |
124 browser->get_Document(&pDocDispatch); | 127 browser->get_Document(&pDocDispatch); |
125 CComQIPtr<IHTMLDocument2> pDoc2 = pDocDispatch; | 128 CComQIPtr<IHTMLDocument2> pDoc2 = pDocDispatch; |
126 if (!pDoc2) | 129 if (!pDoc2) |
127 { | 130 { |
128 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CRE
ATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to QI docume
nt"); | 131 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CRE
ATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to QI docume
nt"); |
129 return; | 132 return; |
130 } | 133 } |
131 CComPtr<IHTMLWindow2> pWnd2; | 134 CComPtr<IHTMLWindow2> pWnd2; |
132 pDoc2->get_parentWindow(&pWnd2); | 135 pDoc2->get_parentWindow(&pWnd2); |
(...skipping 12 matching lines...) Expand all Loading... |
145 // A method call of "Settings" in JavaScript, transfered to "Invoke" of m_plug
inUserSettings | 148 // A method call of "Settings" in JavaScript, transfered to "Invoke" of m_plug
inUserSettings |
146 DISPID dispid; | 149 DISPID dispid; |
147 HRESULT hr = pWndEx->GetDispID(L"Settings", fdexNameEnsure, &dispid); | 150 HRESULT hr = pWndEx->GetDispID(L"Settings", fdexNameEnsure, &dispid); |
148 if (FAILED(hr)) | 151 if (FAILED(hr)) |
149 { | 152 { |
150 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CR
EATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to get disp
atch"); | 153 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CR
EATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to get disp
atch"); |
151 return; | 154 return; |
152 } | 155 } |
153 CComVariant var((IDispatch*)&m_pluginUserSettings); | 156 CComVariant var((IDispatch*)&m_pluginUserSettings); |
154 | 157 |
| 158 DEBUG_GENERAL("Injecting"); |
| 159 |
155 DISPPARAMS params; | 160 DISPPARAMS params; |
156 params.cArgs = 1; | 161 params.cArgs = 1; |
157 params.cNamedArgs = 0; | 162 params.cNamedArgs = 0; |
158 params.rgvarg = &var; | 163 params.rgvarg = &var; |
159 params.rgdispidNamedArgs = 0; | 164 params.rgdispidNamedArgs = 0; |
160 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU
T | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); | 165 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPU
T | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); |
| 166 DEBUG_GENERAL("Invoke"); |
161 if (FAILED(hr)) | 167 if (FAILED(hr)) |
162 { | 168 { |
163 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CR
EATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to create S
ettings in JavaScript"); | 169 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGIN_ERROR_CR
EATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::InjectABP - Failed to create S
ettings in JavaScript"); |
164 } | 170 } |
165 } | 171 } |
166 | 172 |
167 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser) | 173 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser) |
168 { | 174 { |
169 #ifdef SUPPORT_DOM_TRAVERSER | 175 #ifdef SUPPORT_DOM_TRAVERSER |
170 if (!CPluginClient::GetInstance()->IsWhitelistedUrl(std::wstring(GetDocumentUr
l()))) | 176 if (!CPluginClient::GetInstance()->IsWhitelistedUrl(std::wstring(GetDocumentUr
l()))) |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 380 |
375 // Non-hanging sleep | 381 // Non-hanging sleep |
376 Sleep(50); | 382 Sleep(50); |
377 } | 383 } |
378 | 384 |
379 tabLoopIteration++; | 385 tabLoopIteration++; |
380 } | 386 } |
381 | 387 |
382 return 0; | 388 return 0; |
383 } | 389 } |
OLD | NEW |