Merge branch 'master' into native-window-open

This commit is contained in:
Ryohei Ikegami 2017-05-11 13:51:43 +09:00
commit 7ac93045b7
157 changed files with 2239 additions and 1058 deletions

View file

@ -51,13 +51,13 @@ SpellCheckClient::SpellCheckClient(const std::string& language,
SpellCheckClient::~SpellCheckClient() {}
void SpellCheckClient::spellCheck(
void SpellCheckClient::checkSpelling(
const blink::WebString& text,
int& misspelling_start,
int& misspelling_len,
blink::WebVector<blink::WebString>* optional_suggestions) {
std::vector<blink::WebTextCheckingResult> results;
SpellCheckText(base::string16(text), true, &results);
SpellCheckText(text.utf16(), true, &results);
if (results.size() == 1) {
misspelling_start = results[0].location;
misspelling_len = results[0].length;
@ -66,10 +66,8 @@ void SpellCheckClient::spellCheck(
void SpellCheckClient::requestCheckingOfText(
const blink::WebString& textToCheck,
const blink::WebVector<uint32_t>& markersInText,
const blink::WebVector<unsigned>& markerOffsets,
blink::WebTextCheckingCompletion* completionCallback) {
base::string16 text(textToCheck);
base::string16 text(textToCheck.utf16());
if (text.empty() || !HasWordCharacters(text, 0)) {
completionCallback->didCancelCheckingText();
return;

View file

@ -13,6 +13,10 @@
#include "native_mate/scoped_persistent.h"
#include "third_party/WebKit/public/web/WebSpellCheckClient.h"
namespace blink {
struct WebTextCheckingResult;
}
namespace atom {
namespace api {
@ -27,15 +31,13 @@ class SpellCheckClient : public blink::WebSpellCheckClient {
private:
// blink::WebSpellCheckClient:
void spellCheck(
void checkSpelling(
const blink::WebString& text,
int& misspelledOffset,
int& misspelledLength,
blink::WebVector<blink::WebString>* optionalSuggestions) override;
void requestCheckingOfText(
const blink::WebString& textToCheck,
const blink::WebVector<uint32_t>& markersInText,
const blink::WebVector<unsigned>& markerOffsets,
blink::WebTextCheckingCompletion* completionCallback) override;
void showSpellingUI(bool show) override;
bool isShowingSpellingUI() override;

View file

@ -16,15 +16,15 @@
#include "content/public/renderer/render_view.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "third_party/WebKit/public/web/WebCache.h"
#include "third_party/WebKit/public/platform/WebCache.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrameWidget.h"
#include "third_party/WebKit/public/web/WebInputMethodController.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebScriptExecutionCallback.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
#include "atom/common/node_includes.h"
@ -110,7 +110,8 @@ void WebFrame::SetLayoutZoomLevelLimits(double min_level, double max_level) {
v8::Local<v8::Value> WebFrame::RegisterEmbedderCustomElement(
const base::string16& name, v8::Local<v8::Object> options) {
blink::WebExceptionCode c = 0;
return web_frame_->document().registerEmbedderCustomElement(name, options, c);
return web_frame_->document().registerEmbedderCustomElement(
blink::WebString::fromUTF16(name), options, c);
}
void WebFrame::RegisterElementResizeCallback(
@ -145,15 +146,14 @@ void WebFrame::SetSpellCheckProvider(mate::Arguments* args,
void WebFrame::RegisterURLSchemeAsSecure(const std::string& scheme) {
// TODO(pfrazee): Remove 2.0
// Register scheme to secure list (https, wss, data).
blink::WebSecurityPolicy::registerURLSchemeAsSecure(
blink::WebString::fromUTF8(scheme));
blink::SchemeRegistry::registerURLSchemeAsSecure(
WTF::String::fromUTF8(scheme.data(), scheme.length()));
}
void WebFrame::RegisterURLSchemeAsBypassingCSP(const std::string& scheme) {
// Register scheme to bypass pages's Content Security Policy.
blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
blink::WebString::fromUTF8(scheme));
blink::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(
WTF::String::fromUTF8(scheme.data(), scheme.length()));
}
void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
@ -175,32 +175,36 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
}
}
// Register scheme to privileged list (https, wss, data, chrome-extension)
blink::WebString privileged_scheme(blink::WebString::fromUTF8(scheme));
WTF::String privileged_scheme(
WTF::String::fromUTF8(scheme.data(), scheme.length()));
if (secure) {
// TODO(pfrazee): Remove 2.0
blink::WebSecurityPolicy::registerURLSchemeAsSecure(privileged_scheme);
blink::SchemeRegistry::registerURLSchemeAsSecure(privileged_scheme);
}
if (bypassCSP) {
blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
blink::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(
privileged_scheme);
}
if (allowServiceWorkers) {
blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers(
blink::SchemeRegistry::registerURLSchemeAsAllowingServiceWorkers(
privileged_scheme);
}
if (supportFetchAPI) {
blink::WebSecurityPolicy::registerURLSchemeAsSupportingFetchAPI(
blink::SchemeRegistry::registerURLSchemeAsSupportingFetchAPI(
privileged_scheme);
}
if (corsEnabled) {
blink::WebSecurityPolicy::registerURLSchemeAsCORSEnabled(privileged_scheme);
blink::SchemeRegistry::registerURLSchemeAsCORSEnabled(privileged_scheme);
}
}
void WebFrame::InsertText(const std::string& text) {
web_frame_->frameWidget()
->getActiveWebInputMethodController()
->commitText(blink::WebString::fromUTF8(text), 0);
->commitText(blink::WebString::fromUTF8(text),
blink::WebVector<blink::WebCompositionUnderline>(),
blink::WebRange(),
0);
}
void WebFrame::InsertCSS(const std::string& css) {
@ -216,7 +220,7 @@ void WebFrame::ExecuteJavaScript(const base::string16& code,
std::unique_ptr<blink::WebScriptExecutionCallback> callback(
new ScriptExecutionCallback(completion_callback));
web_frame_->requestExecuteScriptAndReturnValue(
blink::WebScriptSource(code),
blink::WebScriptSource(blink::WebString::fromUTF16(code)),
has_user_gesture,
callback.release());
}

View file

@ -11,7 +11,7 @@
#include "atom/renderer/guest_view_container.h"
#include "native_mate/handle.h"
#include "native_mate/wrappable.h"
#include "third_party/WebKit/public/web/WebCache.h"
#include "third_party/WebKit/public/platform/WebCache.h"
namespace blink {
class WebLocalFrame;

View file

@ -24,7 +24,6 @@ void AtomRenderFrameObserver::DidClearWindowObject() {
void AtomRenderFrameObserver::DidCreateScriptContext(
v8::Handle<v8::Context> context,
int extension_group,
int world_id) {
if (ShouldNotifyClient(world_id))
renderer_client_->DidCreateScriptContext(context, render_frame_);
@ -62,8 +61,7 @@ void AtomRenderFrameObserver::CreateIsolatedWorldContext() {
// Create initial script context in isolated world
blink::WebScriptSource source("void 0");
frame->executeScriptInIsolatedWorld(
World::ISOLATED_WORLD, &source, 1, ExtensionGroup::MAIN_GROUP);
frame->executeScriptInIsolatedWorld(World::ISOLATED_WORLD, &source, 1);
}
bool AtomRenderFrameObserver::IsMainWorld(int world_id) {

View file

@ -17,10 +17,6 @@ enum World {
ISOLATED_WORLD = 999
};
enum ExtensionGroup {
MAIN_GROUP = 1
};
// Helper class to forward the messages to the client.
class AtomRenderFrameObserver : public content::RenderFrameObserver {
public:
@ -30,7 +26,6 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
// content::RenderFrameObserver:
void DidClearWindowObject() override;
void DidCreateScriptContext(v8::Handle<v8::Context> context,
int extension_group,
int world_id) override;
void WillReleaseScriptContext(v8::Local<v8::Context> context,
int world_id) override;

View file

@ -7,8 +7,6 @@
#include <string>
#include <vector>
#include "atom_natives.h" // NOLINT: This file is generated with js2c
#include "atom/common/api/atom_bindings.h"
#include "atom/common/api/event_emitter_caller.h"
#include "atom/common/asar/asar_util.h"
@ -27,6 +25,7 @@
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "atom/common/node_includes.h"
#include "atom_natives.h" // NOLINT: This file is generated with js2c
namespace atom {
@ -172,8 +171,7 @@ void AtomRendererClient::WillDestroyWorkerContextOnWorkerThread(
v8::Local<v8::Context> AtomRendererClient::GetContext(
blink::WebFrame* frame, v8::Isolate* isolate) {
if (isolated_world())
return frame->worldScriptContext(
isolate, World::ISOLATED_WORLD, ExtensionGroup::MAIN_GROUP);
return frame->worldScriptContext(isolate, World::ISOLATED_WORLD);
else
return frame->mainWorldScriptContext();
}

View file

@ -6,14 +6,11 @@
#include <string>
#include "atom_natives.h" // NOLINT: This file is generated with js2c
#include "atom/common/api/api_messages.h"
#include "atom/common/api/atom_bindings.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/v8_value_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/node_includes.h"
#include "atom/common/options_switches.h"
#include "atom/renderer/api/atom_api_renderer_ipc.h"
#include "atom/renderer/atom_render_view_observer.h"
@ -31,6 +28,9 @@
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "atom/common/node_includes.h"
#include "atom_natives.h" // NOLINT: This file is generated with js2c
namespace atom {
namespace {
@ -86,6 +86,9 @@ void InitializeBindings(v8::Local<v8::Object> binding,
mate::Dictionary b(isolate, binding);
b.SetMethod("get", GetBinding);
b.SetMethod("crash", AtomBindings::Crash);
b.SetMethod("hang", AtomBindings::Hang);
b.SetMethod("getProcessMemoryInfo", &AtomBindings::GetProcessMemoryInfo);
b.SetMethod("getSystemMemoryInfo", &AtomBindings::GetSystemMemoryInfo);
}
class AtomSandboxedRenderViewObserver : public AtomRenderViewObserver {

View file

@ -30,6 +30,7 @@
#include "third_party/WebKit/public/web/WebPluginParams.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
@ -85,6 +86,13 @@ void RendererClientBase::RenderThreadStarted() {
blink::WebCustomElement::addEmbedderCustomElementName("webview");
blink::WebCustomElement::addEmbedderCustomElementName("browserplugin");
// Parse --secure-schemes=scheme1,scheme2
std::vector<std::string> secure_schemes_list =
ParseSchemesCLISwitch(switches::kSecureSchemes);
for (const std::string& scheme : secure_schemes_list)
blink::SchemeRegistry::registerURLSchemeAsSecure(
WTF::String::fromUTF8(scheme.data(), scheme.length()));
preferences_manager_.reset(new PreferencesManager);
#if defined(OS_WIN)
@ -126,13 +134,6 @@ void RendererClientBase::RenderFrameCreated(
// Allow access to file scheme from pdf viewer.
blink::WebSecurityPolicy::addOriginAccessWhitelistEntry(
GURL(kPdfViewerUIOrigin), "file", "", true);
// Parse --secure-schemes=scheme1,scheme2
std::vector<std::string> secure_schemes_list =
ParseSchemesCLISwitch(switches::kSecureSchemes);
for (const std::string& secure_scheme : secure_schemes_list)
blink::WebSecurityPolicy::registerURLSchemeAsSecure(
blink::WebString::fromUTF8(secure_scheme));
}
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {