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

Unified Diff: src/plugin/PluginSettings.cpp

Issue 10948032: Fix domain-based whitelisting (Closed)
Patch Set: Created June 14, 2013, 2:44 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
Index: src/plugin/PluginSettings.cpp
===================================================================
--- a/src/plugin/PluginSettings.cpp
+++ b/src/plugin/PluginSettings.cpp
@@ -22,6 +22,14 @@
#include <knownfolders.h>
+namespace
+{
+ std::string CreateDomainWhitelistingFilter(CString domain)
+ {
+ return std::string("@@||").append(CW2A(domain)).append("^$document");
+ }
+}
+
class TSettings
{
DWORD processorId;
@@ -1270,33 +1278,27 @@
{
DEBUG_SETTINGS("SettingsWhitelist::AddWhiteListedDomain domain:" + domain)
- bool isNewVersion = false;
- bool isForcingUpdateOnStart = false;
+ RefreshWhitelist();
+ if (IsWhiteListedDomain(domain))
+ return;
Wladimir Palant 2013/06/17 09:33:56 I think that this code block is unnecessary and me
Felix Dahlke 2013/06/17 11:19:01 Done.
- CPluginSettingsWhitelistLock lock;
- if (lock.IsLocked())
- {
- ReadWhitelist(false);
-
- std::string newDomain = CW2A(domain, CP_UTF8);
-
- //Domain already present?
- if (std::find(m_whitelistedDomains.begin(), m_whitelistedDomains.end(), newDomain) != m_whitelistedDomains.end())
- {
- return;
- }
- s_criticalSectionLocal.Lock();
- CPluginClient::GetInstance()->AddFilter(std::string("@@||").append(CW2A(domain)).append("^$document"));
- s_criticalSectionLocal.Unlock();
-
- }
-
- if (isForcingUpdateOnStart)
- {
- ForceConfigurationUpdateOnStart();
- }
+ s_criticalSectionLocal.Lock();
Wladimir Palant 2013/06/17 09:33:56 Please remove the pointless critical section use h
Felix Dahlke 2013/06/17 11:19:01 Done.
+ CPluginClient::GetInstance()->AddFilter(CreateDomainWhitelistingFilter(domain));
+ s_criticalSectionLocal.Unlock();
}
+void CPluginSettings::RemoveWhiteListedDomain(const CString& domain)
+{
+ DEBUG_SETTINGS("SettingsWhitelist::RemoveWhiteListedDomain domain:" + domain)
+
+ RefreshWhitelist();
+ if (!IsWhiteListedDomain(domain))
+ return;
Wladimir Palant 2013/06/17 09:33:56 I think that this code block is unnecessary and me
Felix Dahlke 2013/06/17 11:19:01 Done.
+
+ s_criticalSectionLocal.Lock();
Wladimir Palant 2013/06/17 09:33:56 Please remove the pointless critical section use h
Felix Dahlke 2013/06/17 11:19:01 Done.
+ CPluginClient::GetInstance()->RemoveFilter(CreateDomainWhitelistingFilter(domain));
+ s_criticalSectionLocal.Unlock();
+}
bool CPluginSettings::IsWhiteListedDomain(const CString& domain) const
{

Powered by Google App Engine
This is Rietveld