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

Unified Diff: src/engine/main.cpp

Issue 11013110: Cleanup (Closed)
Patch Set: More beautification and addressing comments Created July 29, 2013, 12:13 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 | « adblockplus.gyp ('k') | src/plugin/AdblockPlus.rc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/engine/main.cpp
===================================================================
--- a/src/engine/main.cpp
+++ b/src/engine/main.cpp
@@ -143,6 +143,84 @@
filterEngine->GetFilter(text)->RemoveFromList();
break;
}
+ case Communication::PROC_SET_PREF:
+ {
+ std::string prefName;
+ request >> prefName;
+
+ Communication::ValueType valueType = request.GetType();
+ switch (valueType)
+ {
+ case Communication::TYPE_STRING:
+ {
+ std::string prefValue;
+ request >> prefValue;
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue));
+ break;
+ }
+ case Communication::TYPE_INT64:
+ {
+ int64_t prefValue;
+ request >> prefValue;
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue));
+ break;
+ }
+ case Communication::TYPE_INT32:
+ {
+ int prefValue;
+ request >> prefValue;
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue));
+ break;
+ }
+ case Communication::TYPE_BOOL:
+ {
+ bool prefValue;
+ request >> prefValue;
+ filterEngine->SetPref(prefName, filterEngine->GetJsEngine()->NewValue(prefValue));
+ break;
+ }
+ default:
+ break;
+ }
+ break;
+ }
+ case Communication::PROC_GET_PREF:
+ {
+ std::string name;
+ request >> name;
+
+ AdblockPlus::JsValuePtr valuePtr = filterEngine->GetPref(name);
+ if (valuePtr->IsNull() || valuePtr->IsUndefined())
+ {
+ // Report no success
+ response << false;
+ break;
+ }
+
+
+ if (valuePtr->IsBool())
+ {
+ response << true;
+ response << valuePtr->AsBool();
+ }
+ else if (valuePtr->IsNumber())
+ {
+ response << true;
+ response << valuePtr->AsInt();
+ }
+ else if (valuePtr->IsString())
+ {
+ response << true;
+ response << valuePtr->AsString();
+ }
+ else
+ {
+ // Report failure
+ response << false;
+ }
+ break;
+ }
+
}
return response;
}
« no previous file with comments | « adblockplus.gyp ('k') | src/plugin/AdblockPlus.rc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld