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: rebase only; no other changes Created Nov. 18, 2015, 12: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') | src/plugin/PluginStdAfx.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
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
41 CPluginSettings* CPluginSettings::s_instance = NULL; 41 CPluginSettings* CPluginSettings::s_instance = NULL;
42 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal; 42 CComAutoCriticalSection CPluginSettings::s_criticalSectionLocal;
43 43
44 CPluginSettings::CPluginSettings() : m_dwWorkingThreadId(0) 44 CPluginSettings::CPluginSettings()
45 { 45 {
46 s_instance = NULL; 46 s_instance = NULL;
47 m_WindowsBuildNumber = 0; 47 m_WindowsBuildNumber = 0;
48 ClearWhitelist(); 48 ClearWhitelist();
49 } 49 }
50 50
51 CPluginSettings::~CPluginSettings() 51 CPluginSettings::~CPluginSettings()
52 { 52 {
53 s_instance = NULL; 53 s_instance = NULL;
54 } 54 }
(...skipping 23 matching lines...) Expand all
78 78
79 s_criticalSectionLocal.Lock(); 79 s_criticalSectionLocal.Lock();
80 { 80 {
81 hasInstance = s_instance != NULL; 81 hasInstance = s_instance != NULL;
82 } 82 }
83 s_criticalSectionLocal.Unlock(); 83 s_criticalSectionLocal.Unlock();
84 84
85 return hasInstance; 85 return hasInstance;
86 } 86 }
87 87
88 std::wstring GetDataPath(const std::wstring& filename)
89 {
90 return GetAppDataPath() + L"\\" + filename;
91 }
92
93 bool CPluginSettings::IsPluginEnabled() const 88 bool CPluginSettings::IsPluginEnabled() const
94 { 89 {
95 return GetPluginEnabled(); 90 return GetPluginEnabled();
96 } 91 }
97 92
98 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() const 93 std::map<CString, CString> CPluginSettings::GetFilterLanguageTitleList() const
99 { 94 {
100 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc e()->FetchAvailableSubscriptions(); 95 std::vector<SubscriptionDescription> subscriptions = CPluginClient::GetInstanc e()->FetchAvailableSubscriptions();
101 96
102 std::map<CString, CString> filterList; 97 std::map<CString, CString> filterList;
103 for (size_t i = 0; i < subscriptions.size(); i ++) 98 for (size_t i = 0; i < subscriptions.size(); i ++)
104 { 99 {
105 SubscriptionDescription it = subscriptions[i]; 100 SubscriptionDescription it = subscriptions[i];
106 filterList.insert(std::make_pair(CString(it.url.c_str()), CString(it.title.c _str()))); 101 filterList.insert(std::make_pair(CString(it.url.c_str()), CString(it.title.c _str())));
107 } 102 }
108 return filterList; 103 return filterList;
109 } 104 }
110 105
111 bool CPluginSettings::IsWorkingThread(DWORD dwThreadId) const
112 {
113 if (dwThreadId == 0)
114 {
115 dwThreadId = ::GetCurrentThreadId();
116 }
117 return m_dwWorkingThreadId == dwThreadId;
118 }
119
120 void CPluginSettings::SetWorkingThreadId()
121 {
122 m_dwWorkingThreadId = ::GetCurrentThreadId();
123 }
124
125 void CPluginSettings::SetWorkingThreadId(DWORD id)
126 {
127 m_dwWorkingThreadId = id;
128 }
129
130 void CPluginSettings::TogglePluginEnabled() 106 void CPluginSettings::TogglePluginEnabled()
131 { 107 {
132 CPluginClient::GetInstance()->TogglePluginEnabled(); 108 CPluginClient::GetInstance()->TogglePluginEnabled();
133 } 109 }
134 bool CPluginSettings::GetPluginEnabled() const 110 bool CPluginSettings::GetPluginEnabled() const
135 { 111 {
136 return CPluginClient::GetInstance()->GetPref(L"enabled", true); 112 return CPluginClient::GetInstance()->GetPref(L"enabled", true);
137 } 113 }
138 114
139 115
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 241
266 CString CPluginSettings::GetAppLocale() 242 CString CPluginSettings::GetAppLocale()
267 { 243 {
268 return ToCString(GetBrowserLanguage()); 244 return ToCString(GetBrowserLanguage());
269 } 245 }
270 246
271 CString CPluginSettings::GetDocumentationLink() 247 CString CPluginSettings::GetDocumentationLink()
272 { 248 {
273 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str()); 249 return CString(CPluginClient::GetInstance()->GetDocumentationLink().c_str());
274 } 250 }
OLDNEW
« no previous file with comments | « src/plugin/PluginSettings.h ('k') | src/plugin/PluginStdAfx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld