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

Side by Side Diff: src/FilterEngine.cpp

Issue 10011043: Move ABP JS code loading to FilterEngine and make it optional (Closed)
Patch Set: Created April 2, 2013, 10:32 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
« no previous file with comments | « libadblockplus.gyp ('k') | src/JsEngine.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 <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 2
3 using namespace AdblockPlus; 3 using namespace AdblockPlus;
4 4
5 #if !FILTER_ENGINE_STUBS
6 extern const char* jsSources[];
7 #endif
8
5 Subscription::Subscription(const std::string& url, const std::string& title) 9 Subscription::Subscription(const std::string& url, const std::string& title)
6 : url(url), title(title) 10 : url(url), title(title)
7 { 11 {
8 } 12 }
9 13
10 FilterEngine::FilterEngine(JsEngine& jsEngine) : jsEngine(jsEngine) 14 FilterEngine::FilterEngine(JsEngine& jsEngine) : jsEngine(jsEngine)
11 { 15 {
12 // TODO: Load ABP: 16 #if !FILTER_ENGINE_STUBS
13 // jsEngine.Load("adblockplus_compat.js"); 17 for (int i = 0; jsSources[i] && jsSources[i + 1]; i += 2)
14 // jsEngine.Load("adblockplus.js"); 18 jsEngine.Evaluate(jsSources[i + 1], jsSources[i]);
19 #endif
15 } 20 }
16 21
17 void FilterEngine::AddSubscription(Subscription subscription) 22 void FilterEngine::AddSubscription(Subscription subscription)
18 { 23 {
19 subscriptions.push_back(subscription); 24 subscriptions.push_back(subscription);
20 } 25 }
21 26
22 void FilterEngine::RemoveSubscription(const Subscription& subscription) 27 void FilterEngine::RemoveSubscription(const Subscription& subscription)
23 { 28 {
24 for (std::vector<Subscription>::iterator it = subscriptions.begin(); 29 for (std::vector<Subscription>::iterator it = subscriptions.begin();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return subscriptions.size() && url.length() % 2; 66 return subscriptions.size() && url.length() % 2;
62 } 67 }
63 68
64 std::vector<std::string> FilterEngine::GetElementHidingRules() const 69 std::vector<std::string> FilterEngine::GetElementHidingRules() const
65 { 70 {
66 std::vector<std::string> hidingRules; 71 std::vector<std::string> hidingRules;
67 hidingRules.push_back("###ad"); 72 hidingRules.push_back("###ad");
68 hidingRules.push_back("##.ad"); 73 hidingRules.push_back("##.ad");
69 return hidingRules; 74 return hidingRules;
70 } 75 }
OLDNEW
« no previous file with comments | « libadblockplus.gyp ('k') | src/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld