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

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

Issue 5187613258416128: Issue #1234 - Rewrite internals of debug facility (Closed)
Patch Set: Created March 12, 2015, 10:52 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
OLDNEW
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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 class CPluginSettingsWhitelistLock : public CPluginMutex 51 class CPluginSettingsWhitelistLock : public CPluginMutex
52 { 52 {
53 public: 53 public:
54 CPluginSettingsWhitelistLock() : CPluginMutex(L"SettingsFileWhitelist", PLUGIN _ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {} 54 CPluginSettingsWhitelistLock() : CPluginMutex(L"SettingsFileWhitelist", PLUGIN _ERROR_MUTEX_SETTINGS_FILE_WHITELIST) {}
55 ~CPluginSettingsWhitelistLock() {} 55 ~CPluginSettingsWhitelistLock() {}
56 }; 56 };
57 57
58 CPluginSettings* CPluginSettings::s_instance = NULL; 58 CPluginSettings* CPluginSettings::s_instance = NULL;
59 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; 59 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal;
60 60
61 CPluginSettings::CPluginSettings() : m_dwWorkingThreadId(0) 61 CPluginSettings::CPluginSettings()
62 { 62 {
63 s_instance = NULL; 63 s_instance = NULL;
64 m_WindowsBuildNumber = 0; 64 m_WindowsBuildNumber = 0;
65 ClearWhitelist(); 65 ClearWhitelist();
66 } 66 }
67 67
68 CPluginSettings::~CPluginSettings() 68 CPluginSettings::~CPluginSettings()
69 { 69 {
70 s_instance = NULL; 70 s_instance = NULL;
71 } 71 }
(...skipping 23 matching lines...) Expand all
95 95
96 s_criticalSectionLocal.Lock(); 96 s_criticalSectionLocal.Lock();
97 { 97 {
98 hasInstance = s_instance != NULL; 98 hasInstance = s_instance != NULL;
99 } 99 }
100 s_criticalSectionLocal.Unlock(); 100 s_criticalSectionLocal.Unlock();
101 101
102 return hasInstance; 102 return hasInstance;
103 } 103 }
104 104
105 std::wstring GetDataPath(const std::wstring& filename)
106 {
107 return GetAppDataPath() + L"\\" + filename;
108 }
109
110 bool CPluginSettings::IsPluginEnabled() const 105 bool CPluginSettings::IsPluginEnabled() const
111 { 106 {
112 return GetPluginEnabled(); 107 return GetPluginEnabled();
113 } 108 }
114 109
115 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() const 110 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() const
116 { 111 {
117 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc e()->FetchAvailableSubscriptions(); 112 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc e()->FetchAvailableSubscriptions();
118 113
119 std::map<CString, CString> filterList; 114 std::map<CString, CString> filterList;
120 for (size_t i = 0; i < subscriptions.size(); i ++) 115 for (size_t i = 0; i < subscriptions.size(); i ++)
121 { 116 {
122 SubscriptionDescription it = subscriptions[i]; 117 SubscriptionDescription it = subscriptions[i];
123 filterList.insert(std::make_pair(CString(it.url.c_str()), CString(it.title.c _str()))); 118 filterList.insert(std::make_pair(CString(it.url.c_str()), CString(it.title.c _str())));
124 } 119 }
125 return filterList; 120 return filterList;
126 } 121 }
127 122
128 bool CPluginSettings::IsWorkingThread(DWORD dwThreadId) const
129 {
130 if (dwThreadId == 0)
131 {
132 dwThreadId = ::GetCurrentThreadId();
133 }
134 return m_dwWorkingThreadId == dwThreadId;
135 }
136
137 void CPluginSettings::SetWorkingThreadId()
138 {
139 m_dwWorkingThreadId = ::GetCurrentThreadId();
140 }
141
142 void CPluginSettings::SetWorkingThreadId(DWORD id)
143 {
144 m_dwWorkingThreadId = id;
145 }
146
147 void CPluginSettings::TogglePluginEnabled() 123 void CPluginSettings::TogglePluginEnabled()
148 { 124 {
149 CPluginClient::GetInstance()->TogglePluginEnabled(); 125 CPluginClient::GetInstance()->TogglePluginEnabled();
150 } 126 }
151 bool CPluginSettings::GetPluginEnabled() const 127 bool CPluginSettings::GetPluginEnabled() const
152 { 128 {
153 return CPluginClient::GetInstance()->GetPref(L"enabled", true); 129 return CPluginClient::GetInstance()->GetPref(L"enabled", true);
154 } 130 }
155 131
156 132
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 258
283 CString CPluginSettings::GetAppLocale() 259 CString CPluginSettings::GetAppLocale()
284 { 260 {
285 return ToCString(GetBrowserLanguage()); 261 return ToCString(GetBrowserLanguage());
286 } 262 }
287 263
288 CString CPluginSettings::GetDocumentationLink() 264 CString CPluginSettings::GetDocumentationLink()
289 { 265 {
290 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str()); 266 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str());
291 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld