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

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

Issue 5427527162003456: Issue 1086 - Add acceptable ads checkbox to the settings page (Closed)
Patch Set: Moved from onchange in html to addListener in JS Created July 22, 2014, 2:22 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
« html/static/js/IESettings.js ('K') | « src/plugin/PluginClass.cpp ('k') | no next file » | 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 #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 "../shared/Dictionary.h" 6 #include "../shared/Dictionary.h"
7 7
8 static const CString s_GetMessage = L"GetMessage"; 8 static const CString s_GetMessage = L"GetMessage";
9 static const CString s_GetLanguageCount = L"GetLanguageCount"; 9 static const CString s_GetLanguageCount = L"GetLanguageCount";
10 static const CString s_GetLanguageByIndex = L"GetLanguageByIndex"; 10 static const CString s_GetLanguageByIndex = L"GetLanguageByIndex";
11 static const CString s_GetLanguageTitleByIndex = L"GetLanguageTitleByIndex"; 11 static const CString s_GetLanguageTitleByIndex = L"GetLanguageTitleByIndex";
12 static const CString s_SetLanguage = L"SetLanguage"; 12 static const CString s_SetLanguage = L"SetLanguage";
13 static const CString s_GetLanguage = L"GetLanguage"; 13 static const CString s_GetLanguage = L"GetLanguage";
14 static const CString s_GetWhitelistDomains = L"GetWhitelistDomains"; 14 static const CString s_GetWhitelistDomains = L"GetWhitelistDomains";
15 static const CString s_AddWhitelistDomain = L"AddWhitelistDomain"; 15 static const CString s_AddWhitelistDomain = L"AddWhitelistDomain";
16 static const CString s_RemoveWhitelistDomain = L"RemoveWhitelistDomain"; 16 static const CString s_RemoveWhitelistDomain = L"RemoveWhitelistDomain";
17 static const CString s_GetAppLocale = L"GetAppLocale"; 17 static const CString s_GetAppLocale = L"GetAppLocale";
18 static const CString s_GetDocumentationLink = L"GetDocumentationLink"; 18 static const CString s_GetDocumentationLink = L"GetDocumentationLink";
19 19 static const CString s_IsAcceptableAdsEnabled = L"IsAcceptableAdsEnabled";
20 static const CString s_Methods[] = {s_GetMessage, s_GetLanguageCount, s_GetLangu ageByIndex, s_GetLanguageTitleByIndex, s_SetLanguage, s_GetLanguage, s_GetWhitel istDomains, s_AddWhitelistDomain, s_RemoveWhitelistDomain, s_GetAppLocale, s_Get DocumentationLink}; 20 static const CString s_SetAcceptableAdsEnabled = L"SetAcceptableAdsEnabled";
21 static const CString s_Methods[] = {s_GetMessage, s_GetLanguageCount, s_GetLangu ageByIndex, s_GetLanguageTitleByIndex, s_SetLanguage, s_GetLanguage, s_GetWhitel istDomains, s_AddWhitelistDomain, s_RemoveWhitelistDomain, s_GetAppLocale, s_Get DocumentationLink, s_IsAcceptableAdsEnabled, s_SetAcceptableAdsEnabled};
21 22
22 CPluginUserSettings::CPluginUserSettings() 23 CPluginUserSettings::CPluginUserSettings()
23 { 24 {
24 } 25 }
25 26
26 27
27 STDMETHODIMP CPluginUserSettings::QueryInterface(REFIID riid, void **ppvObj) 28 STDMETHODIMP CPluginUserSettings::QueryInterface(REFIID riid, void **ppvObj)
28 { 29 {
29 if (IID_IUnknown == riid || IID_IDispatch == riid) 30 if (IID_IUnknown == riid || IID_IDispatch == riid)
30 { 31 {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 pVarResult->bstrVal = SysAllocString(settings->GetAppLocale()); 317 pVarResult->bstrVal = SysAllocString(settings->GetAppLocale());
317 } 318 }
318 else if (s_GetDocumentationLink == method) 319 else if (s_GetDocumentationLink == method)
319 { 320 {
320 if (0 != pDispparams->cArgs) 321 if (0 != pDispparams->cArgs)
321 return DISP_E_BADPARAMCOUNT; 322 return DISP_E_BADPARAMCOUNT;
322 323
323 pVarResult->vt = VT_BSTR; 324 pVarResult->vt = VT_BSTR;
324 pVarResult->bstrVal = SysAllocString(settings->GetDocumentationLink()); 325 pVarResult->bstrVal = SysAllocString(settings->GetDocumentationLink());
325 } 326 }
327 else if (s_IsAcceptableAdsEnabled == method)
328 {
329 if (0 != pDispparams->cArgs)
330 return DISP_E_BADPARAMCOUNT;
331
332 pVarResult->vt = VT_BOOL;
333 pVarResult->boolVal = CPluginClient::GetInstance()->IsAcceptableAdsEnabled() ;
334 }
335 else if (s_SetAcceptableAdsEnabled == method)
336 {
337 if (1 != pDispparams->cArgs)
338 return DISP_E_BADPARAMCOUNT;
339
340 if (VT_BOOL != pDispparams->rgvarg[0].vt)
341 return DISP_E_TYPEMISMATCH;
342
343 bool enable = pDispparams->rgvarg[0].boolVal;
344
345 if (enable)
346 {
347 CPluginClient* client = CPluginClient::GetInstance();
348 client->AddSubscription(client->GetPref(L"subscriptions_exceptionsurl", L" "));
349 }
350 else
351 {
352 CPluginClient* client = CPluginClient::GetInstance();
353 client->RemoveSubscription(client->GetPref(L"subscriptions_exceptionsurl", L""));
354 }
355 }
326 else 356 else
327 return DISP_E_MEMBERNOTFOUND; 357 return DISP_E_MEMBERNOTFOUND;
328 358
329 return S_OK; 359 return S_OK;
330 } 360 }
331 361
OLDNEW
« html/static/js/IESettings.js ('K') | « src/plugin/PluginClass.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld