From 05cb26a1743fbe11d2218c13764c4fc3658d729c Mon Sep 17 00:00:00 2001 From: Yury Solovyov Date: Thu, 3 Nov 2016 21:23:40 +0300 Subject: [PATCH] Use object for options --- atom/browser/api/atom_api_app.cc | 36 +++++++++++++------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index f5d9201f84ee..c6b50a48e93d 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -315,26 +315,6 @@ struct Converter { } }; -template <> -struct Converter { - static bool FromV8(v8::Isolate* isolate, - v8::Local val, - IconLoader::IconSize* out) { - std::string icon_size_string; - if (!ConvertFromV8(isolate, val, &icon_size_string)) - return false; - if (icon_size_string == "small") - *out = IconLoader::IconSize::SMALL; - else if (icon_size_string == "normal") - *out = IconLoader::IconSize::NORMAL; - else if (icon_size_string == "large") - *out = IconLoader::IconSize::LARGE; - else - return false; - return true; - } -}; - template<> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, @@ -356,6 +336,15 @@ namespace api { namespace { +IconLoader::IconSize GetIconSizeByString(std::string size) { + if (size == "small") { + return IconLoader::IconSize::SMALL; + } else if (size == "large") { + return IconLoader::IconSize::LARGE; + } + return IconLoader::IconSize::NORMAL; +}; + // Return the path constant from string. int GetPathConstant(const std::string& name) { if (name == "appData") @@ -869,11 +858,16 @@ JumpListResult App::SetJumpList(v8::Local val, void App::GetFileIcon(const base::FilePath& path, mate::Arguments* args) { + base::DictionaryValue options; IconLoader::IconSize icon_size; FileIconCallback callback; - if (!args->GetNext(&icon_size)) { + if (!args->GetNext(&options)) { icon_size = IconLoader::IconSize::NORMAL; + } else { + std::string icon_size_string; + options.GetString("size", &icon_size_string); + icon_size = GetIconSizeByString(icon_size_string); } if (!args->GetNext(&callback)) {