Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include "PluginStdAfx.h" | 18 #include "PluginStdAfx.h" |
19 | 19 |
20 #include "PluginSettings.h" | 20 #include "PluginSettings.h" |
21 #include "AdblockPlusClient.h" | 21 #include "AdblockPlusClient.h" |
22 #include "PluginSystem.h" | 22 #include "PluginSystem.h" |
23 #include "PluginMutex.h" | 23 #include "PluginMutex.h" |
24 #include "../shared/Utils.h" | 24 #include "../shared/Utils.h" |
25 | 25 |
26 namespace | 26 namespace |
27 { | 27 { |
28 std::wstring CreateDomainWhitelistingFilter(const CString& domain) | 28 std::wstring CreateDomainWhitelistingFilter(const std::wstring& domain) |
29 { | 29 { |
30 return L"@@||" + ToWstring(domain) + L"^$document"; | 30 return L"@@||" + domain + L"^$document"; |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 class CPluginSettingsWhitelistLock : public CPluginMutex | 34 class CPluginSettingsWhitelistLock : public CPluginMutex |
35 { | 35 { |
36 public: | 36 public: |
37 CPluginSettingsWhitelistLock() : CPluginMutex(L"SettingsFileWhitelist", PLUGIN _ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {} | 37 CPluginSettingsWhitelistLock() : CPluginMutex(L"SettingsFileWhitelist", PLUGIN _ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {} |
38 ~CPluginSettingsWhitelistLock() {} | 38 ~CPluginSettingsWhitelistLock() {} |
39 }; | 39 }; |
40 | 40 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 std::wstring GetDataPath(const std::wstring& filename) | 88 std::wstring GetDataPath(const std::wstring& filename) |
89 { | 89 { |
90 return GetAppDataPath() + L"\\" + filename; | 90 return GetAppDataPath() + L"\\" + filename; |
91 } | 91 } |
92 | 92 |
93 bool CPluginSettings::IsPluginEnabled() const | 93 bool CPluginSettings::IsPluginEnabled() const |
94 { | 94 { |
95 return GetPluginEnabled(); | 95 return GetPluginEnabled(); |
96 } | 96 } |
97 | 97 |
98 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() const | 98 std::map<std::wstring, std::wstring> CPluginSettings::GetFilterLanguageTitleList () const |
99 { | 99 { |
100 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc e()->FetchAvailableSubscriptions(); | 100 auto subscriptions = CPluginClient::GetInstance()->FetchAvailableSubscriptions (); |
101 | 101 |
102 std::map<CString, CString> filterList; | 102 std::map<std::wstring, std::wstring> filterList; |
103 for (size_t i = 0; i < subscriptions.size(); i ++) | 103 for (size_t i = 0; i < subscriptions.size(); i ++) |
104 { | 104 { |
105 SubscriptionDescription it = subscriptions[i]; | 105 auto it = subscriptions[i]; |
106 filterList.insert(std::make_pair(CString(it.url.c_str()), CString(it.title.c _str()))); | 106 filterList.insert(std::make_pair(it.url,it.title)); |
sergei
2015/11/25 09:27:08
the space after comma is missed
Eric
2015/11/25 17:31:02
Done.
| |
107 } | 107 } |
108 return filterList; | 108 return filterList; |
109 } | 109 } |
110 | 110 |
111 bool CPluginSettings::IsWorkingThread(DWORD dwThreadId) const | 111 bool CPluginSettings::IsWorkingThread(DWORD dwThreadId) const |
112 { | 112 { |
113 if (dwThreadId == 0) | 113 if (dwThreadId == 0) |
114 { | 114 { |
115 dwThreadId = ::GetCurrentThreadId(); | 115 dwThreadId = ::GetCurrentThreadId(); |
116 } | 116 } |
(...skipping 12 matching lines...) Expand all Loading... | |
129 | 129 |
130 void CPluginSettings::TogglePluginEnabled() | 130 void CPluginSettings::TogglePluginEnabled() |
131 { | 131 { |
132 CPluginClient::GetInstance()->TogglePluginEnabled(); | 132 CPluginClient::GetInstance()->TogglePluginEnabled(); |
133 } | 133 } |
134 bool CPluginSettings::GetPluginEnabled() const | 134 bool CPluginSettings::GetPluginEnabled() const |
135 { | 135 { |
136 return CPluginClient::GetInstance()->GetPref(L"enabled", true); | 136 return CPluginClient::GetInstance()->GetPref(L"enabled", true); |
137 } | 137 } |
138 | 138 |
139 | |
140 void CPluginSettings::AddError(const CString& error, const CString& errorCode) | 139 void CPluginSettings::AddError(const CString& error, const CString& errorCode) |
141 { | 140 { |
142 DEBUG_SETTINGS(L"SettingsTab::AddError error:" + error + " code:" + errorCode) | 141 DEBUG_SETTINGS(L"SettingsTab::AddError error:" + error + " code:" + errorCode) |
143 } | 142 } |
144 | 143 |
145 | |
146 // ============================================================================ | 144 // ============================================================================ |
147 // Whitelist settings | 145 // Whitelist settings |
148 // ============================================================================ | 146 // ============================================================================ |
149 | 147 |
150 void CPluginSettings::ClearWhitelist() | 148 void CPluginSettings::ClearWhitelist() |
151 { | 149 { |
152 s_criticalSectionLocal.Lock(); | 150 s_criticalSectionLocal.Lock(); |
153 { | 151 { |
154 m_whitelistedDomains.clear(); | 152 m_whitelistedDomains.clear(); |
155 } | 153 } |
(...skipping 21 matching lines...) Expand all Loading... | |
177 s_criticalSectionLocal.Unlock(); | 175 s_criticalSectionLocal.Unlock(); |
178 } | 176 } |
179 else | 177 else |
180 { | 178 { |
181 isRead = false; | 179 isRead = false; |
182 } | 180 } |
183 | 181 |
184 return isRead; | 182 return isRead; |
185 } | 183 } |
186 | 184 |
187 void CPluginSettings::AddWhiteListedDomain(const CString& domain) | 185 void CPluginSettings::AddWhiteListedDomain(const std::wstring& domain) |
188 { | 186 { |
189 DEBUG_SETTINGS("SettingsWhitelist::AddWhiteListedDomain domain:" + domain) | 187 DEBUG_SETTINGS("SettingsWhitelist::AddWhiteListedDomain domain:" + domain) |
190 CPluginClient::GetInstance()->AddFilter(CreateDomainWhitelistingFilter(domain) ); | 188 CPluginClient::GetInstance()->AddFilter(CreateDomainWhitelistingFilter(domain) ); |
191 } | 189 } |
192 | 190 |
193 void CPluginSettings::RemoveWhiteListedDomain(const CString& domain) | 191 void CPluginSettings::RemoveWhiteListedDomain(const std::wstring& domain) |
194 { | 192 { |
195 DEBUG_SETTINGS("SettingsWhitelist::RemoveWhiteListedDomain domain:" + domain) | 193 DEBUG_SETTINGS("SettingsWhitelist::RemoveWhiteListedDomain domain:" + domain) |
196 CPluginClient::GetInstance()->RemoveFilter(CreateDomainWhitelistingFilter(doma in)); | 194 CPluginClient::GetInstance()->RemoveFilter(CreateDomainWhitelistingFilter(doma in)); |
197 } | 195 } |
198 | 196 |
199 int CPluginSettings::GetWhiteListedDomainCount() const | 197 int CPluginSettings::GetWhiteListedDomainCount() const |
200 { | 198 { |
201 int count = 0; | 199 int count = 0; |
202 | 200 |
203 s_criticalSectionLocal.Lock(); | 201 s_criticalSectionLocal.Lock(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 | 239 |
242 return m_WindowsBuildNumber; | 240 return m_WindowsBuildNumber; |
243 } | 241 } |
244 | 242 |
245 void CPluginSettings::SetSubscription(const std::wstring& url) | 243 void CPluginSettings::SetSubscription(const std::wstring& url) |
246 { | 244 { |
247 CPluginClient::GetInstance()->SetSubscription(url); | 245 CPluginClient::GetInstance()->SetSubscription(url); |
248 RefreshWhitelist(); | 246 RefreshWhitelist(); |
249 } | 247 } |
250 | 248 |
251 CString CPluginSettings::GetSubscription() | 249 std::wstring CPluginSettings::GetSubscription() |
252 { | 250 { |
253 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc e()->GetListedSubscriptions(); | 251 auto subscriptions = CPluginClient::GetInstance()->GetListedSubscriptions(); |
254 std::wstring aaUrl = CPluginClient::GetInstance()->GetPref(L"subscriptions_exc eptionsurl", L""); | 252 std::wstring aaUrl = CPluginClient::GetInstance()->GetPref(L"subscriptions_exc eptionsurl", L""); |
255 | 253 |
256 for (std::vector<SubscriptionDescription>::iterator subscription = subscriptio ns.begin(); subscription != subscriptions.end(); subscription++) | 254 for (auto subscription = subscriptions.begin(); subscription != subscriptions. end(); subscription++) |
257 { | 255 { |
258 if (subscription->url != aaUrl) | 256 if (subscription->url != aaUrl) |
259 { | 257 { |
260 return CString(subscription->url.c_str()); | 258 return subscription->url; |
261 } | 259 } |
262 } | 260 } |
263 return CString(L""); | 261 return std::wstring(); |
264 } | 262 } |
265 | |
266 CString CPluginSettings::GetAppLocale() | |
267 { | |
268 return ToCString(GetBrowserLanguage()); | |
269 } | |
270 | |
271 CString CPluginSettings::GetDocumentationLink() | |
272 { | |
273 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str()); | |
274 } | |
OLD | NEW |