Use base::DictionaryValue converter

This commit is contained in:
Kevin Sawicki 2017-05-30 13:00:55 -07:00
parent 4a5831a733
commit bf2fca3dd1
2 changed files with 5 additions and 27 deletions

View file

@ -1022,32 +1022,10 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
return result; return result;
} }
static mate::Dictionary ConvertDictionary( v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
v8::Isolate* isolate, const base::DictionaryValue &dict) { auto status = content::GetFeatureStatus();
auto result = mate::Dictionary::CreateEmpty(isolate); return mate::ConvertToV8(isolate,
status ? *status : base::DictionaryValue());
for (base::DictionaryValue::Iterator iterator(dict);
!iterator.IsAtEnd();
iterator.Advance()) {
auto& key = iterator.key();
auto& value = iterator.value();
if (value.is_string()) {
std::string strValue;
if (value.GetAsString(&strValue)) {
result.Set(key, strValue);
}
}
}
return result;
}
mate::Dictionary App::GetGPUFeatureStatus(v8::Isolate* isolate) {
if (auto status = content::GetFeatureStatus()) {
return ConvertDictionary(isolate, *status);
} else {
return mate::Dictionary::CreateEmpty(isolate);
}
} }
// static // static

View file

@ -177,7 +177,7 @@ class App : public AtomBrowserClient::Delegate,
mate::Arguments* args); mate::Arguments* args);
std::vector<mate::Dictionary> GetAppMetrics(v8::Isolate* isolate); std::vector<mate::Dictionary> GetAppMetrics(v8::Isolate* isolate);
mate::Dictionary GetGPUFeatureStatus(v8::Isolate* isolate); v8::Local<v8::Value> GetGPUFeatureStatus(v8::Isolate* isolate);
#if defined(OS_WIN) #if defined(OS_WIN)
// Get the current Jump List settings. // Get the current Jump List settings.