webContents: adding findInPage api

This commit is contained in:
Robo 2015-12-17 22:57:56 +05:30
parent c68e38f480
commit 39e615ed87
7 changed files with 157 additions and 1 deletions

View file

@ -282,4 +282,20 @@ bool Converter<blink::WebDeviceEmulationParams>::FromV8(
return true;
}
bool Converter<blink::WebFindOptions>::FromV8(
v8::Isolate* isolate,
v8::Local<v8::Value> val,
blink::WebFindOptions* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
dict.Get("forward", &out->forward);
dict.Get("matchCase", &out->matchCase);
dict.Get("findNext", &out->findNext);
dict.Get("wordStart", &out->wordStart);
dict.Get("medialCapitalAsWordStart", &out->medialCapitalAsWordStart);
return true;
}
} // namespace mate

View file

@ -6,6 +6,7 @@
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_
#include "native_mate/converter.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
namespace blink {
class WebInputEvent;
@ -80,6 +81,12 @@ struct Converter<blink::WebDeviceEmulationParams> {
blink::WebDeviceEmulationParams* out);
};
template<>
struct Converter<blink::WebFindOptions> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
blink::WebFindOptions* out);
};
} // namespace mate
#endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_

View file

@ -4,6 +4,7 @@
#include "atom/common/native_mate_converters/content_converter.h"
#include <string>
#include <vector>
#include "atom/common/native_mate_converters/callback.h"
@ -97,4 +98,23 @@ v8::Local<v8::Value> Converter<ContextMenuParamsWithWebContents>::ToV8(
return mate::ConvertToV8(isolate, dict);
}
// static
bool Converter<content::StopFindAction>::FromV8(
v8::Isolate* isolate,
v8::Local<v8::Value> val,
content::StopFindAction* out) {
std::string action;
if (!ConvertFromV8(isolate, val, &action))
return false;
if (action == "clearSelection")
*out = content::STOP_FIND_ACTION_CLEAR_SELECTION;
else if (action == "keepSelection")
*out = content::STOP_FIND_ACTION_KEEP_SELECTION;
else
*out = content::STOP_FIND_ACTION_ACTIVATE_SELECTION;
return true;
}
} // namespace mate

View file

@ -8,6 +8,7 @@
#include <utility>
#include "content/public/common/menu_item.h"
#include "content/public/common/stop_find_action.h"
#include "native_mate/converter.h"
namespace content {
@ -32,6 +33,12 @@ struct Converter<ContextMenuParamsWithWebContents> {
const ContextMenuParamsWithWebContents& val);
};
template<>
struct Converter<content::StopFindAction> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
content::StopFindAction* out);
};
} // namespace mate
#endif // ATOM_COMMON_NATIVE_MATE_CONVERTERS_CONTENT_CONVERTER_H_