Use object for options
This commit is contained in:
		
					parent
					
						
							
								bec671bac8
							
						
					
				
			
			
				commit
				
					
						05cb26a174
					
				
			
		
					 1 changed files with 15 additions and 21 deletions
				
			
		| 
						 | 
				
			
			@ -315,26 +315,6 @@ struct Converter<Browser::LoginItemSettings> {
 | 
			
		|||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
struct Converter<IconLoader::IconSize> {
 | 
			
		||||
  static bool FromV8(v8::Isolate* isolate,
 | 
			
		||||
                     v8::Local<v8::Value> 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<content::CertificateRequestResultType> {
 | 
			
		||||
  static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> 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<v8::Value> 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)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue