browser: handle flash context menu

This commit is contained in:
Robo 2015-10-31 19:09:07 +05:30
parent cb91d4487b
commit c969052f12
10 changed files with 177 additions and 22 deletions

View file

@ -4,30 +4,50 @@
#include "atom/common/native_mate_converters/content_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "content/public/common/context_menu_params.h"
#include "content/public/common/menu_item.h"
#include "native_mate/dictionary.h"
#include "net/url_request/url_request.h"
namespace mate {
template<>
struct Converter<content::MenuItem::Type> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const content::MenuItem::Type& val) {
switch (val) {
case content::MenuItem::CHECKABLE_OPTION:
return StringToV8(isolate, "checkbox");
case content::MenuItem::SEPARATOR:
return StringToV8(isolate, "separator");
case content::MenuItem::SUBMENU:
return StringToV8(isolate, "submenu");
default:
return StringToV8(isolate, "normal");
}
}
};
// static
v8::Local<v8::Value> Converter<const net::URLRequest*>::ToV8(
v8::Isolate* isolate, const net::URLRequest* val) {
v8::Local<v8::Value> Converter<content::MenuItem>::ToV8(
v8::Isolate* isolate, const content::MenuItem& val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("method", val->method());
dict.Set("url", val->url().spec());
dict.Set("referrer", val->referrer());
dict.Set("id", val.action);
dict.Set("type", val.type);
dict.Set("label", val.label);
dict.Set("enabled", val.enabled);
dict.Set("checked", val.checked);
return mate::ConvertToV8(isolate, dict);
}
// static
v8::Local<v8::Value> Converter<const net::AuthChallengeInfo*>::ToV8(
v8::Isolate* isolate, const net::AuthChallengeInfo* val) {
v8::Local<v8::Value> Converter<content::ContextMenuParams>::ToV8(
v8::Isolate* isolate, const content::ContextMenuParams& val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("isProxy", val->is_proxy);
dict.Set("scheme", val->scheme);
dict.Set("host", val->challenger.host());
dict.Set("port", static_cast<uint32_t>(val->challenger.port()));
dict.Set("realm", val->realm);
dict.Set("x", val.x);
dict.Set("y", val.y);
dict.Set("isPepperMenu", val.custom_context.is_pepper_menu);
dict.Set("menuItems", val.custom_items);
return mate::ConvertToV8(isolate, dict);
}

View file

@ -7,23 +7,23 @@
#include "native_mate/converter.h"
namespace net {
class AuthChallengeInfo;
class URLRequest;
namespace content {
struct ContextMenuParams;
struct MenuItem;
}
namespace mate {
template<>
struct Converter<const net::URLRequest*> {
struct Converter<content::MenuItem> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const net::URLRequest* val);
const content::MenuItem& val);
};
template<>
struct Converter<const net::AuthChallengeInfo*> {
struct Converter<content::ContextMenuParams> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const net::AuthChallengeInfo* val);
const content::ContextMenuParams& val);
};
} // namespace mate

View file

@ -0,0 +1,34 @@
// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "atom/common/native_mate_converters/net_converter.h"
#include "native_mate/dictionary.h"
#include "net/url_request/url_request.h"
namespace mate {
// static
v8::Local<v8::Value> Converter<const net::URLRequest*>::ToV8(
v8::Isolate* isolate, const net::URLRequest* val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("method", val->method());
dict.Set("url", val->url().spec());
dict.Set("referrer", val->referrer());
return mate::ConvertToV8(isolate, dict);
}
// static
v8::Local<v8::Value> Converter<const net::AuthChallengeInfo*>::ToV8(
v8::Isolate* isolate, const net::AuthChallengeInfo* val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("isProxy", val->is_proxy);
dict.Set("scheme", val->scheme);
dict.Set("host", val->challenger.host());
dict.Set("port", static_cast<uint32_t>(val->challenger.port()));
dict.Set("realm", val->realm);
return mate::ConvertToV8(isolate, dict);
}
} // namespace mate

View file

@ -0,0 +1,31 @@
// Copyright (c) 2015 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ATOM_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_
#include "native_mate/converter.h"
namespace net {
class AuthChallengeInfo;
class URLRequest;
}
namespace mate {
template<>
struct Converter<const net::URLRequest*> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const net::URLRequest* val);
};
template<>
struct Converter<const net::AuthChallengeInfo*> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const net::AuthChallengeInfo* val);
};
} // namespace mate
#endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_NET_CONVERTER_H_