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

Unified Diff: src/plugin/AdblockPlusClient.cpp

Issue 4882650246414336: Issue 2005 - Refactor working with strings in InputBuffer and OutputBuffer
Patch Set: rebase Created Feb. 19, 2015, 2:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/shared/Communication.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/plugin/AdblockPlusClient.cpp
diff --git a/src/plugin/AdblockPlusClient.cpp b/src/plugin/AdblockPlusClient.cpp
index db60b634fa07964e4db920771afc8392ddbf2b44..04f669c51f44414a35e2998a7dbbfa09d8ba33c0 100644
--- a/src/plugin/AdblockPlusClient.cpp
+++ b/src/plugin/AdblockPlusClient.cpp
@@ -134,15 +134,9 @@ namespace
for (int32_t i = 0; i < count; i++)
{
SubscriptionDescription description;
- std::string url;
- message >> url;
- description.url = ToUtf16String(url);
- std::string title;
- message >> title;
- description.title = ToUtf16String(title);
- std::string specialization;
- message >> specialization;
- description.specialization = ToUtf16String(specialization);
+ message >> description.url;
+ message >> description.title;
+ message >> description.specialization;
message >> description.listed;
result.push_back(description);
}
@@ -262,7 +256,7 @@ bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url)
{
DEBUG_GENERAL((L"IsWhitelistedUrl: " + url + L" start").c_str());
Communication::OutputBuffer request;
- request << Communication::PROC_IS_WHITELISTED_URL << ToUtf8String(url);
+ request << Communication::PROC_IS_WHITELISTED_URL << url;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -278,7 +272,7 @@ bool CAdblockPlusClient::IsWhitelistedUrl(const std::wstring& url)
bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url)
{
Communication::OutputBuffer request;
- request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << ToUtf8String(url);
+ request << Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL << url;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -292,7 +286,7 @@ bool CAdblockPlusClient::IsElemhideWhitelistedOnDomain(const std::wstring& url)
bool CAdblockPlusClient::Matches(const std::wstring& url, AdblockPlus::FilterEngine::ContentType contentType, const std::wstring& domain)
{
Communication::OutputBuffer request;
- request << Communication::PROC_MATCHES << ToUtf8String(url) << static_cast<int32_t>(contentType) << ToUtf8String(domain);
+ request << Communication::PROC_MATCHES << url << contentType << domain;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -306,15 +300,15 @@ bool CAdblockPlusClient::Matches(const std::wstring& url, AdblockPlus::FilterEng
std::vector<std::wstring> CAdblockPlusClient::GetElementHidingSelectors(const std::wstring& domain)
{
Communication::OutputBuffer request;
- request << Communication::PROC_GET_ELEMHIDE_SELECTORS << ToUtf8String(domain);
+ request << Communication::PROC_GET_ELEMHIDE_SELECTORS << domain;
Communication::InputBuffer response;
if (!CallEngine(request, response))
return std::vector<std::wstring>();
- std::vector<std::string> selectors;
+ std::vector<std::wstring> selectors;
response >> selectors;
- return ToUtf16Strings(selectors);
+ return selectors;
}
std::vector<SubscriptionDescription> CAdblockPlusClient::FetchAvailableSubscriptions()
@@ -351,21 +345,21 @@ bool CAdblockPlusClient::IsAcceptableAdsEnabled()
void CAdblockPlusClient::SetSubscription(const std::wstring& url)
{
Communication::OutputBuffer request;
- request << Communication::PROC_SET_SUBSCRIPTION << ToUtf8String(url);
+ request << Communication::PROC_SET_SUBSCRIPTION << url;
CallEngine(request);
}
void CAdblockPlusClient::AddSubscription(const std::wstring& url)
{
Communication::OutputBuffer request;
- request << Communication::PROC_ADD_SUBSCRIPTION << ToUtf8String(url);
+ request << Communication::PROC_ADD_SUBSCRIPTION << url;
CallEngine(request);
}
void CAdblockPlusClient::RemoveSubscription(const std::wstring& url)
{
Communication::OutputBuffer request;
- request << Communication::PROC_REMOVE_SUBSCRIPTION << ToUtf8String(url);
+ request << Communication::PROC_REMOVE_SUBSCRIPTION << url;
CallEngine(request);
}
@@ -381,9 +375,9 @@ std::vector<std::wstring> CAdblockPlusClient::GetExceptionDomains()
if (!CallEngine(Communication::PROC_GET_EXCEPTION_DOMAINS, response))
return std::vector<std::wstring>();
- std::vector<std::string> domains;
+ std::vector<std::wstring> domains;
response >> domains;
- return ToUtf16Strings(domains);
+ return domains;
}
bool CAdblockPlusClient::IsFirstRun()
@@ -399,35 +393,35 @@ bool CAdblockPlusClient::IsFirstRun()
void CAdblockPlusClient::AddFilter(const std::wstring& text)
{
Communication::OutputBuffer request;
- request << Communication::PROC_ADD_FILTER << ToUtf8String(text);
+ request << Communication::PROC_ADD_FILTER << text;
CallEngine(request);
}
void CAdblockPlusClient::RemoveFilter(const std::wstring& text)
{
Communication::OutputBuffer request;
- request << Communication::PROC_REMOVE_FILTER << ToUtf8String(text);
+ request << Communication::PROC_REMOVE_FILTER << text;
CallEngine(request);
}
void CAdblockPlusClient::SetPref(const std::wstring& name, const std::wstring& value)
{
Communication::OutputBuffer request;
- request << Communication::PROC_SET_PREF << ToUtf8String(name) << ToUtf8String(value);
+ request << Communication::PROC_SET_PREF << name << value;
CallEngine(request);
}
void CAdblockPlusClient::SetPref(const std::wstring& name, const int64_t & value)
{
Communication::OutputBuffer request;
- request << Communication::PROC_SET_PREF << ToUtf8String(name) << value;
+ request << Communication::PROC_SET_PREF << name << value;
CallEngine(request);
}
void CAdblockPlusClient::SetPref(const std::wstring& name, bool value)
{
Communication::OutputBuffer request;
- request << Communication::PROC_SET_PREF << ToUtf8String(name) << value;
+ request << Communication::PROC_SET_PREF << name << value;
CallEngine(request);
}
@@ -439,7 +433,7 @@ std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
{
DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str());
Communication::OutputBuffer request;
- request << Communication::PROC_GET_PREF << ToUtf8String(name);
+ request << Communication::PROC_GET_PREF << name;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -448,10 +442,10 @@ std::wstring CAdblockPlusClient::GetPref(const std::wstring& name, const std::ws
response >> success;
if (success)
{
- std::string value;
+ std::wstring value;
response >> value;
DEBUG_GENERAL((L"GetPref: " + name + L" end").c_str());
- return ToUtf16String(value);
+ return value;
}
else
{
@@ -464,7 +458,7 @@ bool CAdblockPlusClient::GetPref(const std::wstring& name, bool defaultValue)
{
DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str());
Communication::OutputBuffer request;
- request << Communication::PROC_GET_PREF << ToUtf8String(name);
+ request << Communication::PROC_GET_PREF << name;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -488,7 +482,7 @@ int64_t CAdblockPlusClient::GetPref(const std::wstring& name, int64_t defaultVal
{
DEBUG_GENERAL((L"GetPref: " + name + L" start").c_str());
Communication::OutputBuffer request;
- request << Communication::PROC_GET_PREF << ToUtf8String(name);
+ request << Communication::PROC_GET_PREF << name;
Communication::InputBuffer response;
if (!CallEngine(request, response))
@@ -522,9 +516,9 @@ std::wstring CAdblockPlusClient::GetDocumentationLink()
Communication::InputBuffer response;
if (!CallEngine(Communication::PROC_GET_DOCUMENTATION_LINK, response))
return L"";
- std::string docLink;
+ std::wstring docLink;
response >> docLink;
- return ToUtf16String(docLink);
+ return docLink;
}
bool CAdblockPlusClient::TogglePluginEnabled()
@@ -542,21 +536,21 @@ std::wstring CAdblockPlusClient::GetHostFromUrl(const std::wstring& url)
{
DEBUG_GENERAL("GetHostFromUrl");
Communication::OutputBuffer request;
- request << Communication::PROC_GET_HOST << ToUtf8String(url);
+ request << Communication::PROC_GET_HOST << url;
Communication::InputBuffer response;
if (!CallEngine(request, response))
return L"";
- std::string host;
+ std::wstring host;
response >> host;
- return ToUtf16String(host);
+ return host;
}
int CAdblockPlusClient::CompareVersions(const std::wstring& v1, const std::wstring& v2)
{
DEBUG_GENERAL("CompareVersions");
Communication::OutputBuffer request;
- request << Communication::PROC_COMPARE_VERSIONS << ToUtf8String(v1) << ToUtf8String(v2);
+ request << Communication::PROC_COMPARE_VERSIONS << v1 << v2;
Communication::InputBuffer response;
if (!CallEngine(request, response))
return 0;
« no previous file with comments | « no previous file | src/shared/Communication.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld