Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginClientBase.cpp

Issue 10948032: Fix domain-based whitelisting (Closed)
Patch Set: Created June 17, 2013, 1:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/PluginClientBase.h ('k') | src/plugin/PluginSettings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/PluginClientBase.cpp
===================================================================
--- a/src/plugin/PluginClientBase.cpp
+++ b/src/plugin/PluginClientBase.cpp
@@ -166,15 +166,6 @@
#ifdef SUPPORT_WHITELIST
-void CPluginClientBase::CacheWhiteListedUrl(const CString& url, bool isWhitelisted)
-{
- m_criticalSectionWhitelist.Lock();
- {
- m_cacheWhitelistedUrls[url] = isWhitelisted;
- }
- m_criticalSectionWhitelist.Unlock();
-}
-
bool CPluginClientBase::IsUrlWhiteListed(const CString& url)
{
if (url.IsEmpty())
@@ -182,49 +173,18 @@
return false;
}
- bool isWhitelisted = false;
- bool isCached = false;
-
- m_criticalSectionWhitelist.Lock();
+ int pos = 0;
+ CString scheme = url.Find('/',pos) >= 0 ? url.Tokenize(L"/", pos) : L"";
+ CString domain = ExtractDomain(url);
+ if (scheme == L"res:" || scheme == L"file:")
{
- std::map<CString,bool>::iterator it = m_cacheWhitelistedUrls.find(url);
-
- isCached = it != m_cacheWhitelistedUrls.end();
- if (isCached)
- {
- isWhitelisted = it->second;
- }
- }
- m_criticalSectionWhitelist.Unlock();
-
- if (!isCached)
- {
- int pos = 0;
- CString http = url.Find('/',pos) >= 0 ? url.Tokenize(L"/", pos) : L"";
- CString domain = ExtractDomain(url);
- if (http == L"res:" || http == L"file:")
- {
- isWhitelisted = true;
- }
- else
- {
- isWhitelisted = CPluginSettings::GetInstance()->IsWhiteListedDomain(domain);
- }
-
- CacheWhiteListedUrl(url, isWhitelisted);
+ return true;
}
- return isWhitelisted;
+ // TODO: Caching whitelist entries in PluginSettings is redundant and wasteful. We should have an engine call for IsWhitelistedDomain.
+ CPluginSettings* pluginSettings = CPluginSettings::GetInstance();
+ pluginSettings->RefreshWhitelist();
+ return pluginSettings->IsWhiteListedDomain(domain);
}
-void CPluginClientBase::ClearWhiteListCache()
-{
- m_criticalSectionWhitelist.Lock();
- {
- m_cacheWhitelistedUrls.clear();
- }
- m_criticalSectionWhitelist.Unlock();
-}
-
-
#endif // SUPPORT_WHITELIST
« no previous file with comments | « src/plugin/PluginClientBase.h ('k') | src/plugin/PluginSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld