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

Side by Side Diff: src/plugin/AdblockPlusClient.h

Issue 11013110: Cleanup (Closed)
Patch Set: SetPref/GetPref type safety. Comments addressed. Created July 22, 2013, 12:42 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #ifndef _ADBLOCK_PLUS_CLIENT_H_ 1 #ifndef _ADBLOCK_PLUS_CLIENT_H_
2 #define _ADBLOCK_PLUS_CLIENT_H_ 2 #define _ADBLOCK_PLUS_CLIENT_H_
3 3
4 4
5 #include "PluginTypedef.h" 5 #include "PluginTypedef.h"
6 #include "PluginClientBase.h" 6 #include "PluginClientBase.h"
7 #include "../shared/Communication.h"
7 8
8 9
9 class CPluginFilter; 10 class CPluginFilter;
10 11
11 struct SubscriptionDescription 12 struct SubscriptionDescription
12 { 13 {
13 std::wstring url; 14 std::wstring url;
14 std::wstring title; 15 std::wstring title;
15 std::wstring specialization; 16 std::wstring specialization;
16 bool listed; 17 bool listed;
17 }; 18 };
18 19
19 class CAdblockPlusClient : public CPluginClientBase 20 class CAdblockPlusClient : public CPluginClientBase
20 { 21 {
21 22
22 private: 23 private:
23 24
24 std::auto_ptr<CPluginFilter> m_filter; 25 std::auto_ptr<CPluginFilter> m_filter;
25 26
26 CComAutoCriticalSection m_criticalSectionFilter; 27 CComAutoCriticalSection m_criticalSectionFilter;
27 CComAutoCriticalSection m_criticalSectionCache; 28 CComAutoCriticalSection m_criticalSectionCache;
28 29
29 std::map<CString,bool> m_cacheBlockedSources; 30 std::map<CString,bool> m_cacheBlockedSources;
30 31
31 32
32 // Private constructor used by the singleton pattern 33 // Private constructor used by the singleton pattern
33 CAdblockPlusClient(); 34 CAdblockPlusClient();
34 35
36 void PostRequest(Communication::OutputBuffer request);
37 Communication::InputBuffer FetchResponse(const std::wstring& name);
38
35 public: 39 public:
36 40
37 static CAdblockPlusClient* s_instance; 41 static CAdblockPlusClient* s_instance;
38 42
39 ~CAdblockPlusClient(); 43 ~CAdblockPlusClient();
40 44
41 static CAdblockPlusClient* GetInstance(); 45 static CAdblockPlusClient* GetInstance();
42 46
43 // Removes the url from the list of whitelisted urls if present 47 // Removes the url from the list of whitelisted urls if present
44 // Only called from ui thread 48 // Only called from ui thread
45 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add Debug=false); 49 bool ShouldBlock(CString src, int contentType, const CString& domain, bool add Debug=false);
46 50
47 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom ain, const CString& indent, CPluginFilter* filter); 51 bool IsElementHidden(const CString& tag, IHTMLElement* pEl, const CString& dom ain, const CString& indent, CPluginFilter* filter);
48 bool IsWhitelistedUrl(const std::wstring& url); 52 bool IsWhitelistedUrl(const std::wstring& url);
49 53
50 int GetIEVersion(); 54 int GetIEVersion();
51 55
52 bool Matches(const std::wstring& url, const std::wstring& contentType, const s td::wstring& domain); 56 bool Matches(const std::wstring& url, const std::wstring& contentType, const s td::wstring& domain);
53 std::vector<std::wstring> GetElementHidingSelectors(const std::wstring& domain ); 57 std::vector<std::wstring> GetElementHidingSelectors(const std::wstring& domain );
54 std::vector<SubscriptionDescription> FetchAvailableSubscriptions(); 58 std::vector<SubscriptionDescription> FetchAvailableSubscriptions();
55 std::vector<SubscriptionDescription> GetListedSubscriptions(); 59 std::vector<SubscriptionDescription> GetListedSubscriptions();
56 void SetSubscription(const std::wstring& url); 60 void SetSubscription(const std::wstring& url);
57 void UpdateAllSubscriptions(); 61 void UpdateAllSubscriptions();
58 std::vector<std::wstring> GetExceptionDomains(); 62 std::vector<std::wstring> GetExceptionDomains();
59 void AddFilter(const std::wstring& text); 63 void AddFilter(const std::wstring& text);
60 void RemoveFilter(const std::wstring& text); 64 void RemoveFilter(const std::wstring& text);
61 void SetPref(const std::wstring& name, const std::wstring& value); 65 void SetPref(const std::wstring& name, const std::wstring& value);
62 std::wstring GetPref(const std::wstring& name); 66 void SetPref(const std::string& name, const std::string& value);
67 void SetPref(const std::wstring& name, const int64_t& value);
68 void SetPref(const std::wstring& name, bool value);
69 std::wstring GetPref(const std::wstring& name, const std::wstring& defaultValu e = L"");
70 std::wstring GetPref(const std::wstring& name, LPCWSTR defaultValue);
71 bool GetPref(const std::wstring& name, bool defaultValue = false);
72 int64_t GetPref(const std::wstring& name, int64_t defaultValue = 0);
63 }; 73 };
64 74
65 #endif // _ADBLOCK_PLUS_CLIENT_H_ 75 #endif // _ADBLOCK_PLUS_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld