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

Side by Side Diff: src/plugin/PluginSettings.cpp

Issue 10948032: Fix domain-based whitelisting (Closed)
Patch Set: Created June 17, 2013, 1:50 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/plugin/PluginSettings.h ('k') | src/plugin/PluginTabBase.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 2
3 #include <Wbemidl.h> 3 #include <Wbemidl.h>
4 #include <time.h> 4 #include <time.h>
5 #include "PluginIniFileW.h" 5 #include "PluginIniFileW.h"
6 #include "PluginIniFile.h" 6 #include "PluginIniFile.h"
7 #include "PluginSettings.h" 7 #include "PluginSettings.h"
8 #include "PluginClient.h" 8 #include "PluginClient.h"
9 #include "PluginChecksum.h" 9 #include "PluginChecksum.h"
10 #include "PluginSystem.h" 10 #include "PluginSystem.h"
11 #ifdef SUPPORT_FILTER 11 #ifdef SUPPORT_FILTER
12 #include "PluginFilter.h" 12 #include "PluginFilter.h"
13 #endif 13 #endif
14 #include "PluginMutex.h" 14 #include "PluginMutex.h"
15 #include "PluginHttpRequest.h" 15 #include "PluginHttpRequest.h"
16 #include "../shared/Utils.h" 16 #include "../shared/Utils.h"
17 #include <memory> 17 #include <memory>
18 18
19 19
20 // IE functions 20 // IE functions
21 #pragma comment(lib, "iepmapi.lib") 21 #pragma comment(lib, "iepmapi.lib")
22 22
23 #include <knownfolders.h> 23 #include <knownfolders.h>
24 24
25 namespace
26 {
27 std::string CreateDomainWhitelistingFilter(CString domain)
28 {
29 return std::string("@@||").append(CW2A(domain)).append("^$document");
30 }
31 }
32
25 class TSettings 33 class TSettings
26 { 34 {
27 DWORD processorId; 35 DWORD processorId;
28 36
29 char sPluginId[44]; 37 char sPluginId[44];
30 }; 38 };
31 39
32 40
33 class CPluginSettingsLock : public CPluginMutex 41 class CPluginSettingsLock : public CPluginMutex
34 { 42 {
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 isRead = false; 1270 isRead = false;
1263 } 1271 }
1264 1272
1265 return isRead; 1273 return isRead;
1266 } 1274 }
1267 1275
1268 1276
1269 void CPluginSettings::AddWhiteListedDomain(const CString& domain) 1277 void CPluginSettings::AddWhiteListedDomain(const CString& domain)
1270 { 1278 {
1271 DEBUG_SETTINGS("SettingsWhitelist::AddWhiteListedDomain domain:" + domain) 1279 DEBUG_SETTINGS("SettingsWhitelist::AddWhiteListedDomain domain:" + domain)
1272 1280 CPluginClient::GetInstance()->AddFilter(CreateDomainWhitelistingFilter(domain) );
1273 bool isNewVersion = false;
1274 bool isForcingUpdateOnStart = false;
1275
1276 CPluginSettingsWhitelistLock lock;
1277 if (lock.IsLocked())
1278 {
1279 ReadWhitelist(false);
1280
1281 std::string newDomain = CW2A(domain, CP_UTF8);
1282
1283 //Domain already present?
1284 if (std::find(m_whitelistedDomains.begin(), m_whitelistedDomains.end(), newD omain) != m_whitelistedDomains.end())
1285 {
1286 return;
1287 }
1288 s_criticalSectionLocal.Lock();
1289 CPluginClient::GetInstance()->AddFilter(std::string("@@||").append(CW2A(doma in)).append("^$document"));
1290 s_criticalSectionLocal.Unlock();
1291
1292 }
1293
1294 if (isForcingUpdateOnStart)
1295 {
1296 ForceConfigurationUpdateOnStart();
1297 }
1298 } 1281 }
1299 1282
1283 void CPluginSettings::RemoveWhiteListedDomain(const CString& domain)
1284 {
1285 DEBUG_SETTINGS("SettingsWhitelist::RemoveWhiteListedDomain domain:" + domain)
1286 CPluginClient::GetInstance()->RemoveFilter(CreateDomainWhitelistingFilter(doma in));
1287 }
1300 1288
1301 bool CPluginSettings::IsWhiteListedDomain(const CString& domain) const 1289 bool CPluginSettings::IsWhiteListedDomain(const CString& domain) const
1302 { 1290 {
1303 bool bIsWhiteListed; 1291 bool bIsWhiteListed;
1304 1292
1305 s_criticalSectionLocal.Lock(); 1293 s_criticalSectionLocal.Lock();
1306 { 1294 {
1307 bIsWhiteListed = std::find(m_whitelistedDomains.begin(), m_whitelistedDomain s.end(), std::string(CW2A(domain, CP_UTF8))) != m_whitelistedDomains.end(); 1295 bIsWhiteListed = std::find(m_whitelistedDomains.begin(), m_whitelistedDomain s.end(), std::string(CW2A(domain, CP_UTF8))) != m_whitelistedDomains.end();
1308 } 1296 }
1309 s_criticalSectionLocal.Unlock(); 1297 s_criticalSectionLocal.Unlock();
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 return CString(L""); 1384 return CString(L"");
1397 } 1385 }
1398 1386
1399 1387
1400 void CPluginSettings::RefreshFilterlist() 1388 void CPluginSettings::RefreshFilterlist()
1401 { 1389 {
1402 CPluginClient::GetInstance()->UpdateAllSubscriptions(); 1390 CPluginClient::GetInstance()->UpdateAllSubscriptions();
1403 } 1391 }
1404 1392
1405 #endif // SUPPORT_WHITELIST 1393 #endif // SUPPORT_WHITELIST
OLDNEW
« no previous file with comments | « src/plugin/PluginSettings.h ('k') | src/plugin/PluginTabBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld