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

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

Issue 11369200: Disable everywhere fix (Closed)
Patch Set: Created Aug. 13, 2013, 2:18 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
« no previous file with comments | « src/plugin/PluginSettings.h ('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 2
3 #include <Wbemidl.h> 3 #include <Wbemidl.h>
4 #include <time.h> 4 #include <time.h>
5 #include "PluginSettings.h" 5 #include "PluginSettings.h"
6 #include "PluginClient.h" 6 #include "PluginClient.h"
7 #include "PluginSystem.h" 7 #include "PluginSystem.h"
8 #ifdef SUPPORT_FILTER 8 #ifdef SUPPORT_FILTER
9 #include "PluginFilter.h" 9 #include "PluginFilter.h"
10 #endif 10 #endif
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 ~CPluginSettingsWhitelistLock() {} 59 ~CPluginSettingsWhitelistLock() {}
60 }; 60 };
61 61
62 #endif 62 #endif
63 63
64 CPluginSettings* CPluginSettings::s_instance = NULL; 64 CPluginSettings* CPluginSettings::s_instance = NULL;
65 65
66 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; 66 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal;
67 67
68 68
69 CPluginSettings::CPluginSettings() : m_dwWorkingThreadId(0), m_isPluginEnabledTa b(true) 69 CPluginSettings::CPluginSettings() : m_dwWorkingThreadId(0)
70 { 70 {
71 s_instance = NULL; 71 s_instance = NULL;
72 72
73 m_WindowsBuildNumber = 0; 73 m_WindowsBuildNumber = 0;
74 74
75 #ifdef SUPPORT_WHITELIST 75 #ifdef SUPPORT_WHITELIST
76 ClearWhitelist(); 76 ClearWhitelist();
77 #endif 77 #endif
78 } 78 }
79 79
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 lang.Append(L"-"); 142 lang.Append(L"-");
143 lang.Append(country); 143 lang.Append(country);
144 144
145 return lang; 145 return lang;
146 146
147 } 147 }
148 148
149 149
150 bool CPluginSettings::IsPluginEnabled() const 150 bool CPluginSettings::IsPluginEnabled() const
151 { 151 {
152 return m_isPluginEnabledTab; 152 return GetPluginEnabled();
153 } 153 }
154 154
155 155
156 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() 156 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList()
157 { 157 {
158 m_subscriptions = CPluginClient::GetInstance()->FetchAvailableSubscriptions(); 158 m_subscriptions = CPluginClient::GetInstance()->FetchAvailableSubscriptions();
159 159
160 std::map<CString, CString> filterList; 160 std::map<CString, CString> filterList;
161 for (size_t i = 0; i < m_subscriptions.size(); i ++) 161 for (size_t i = 0; i < m_subscriptions.size(); i ++)
162 { 162 {
(...skipping 17 matching lines...) Expand all
180 m_dwWorkingThreadId = ::GetCurrentThreadId(); 180 m_dwWorkingThreadId = ::GetCurrentThreadId();
181 } 181 }
182 182
183 void CPluginSettings::SetWorkingThreadId(DWORD id) 183 void CPluginSettings::SetWorkingThreadId(DWORD id)
184 { 184 {
185 m_dwWorkingThreadId = id; 185 m_dwWorkingThreadId = id;
186 } 186 }
187 187
188 void CPluginSettings::TogglePluginEnabled() 188 void CPluginSettings::TogglePluginEnabled()
189 { 189 {
190 CPluginSettingsTabLock lock; 190 GetPluginEnabled() ? SetPluginDisabled() : SetPluginEnabled();
Wladimir Palant 2013/08/13 14:25:29 The SetPluginEnabled/SetPluginDisabled functions a
191 if (lock.IsLocked())
192 {
193 s_criticalSectionLocal.Lock();
194 {
195 //TODO: Query if plugin is enabled from the AdblockPlusEngine
196 m_isPluginEnabledTab = m_isPluginEnabledTab ? false : true;
197 //TODO: Set plugin enabled/disabled in AdblockPlusEngine
198 }
199 s_criticalSectionLocal.Unlock();
200 }
201 } 191 }
202 void CPluginSettings::SetPluginDisabled() 192 void CPluginSettings::SetPluginDisabled()
203 { 193 {
204 CPluginSettingsTabLock lock; 194 CPluginClient::GetInstance()->SetPref(L"enabled", false);
205 if (lock.IsLocked())
206 {
207 s_criticalSectionLocal.Lock();
208 {
209 m_isPluginEnabledTab = false;
210 //TODO: Set plugin disabled in AdblockPlusEngine
211 }
212 s_criticalSectionLocal.Unlock();
213 }
214 } 195 }
215 void CPluginSettings::SetPluginEnabled() 196 void CPluginSettings::SetPluginEnabled()
216 { 197 {
217 CPluginClient::GetInstance()->SetPref(L"enabled", true); 198 CPluginClient::GetInstance()->SetPref(L"enabled", true);
218 } 199 }
219 bool CPluginSettings::GetPluginEnabled() const 200 bool CPluginSettings::GetPluginEnabled() const
220 { 201 {
221 return CPluginClient::GetInstance()->GetPref(L"enabled", true); 202 return CPluginClient::GetInstance()->GetPref(L"enabled", true);
222 } 203 }
223 204
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 339 }
359 340
360 CString CPluginSettings::GetDocumentationLink() 341 CString CPluginSettings::GetDocumentationLink()
361 { 342 {
362 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str()); 343 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str());
363 } 344 }
364 345
365 346
366 347
367 #endif // SUPPORT_WHITELIST 348 #endif // SUPPORT_WHITELIST
OLDNEW
« no previous file with comments | « src/plugin/PluginSettings.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld