Left: | ||
Right: |
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 | 102 |
103 std::wstring domainString = GetDocumentDomain(); | 103 std::wstring domainString = GetDocumentDomain(); |
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) | |
113 { | |
114 CString url = GetDocumentUrl(); | |
115 CString log; | |
116 log.Format(L"Current URL: %s, settings URL: %s", url, UserSettingsFileUrl().c_ str()); | |
117 DEBUG_GENERAL(log); | |
118 if (0 == url.CompareNoCase(CString(UserSettingsFileUrl().c_str())) || | |
119 0 == url.CompareNoCase(CString(FirstRunPageFileUrl().c_str())) ) | |
120 { | |
121 CComPtr<IDispatch> pDocDispatch; | |
122 browser->get_Document(&pDocDispatch); | |
123 CComQIPtr<IHTMLDocument2> pDoc2 = pDocDispatch; | |
124 if (pDoc2) | |
Wladimir Palant
2013/08/13 09:48:34
Now that this is a separate function we can avoid
| |
125 { | |
126 CComPtr<IHTMLWindow2> pWnd2; | |
127 pDoc2->get_parentWindow(&pWnd2); | |
128 if (pWnd2) | |
129 { | |
130 CComQIPtr<IDispatchEx> pWndEx = pWnd2; | |
131 if (pWndEx) | |
132 { | |
133 // Create "Settings" object in JavaScript. | |
134 // A method call of "Settings" in JavaScript, transfered to "Invoke" o f m_pluginUserSettings | |
135 DISPID dispid; | |
136 HRESULT hr = pWndEx->GetDispID(L"Settings", fdexNameEnsure, &dispid); | |
137 if (SUCCEEDED(hr)) | |
138 { | |
139 CComVariant var((IDispatch*)&m_pluginUserSettings); | |
140 | |
141 DISPPARAMS params; | |
142 params.cArgs = 1; | |
143 params.cNamedArgs = 0; | |
144 params.rgvarg = &var; | |
145 params.rgdispidNamedArgs = 0; | |
146 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_ PROPERTYPUT | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); | |
147 if (FAILED(hr)) | |
148 { | |
149 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLUGI N_ERROR_CREATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::OnDocumentComplete - Failed to create Settings in JavaScript"); | |
Felix Dahlke
2013/08/08 08:47:53
It's CPluginTabBase::InjectABP now, isn't it?
Oleksandr
2013/08/08 14:08:47
It is, yes.
On 2013/08/08 08:47:53, Felix H. Dahlk
| |
150 } | |
151 } | |
152 } | |
153 } | |
154 } | |
155 } | |
156 } | |
157 | |
112 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser) | 158 void CPluginTabBase::OnDownloadComplete(IWebBrowser2* browser) |
113 { | 159 { |
114 #ifdef SUPPORT_DOM_TRAVERSER | 160 #ifdef SUPPORT_DOM_TRAVERSER |
115 if (!CPluginClient::GetInstance()->IsWhitelistedUrl(std::wstring(GetDocumentUr l()))) | 161 if (!CPluginClient::GetInstance()->IsWhitelistedUrl(std::wstring(GetDocumentUr l()))) |
116 { | 162 { |
117 m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl() ); | 163 m_traverser->TraverseDocument(browser, GetDocumentDomain(), GetDocumentUrl() ); |
118 } | 164 } |
119 #endif // SUPPORT_DOM_TRAVERSER | 165 #endif // SUPPORT_DOM_TRAVERSER |
166 | |
167 InjectABP(browser); | |
120 } | 168 } |
121 | 169 |
122 | |
123 void CPluginTabBase::OnDocumentComplete(IWebBrowser2* browser, const CString& ur l, bool isDocumentBrowser) | 170 void CPluginTabBase::OnDocumentComplete(IWebBrowser2* browser, const CString& ur l, bool isDocumentBrowser) |
124 { | 171 { |
125 CString documentUrl = GetDocumentUrl(); | 172 CString documentUrl = GetDocumentUrl(); |
126 | 173 |
127 if (isDocumentBrowser) | 174 if (isDocumentBrowser) |
128 { | 175 { |
129 if (url != documentUrl) | 176 if (url != documentUrl) |
130 { | 177 { |
131 SetDocumentUrl(url); | 178 SetDocumentUrl(url); |
132 } | 179 } |
133 | 180 InjectABP(browser); |
Felix Dahlke
2013/08/08 08:47:53
So OnDocumentComplete is only called once, not on
Oleksandr
2013/08/08 14:08:47
No, I have checked the events raised. It isn't fir
Felix Dahlke
2013/08/08 14:19:05
So, initially, OnDocumentComplete is fired and OnD
Oleksandr
2013/08/08 16:00:04
No, I got it a bit wrong actually. Both events are
Felix Dahlke
2013/08/08 16:20:59
That's fine by me, but isn't InjectABP being calle
Oleksandr
2013/08/09 07:07:48
InjectABP can get called even more then twice per
| |
134 CString log; | |
135 log.Format(L"Current URL: %s, settings URL: %s", url, UserSettingsFileUrl(). c_str()); | |
136 DEBUG_GENERAL(log); | |
137 if (0 == url.CompareNoCase(CString(UserSettingsFileUrl().c_str())) || | |
138 0 == url.CompareNoCase(CString(FirstRunPageFileUrl().c_str())) ) | |
139 { | |
140 CComPtr<IDispatch> pDocDispatch; | |
141 browser->get_Document(&pDocDispatch); | |
142 CComQIPtr<IHTMLDocument2> pDoc2 = pDocDispatch; | |
143 if (pDoc2) | |
144 { | |
145 CComPtr<IHTMLWindow2> pWnd2; | |
146 pDoc2->get_parentWindow(&pWnd2); | |
147 if (pWnd2) | |
148 { | |
149 CComQIPtr<IDispatchEx> pWndEx = pWnd2; | |
150 if (pWndEx) | |
151 { | |
152 // Create "Settings" object in JavaScript. | |
153 // A method call of "Settings" in JavaScript, transfered to "Invoke" of m_pluginUserSettings | |
154 DISPID dispid; | |
155 HRESULT hr = pWndEx->GetDispID(L"Settings", fdexNameEnsure, &dispid) ; | |
156 if (SUCCEEDED(hr)) | |
157 { | |
158 CComVariant var((IDispatch*)&m_pluginUserSettings); | |
159 | |
160 DISPPARAMS params; | |
161 params.cArgs = 1; | |
162 params.cNamedArgs = 0; | |
163 params.rgvarg = &var; | |
164 params.rgdispidNamedArgs = 0; | |
165 hr = pWndEx->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATC H_PROPERTYPUT | DISPATCH_PROPERTYPUTREF, ¶ms, 0, 0, 0); | |
166 if (FAILED(hr)) | |
167 { | |
168 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_CREATE_SETTINGS_JAVASCRIPT, PLU GIN_ERROR_CREATE_SETTINGS_JAVASCRIPT_INVOKE, "CPluginTabBase::OnDocumentComplete - Failed to create Settings in JavaScript"); | |
169 } | |
170 } | |
171 } | |
172 } | |
173 } | |
174 } | |
175 } | 181 } |
176 | 182 |
177 #ifdef SUPPORT_DOM_TRAVERSER | 183 #ifdef SUPPORT_DOM_TRAVERSER |
178 if (url.Left(6) != "res://") | 184 if (url.Left(6) != "res://") |
179 { | 185 { |
180 // Get document | 186 // Get document |
181 CComPtr<IDispatch> pDocDispatch; | 187 CComPtr<IDispatch> pDocDispatch; |
182 HRESULT hr = browser->get_Document(&pDocDispatch); | 188 HRESULT hr = browser->get_Document(&pDocDispatch); |
183 if (FAILED(hr) || !pDocDispatch) | 189 if (FAILED(hr) || !pDocDispatch) |
184 { | 190 { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 | 365 |
360 // Non-hanging sleep | 366 // Non-hanging sleep |
361 Sleep(50); | 367 Sleep(50); |
362 } | 368 } |
363 | 369 |
364 tabLoopIteration++; | 370 tabLoopIteration++; |
365 } | 371 } |
366 | 372 |
367 return 0; | 373 return 0; |
368 } | 374 } |
OLD | NEW |