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

Side by Side Diff: src/engine/Main.cpp

Issue 5338025085108224: Support Acceptable Ads (Closed)
Patch Set: Created April 14, 2014, 7:01 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 #include <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 #include <functional> 2 #include <functional>
3 #include <vector> 3 #include <vector>
4 #include <Windows.h> 4 #include <Windows.h>
5 5
6 #include "../shared/AutoHandle.h" 6 #include "../shared/AutoHandle.h"
7 #include "../shared/Communication.h" 7 #include "../shared/Communication.h"
8 #include "../shared/Dictionary.h" 8 #include "../shared/Dictionary.h"
9 #include "../shared/Utils.h" 9 #include "../shared/Utils.h"
10 #include "../shared/Version.h" 10 #include "../shared/Version.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 case Communication::PROC_LISTED_SUBSCRIPTIONS: 107 case Communication::PROC_LISTED_SUBSCRIPTIONS:
108 { 108 {
109 WriteSubscriptions(response, filterEngine->GetListedSubscriptions()); 109 WriteSubscriptions(response, filterEngine->GetListedSubscriptions());
110 break; 110 break;
111 } 111 }
112 case Communication::PROC_SET_SUBSCRIPTION: 112 case Communication::PROC_SET_SUBSCRIPTION:
113 { 113 {
114 std::string url; 114 std::string url;
115 request >> url; 115 request >> url;
116 116
117 AdblockPlus::JsValuePtr valuePtr = filterEngine->GetPref("subscriptions_ exceptionsurl");
118 std::string aaUrl = "";
119 if (valuePtr->IsString())
120 {
121 aaUrl = valuePtr->AsString();
122 }
Eric 2014/06/25 14:34:15 Why the partial type enforcement? Is there any rea
Felix Dahlke 2014/06/30 17:24:04 I guess this is because the pref could be missing,
117 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = filterEngine-> GetListedSubscriptions(); 123 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = filterEngine-> GetListedSubscriptions();
124
125 // Remove all subscriptions, besides the Acceptable Ads
Felix Dahlke 2014/06/30 17:24:04 Wow, this is hacky. So we currently only support e
Oleksandr 2014/07/18 19:06:42 https://issues.adblockplus.org/ticket/1084 On 2014
118 for (size_t i = 0, count = subscriptions.size(); i < count; i++) 126 for (size_t i = 0, count = subscriptions.size(); i < count; i++)
119 subscriptions[i]->RemoveFromList(); 127 {
128 if (subscriptions[i].get()->GetProperty("url")->AsString() != aaUrl)
Felix Dahlke 2014/06/30 17:24:04 Are you sure the .get() is required here? That sho
129 {
130 subscriptions[i]->RemoveFromList();
131 }
132 }
133
134 // Add new subscription
Felix Dahlke 2014/06/30 17:24:04 Kinda obvious IMHO :P
135 filterEngine->GetSubscription(url)->AddToList();
136 break;
137 }
138 case Communication::PROC_ADD_SUBSCRIPTION:
139 {
140 std::string url;
141 request >> url;
120 142
121 filterEngine->GetSubscription(url)->AddToList(); 143 filterEngine->GetSubscription(url)->AddToList();
122 break; 144 break;
123 } 145 }
146 case Communication::PROC_REMOVE_SUBSCRIPTION:
147 {
148 std::string url;
149 request >> url;
150
151 filterEngine->GetSubscription(url)->RemoveFromList();
152 break;
153 }
124 case Communication::PROC_UPDATE_ALL_SUBSCRIPTIONS: 154 case Communication::PROC_UPDATE_ALL_SUBSCRIPTIONS:
125 { 155 {
126 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = filterEngine-> GetListedSubscriptions(); 156 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = filterEngine-> GetListedSubscriptions();
127 for (size_t i = 0, count = subscriptions.size(); i < count; i++) 157 for (size_t i = 0, count = subscriptions.size(); i < count; i++)
128 subscriptions[i]->UpdateFilters(); 158 subscriptions[i]->UpdateFilters();
129 break; 159 break;
130 } 160 }
131 case Communication::PROC_GET_EXCEPTION_DOMAINS: 161 case Communication::PROC_GET_EXCEPTION_DOMAINS:
132 { 162 {
133 std::vector<AdblockPlus::FilterPtr> filters = filterEngine->GetListedFil ters(); 163 std::vector<AdblockPlus::FilterPtr> filters = filterEngine->GetListedFil ters();
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 448 }
419 catch (std::runtime_error e) 449 catch (std::runtime_error e)
420 { 450 {
421 DebugException(e); 451 DebugException(e);
422 return 1; 452 return 1;
423 } 453 }
424 } 454 }
425 455
426 return 0; 456 return 0;
427 } 457 }
OLDNEW

Powered by Google App Engine
This is Rietveld