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

Delta Between Two Patch Sets: Shared/PluginUserSettings.cpp

Issue 9998007: Initial libadblockplus integration (Closed)
Left Patch Set: More integration, reflecting latest libadblockplus changes Created April 9, 2013, 5:48 a.m.
Right Patch Set: Whitelisting management Created April 11, 2013, 9:06 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Shared/PluginTypedef.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #include "PluginStdAfx.h" 1 #include "PluginStdAfx.h"
2 #include "PluginUserSettings.h" 2 #include "PluginUserSettings.h"
3 #include <algorithm> 3 #include <algorithm>
4 #include "PluginSettings.h" 4 #include "PluginSettings.h"
5 #include "PluginClient.h" 5 #include "PluginClient.h"
6 #include "PluginIniFileW.h" 6 #include "PluginIniFileW.h"
7 #include "PluginDictionary.h" 7 #include "PluginDictionary.h"
8 8
9 static const CString s_GetMessage = L"GetMessage"; 9 static const CString s_GetMessage = L"GetMessage";
10 static const CString s_GetLanguageCount = L"GetLanguageCount"; 10 static const CString s_GetLanguageCount = L"GetLanguageCount";
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 pVarResult->bstrVal = SysAllocString(url); 269 pVarResult->bstrVal = SysAllocString(url);
270 } 270 }
271 } 271 }
272 else if (s_GetWhitelistDomains == method) 272 else if (s_GetWhitelistDomains == method)
273 { 273 {
274 if (pDispparams->cArgs) 274 if (pDispparams->cArgs)
275 return DISP_E_BADPARAMCOUNT; 275 return DISP_E_BADPARAMCOUNT;
276 276
277 if (pVarResult) 277 if (pVarResult)
278 { 278 {
279 //TODO: How and where is this stored? 279 std::vector<std::string> whiteList = settings->GetWhiteListedDomainList(tr ue);
280 TDomainList whiteList = settings->GetWhiteListedDomainList(true);
281 CString sWhiteList; 280 CString sWhiteList;
282 for (TDomainList::const_iterator it = whiteList.begin(); it != whiteList.e nd(); ++it) 281 for (int i = 0; i < whiteList.size(); i++)
283 { 282 {
284 if (!sWhiteList.IsEmpty()) 283 if (!sWhiteList.IsEmpty())
285 { 284 {
286 sWhiteList += ','; 285 sWhiteList += ',';
287 } 286 }
288 sWhiteList += it->first; 287 sWhiteList += CString(CA2W(whiteList[i].c_str(), CP_UTF8));
289 } 288 }
290 289
291 pVarResult->vt = VT_BSTR; 290 pVarResult->vt = VT_BSTR;
292 pVarResult->bstrVal = SysAllocString(sWhiteList); 291 pVarResult->bstrVal = SysAllocString(sWhiteList);
293 } 292 }
294 } 293 }
295 else if (s_AddWhitelistDomain == method) 294 else if (s_AddWhitelistDomain == method)
296 { 295 {
297 if (1 != pDispparams->cArgs) 296 if (1 != pDispparams->cArgs)
298 return DISP_E_BADPARAMCOUNT; 297 return DISP_E_BADPARAMCOUNT;
299 298
300 if (VT_BSTR != pDispparams->rgvarg[0].vt) 299 if (VT_BSTR != pDispparams->rgvarg[0].vt)
301 return DISP_E_TYPEMISMATCH; 300 return DISP_E_TYPEMISMATCH;
302 301
303 CComBSTR domain = pDispparams->rgvarg[0].bstrVal; 302 CComBSTR domain = pDispparams->rgvarg[0].bstrVal;
304 if (domain.Length()) 303 if (domain.Length())
305 { 304 {
306 if (!settings->IsWhiteListedDomain((BSTR)domain)) 305 settings->AddWhiteListedDomain((BSTR)domain);
307 {
308 settings->AddWhiteListedDomain((BSTR)domain, 1, true);
309 }
310 } 306 }
311 } 307 }
312 else if (s_RemoveWhitelistDomain == method) 308 else if (s_RemoveWhitelistDomain == method)
313 { 309 {
314 if (1 != pDispparams->cArgs) 310 if (1 != pDispparams->cArgs)
315 return DISP_E_BADPARAMCOUNT; 311 return DISP_E_BADPARAMCOUNT;
316 312
317 if (VT_BSTR != pDispparams->rgvarg[0].vt) 313 if (VT_BSTR != pDispparams->rgvarg[0].vt)
318 return DISP_E_TYPEMISMATCH; 314 return DISP_E_TYPEMISMATCH;
319 315
320 CComBSTR domain = pDispparams->rgvarg[0].bstrVal; 316 CComBSTR domain = pDispparams->rgvarg[0].bstrVal;
321 if (settings->IsWhiteListedDomain((BSTR)domain)) 317 if (settings->IsWhiteListedDomain((BSTR)domain))
322 { 318 {
323 settings->AddWhiteListedDomain((BSTR)domain, 3, true); 319 settings->AddWhiteListedDomain((BSTR)domain);
324 CPluginClient::GetInstance()->ClearWhiteListCache(); 320 CPluginClient::GetInstance()->ClearWhiteListCache();
325 } 321 }
326 } 322 }
327 else 323 else
328 return DISP_E_MEMBERNOTFOUND; 324 return DISP_E_MEMBERNOTFOUND;
329 325
330 return S_OK; 326 return S_OK;
331 } 327 }
332 328
LEFTRIGHT

Powered by Google App Engine
This is Rietveld