OLD | NEW |
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 // Internet / FTP | 3 // Internet / FTP |
4 #include <wininet.h> | 4 #include <wininet.h> |
5 | 5 |
6 // IP adapter | 6 // IP adapter |
7 #include <iphlpapi.h> | 7 #include <iphlpapi.h> |
8 | 8 |
9 #include "PluginSettings.h" | 9 #include "PluginSettings.h" |
10 #include "PluginSystem.h" | 10 #include "PluginSystem.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 return hasError; | 160 return hasError; |
161 } | 161 } |
162 | 162 |
163 // ============================================================================ | 163 // ============================================================================ |
164 // Whitelisting | 164 // Whitelisting |
165 // ============================================================================ | 165 // ============================================================================ |
166 | 166 |
167 #ifdef SUPPORT_WHITELIST | 167 #ifdef SUPPORT_WHITELIST |
168 | 168 |
169 void CPluginClientBase::CacheWhiteListedUrl(const CString& url, bool isWhitelist
ed) | |
170 { | |
171 m_criticalSectionWhitelist.Lock(); | |
172 { | |
173 m_cacheWhitelistedUrls[url] = isWhitelisted; | |
174 } | |
175 m_criticalSectionWhitelist.Unlock(); | |
176 } | |
177 | |
178 bool CPluginClientBase::IsUrlWhiteListed(const CString& url) | 169 bool CPluginClientBase::IsUrlWhiteListed(const CString& url) |
179 { | 170 { |
180 if (url.IsEmpty()) | 171 if (url.IsEmpty()) |
181 { | 172 { |
182 return false; | 173 return false; |
183 } | 174 } |
184 | 175 |
185 bool isWhitelisted = false; | 176 int pos = 0; |
186 bool isCached = false; | 177 CString scheme = url.Find('/',pos) >= 0 ? url.Tokenize(L"/", pos) : L""; |
187 | 178 CString domain = ExtractDomain(url); |
188 m_criticalSectionWhitelist.Lock(); | 179 if (scheme == L"res:" || scheme == L"file:") |
189 { | 180 { |
190 std::map<CString,bool>::iterator it = m_cacheWhitelistedUrls.find(url); | 181 return true; |
191 | |
192 isCached = it != m_cacheWhitelistedUrls.end(); | |
193 if (isCached) | |
194 { | |
195 isWhitelisted = it->second; | |
196 } | |
197 } | |
198 m_criticalSectionWhitelist.Unlock(); | |
199 | |
200 if (!isCached) | |
201 { | |
202 int pos = 0; | |
203 CString http = url.Find('/',pos) >= 0 ? url.Tokenize(L"/", pos) : L""; | |
204 CString domain = ExtractDomain(url); | |
205 if (http == L"res:" || http == L"file:") | |
206 { | |
207 isWhitelisted = true; | |
208 } | |
209 else | |
210 { | |
211 isWhitelisted = CPluginSettings::GetInstance()->IsWhiteListedDomain(domain
); | |
212 } | |
213 | |
214 CacheWhiteListedUrl(url, isWhitelisted); | |
215 } | 182 } |
216 | 183 |
217 return isWhitelisted; | 184 // TODO: Caching whitelist entries in PluginSettings is redundant and wasteful
. We should have an engine call for IsWhitelistedDomain. |
| 185 CPluginSettings* pluginSettings = CPluginSettings::GetInstance(); |
| 186 pluginSettings->RefreshWhitelist(); |
| 187 return pluginSettings->IsWhiteListedDomain(domain); |
218 } | 188 } |
219 | 189 |
220 void CPluginClientBase::ClearWhiteListCache() | |
221 { | |
222 m_criticalSectionWhitelist.Lock(); | |
223 { | |
224 m_cacheWhitelistedUrls.clear(); | |
225 } | |
226 m_criticalSectionWhitelist.Unlock(); | |
227 } | |
228 | |
229 | |
230 #endif // SUPPORT_WHITELIST | 190 #endif // SUPPORT_WHITELIST |
OLD | NEW |