From 481b04358e6f45cb4297ab965a6d7d1013827fae Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 11 Apr 2017 16:18:40 +0900 Subject: [PATCH] Fix blink API changes --- atom/browser/api/atom_api_web_contents.cc | 2 +- atom/browser/ui/webui/pdf_viewer_ui.cc | 3 +- .../native_mate_converters/blink_converter.cc | 34 +++++++++++-------- .../api/atom_api_spell_check_client.cc | 8 ++--- .../api/atom_api_spell_check_client.h | 8 +++-- atom/renderer/api/atom_api_web_frame.cc | 15 ++++---- atom/renderer/atom_render_frame_observer.cc | 4 +-- atom/renderer/atom_render_frame_observer.h | 5 --- atom/renderer/atom_renderer_client.cc | 3 +- atom/renderer/renderer_client_base.cc | 7 ---- .../media/native_desktop_media_list.cc | 2 ++ 11 files changed, 42 insertions(+), 49 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 38bda34e5d9f..8b46484b36e6 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -950,7 +950,7 @@ void WebContents::NavigationEntryCommitted( int64_t WebContents::GetID() const { int64_t process_id = web_contents()->GetRenderProcessHost()->GetID(); - int64_t routing_id = web_contents()->GetRoutingID(); + int64_t routing_id = web_contents()->GetRenderViewHost()->GetRoutingID(); int64_t rv = (process_id << 32) + routing_id; return rv; } diff --git a/atom/browser/ui/webui/pdf_viewer_ui.cc b/atom/browser/ui/webui/pdf_viewer_ui.cc index 580d1831e58b..c1b6dbfccfa8 100644 --- a/atom/browser/ui/webui/pdf_viewer_ui.cc +++ b/atom/browser/ui/webui/pdf_viewer_ui.cc @@ -134,7 +134,8 @@ class PdfViewerUI::ResourceRequester content::ResourceDispatcherHostImpl::Get()->InitializeURLRequest( request.get(), content::Referrer(url, blink::WebReferrerPolicyDefault), false, // download. - render_process_id, render_view_id, render_frame_id, resource_context); + render_process_id, render_view_id, render_frame_id, + content::PREVIEWS_OFF, resource_context); content::ResourceRequestInfoImpl* info = content::ResourceRequestInfoImpl::ForRequest(request.get()); diff --git a/atom/common/native_mate_converters/blink_converter.cc b/atom/common/native_mate_converters/blink_converter.cc index 5935c26899c7..6633ef887dc2 100644 --- a/atom/common/native_mate_converters/blink_converter.cc +++ b/atom/common/native_mate_converters/blink_converter.cc @@ -14,6 +14,8 @@ #include "content/public/browser/native_web_keyboard_event.h" #include "native_mate/dictionary.h" #include "third_party/WebKit/public/platform/WebInputEvent.h" +#include "third_party/WebKit/public/platform/WebMouseEvent.h" +#include "third_party/WebKit/public/platform/WebMouseWheelEvent.h" #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" #include "third_party/WebKit/public/web/WebFindOptions.h" #include "ui/base/clipboard/clipboard.h" @@ -148,12 +150,14 @@ bool Converter::FromV8( mate::Dictionary dict; if (!ConvertFromV8(isolate, val, &dict)) return false; - if (!dict.Get("type", &out->type)) + blink::WebInputEvent::Type type; + if (!dict.Get("type", &type)) return false; + out->setType(type); std::vector modifiers; if (dict.Get("modifiers", &modifiers)) - out->modifiers = VectorToBitArray(modifiers); - out->timeStampSeconds = base::Time::Now().ToDoubleT(); + out->setModifiers(VectorToBitArray(modifiers)); + out->setTimeStampSeconds(base::Time::Now().ToDoubleT()); return true; } @@ -174,19 +178,19 @@ bool Converter::FromV8( ui::KeyboardCode keyCode = atom::KeyboardCodeFromStr(str, &shifted); out->windowsKeyCode = keyCode; if (shifted) - out->modifiers |= blink::WebInputEvent::ShiftKey; + out->setModifiers(out->modifiers() | blink::WebInputEvent::ShiftKey); ui::DomCode domCode = ui::UsLayoutKeyboardCodeToDomCode(keyCode); out->domCode = static_cast(domCode); ui::DomKey domKey; ui::KeyboardCode dummy_code; - int flags = atom::WebEventModifiersToEventFlags(out->modifiers); + int flags = atom::WebEventModifiersToEventFlags(out->modifiers()); if (ui::DomCodeToUsLayoutDomKey(domCode, flags, &domKey, &dummy_code)) out->domKey = static_cast(domKey); - if ((out->type == blink::WebInputEvent::Char || - out->type == blink::WebInputEvent::RawKeyDown)) { + if ((out->type() == blink::WebInputEvent::Char || + out->type() == blink::WebInputEvent::RawKeyDown)) { // Make sure to not read beyond the buffer in case some bad code doesn't // NULL-terminate it (this is called from plugins). size_t text_length_cap = blink::WebKeyboardEvent::textLengthCap; @@ -218,20 +222,20 @@ v8::Local Converter::ToV8( v8::Isolate* isolate, const content::NativeWebKeyboardEvent& in) { mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); - if (in.type == blink::WebInputEvent::Type::RawKeyDown) + if (in.type() == blink::WebInputEvent::Type::RawKeyDown) dict.Set("type", "keyDown"); - else if (in.type == blink::WebInputEvent::Type::KeyUp) + else if (in.type() == blink::WebInputEvent::Type::KeyUp) dict.Set("type", "keyUp"); dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.domKey)); dict.Set("code", ui::KeycodeConverter::DomCodeToCodeString( static_cast(in.domCode))); using Modifiers = blink::WebInputEvent::Modifiers; - dict.Set("isAutoRepeat", (in.modifiers & Modifiers::IsAutoRepeat) != 0); - dict.Set("shift", (in.modifiers & Modifiers::ShiftKey) != 0); - dict.Set("control", (in.modifiers & Modifiers::ControlKey) != 0); - dict.Set("alt", (in.modifiers & Modifiers::AltKey) != 0); - dict.Set("meta", (in.modifiers & Modifiers::MetaKey) != 0); + dict.Set("isAutoRepeat", (in.modifiers() & Modifiers::IsAutoRepeat) != 0); + dict.Set("shift", (in.modifiers() & Modifiers::ShiftKey) != 0); + dict.Set("control", (in.modifiers() & Modifiers::ControlKey) != 0); + dict.Set("alt", (in.modifiers() & Modifiers::AltKey) != 0); + dict.Set("meta", (in.modifiers() & Modifiers::MetaKey) != 0); return dict.GetHandle(); } @@ -443,7 +447,7 @@ v8::Local Converter::ToV8( mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.Set("count", static_cast(stat.count)); dict.Set("size", static_cast(stat.size)); - dict.Set("liveSize", static_cast(stat.liveSize)); + dict.Set("liveSize", static_cast(stat.decodedSize)); return dict.GetHandle(); } diff --git a/atom/renderer/api/atom_api_spell_check_client.cc b/atom/renderer/api/atom_api_spell_check_client.cc index 9a07cbf6eaa4..8d434f1aa0ce 100644 --- a/atom/renderer/api/atom_api_spell_check_client.cc +++ b/atom/renderer/api/atom_api_spell_check_client.cc @@ -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* optional_suggestions) { std::vector 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& markersInText, - const blink::WebVector& markerOffsets, blink::WebTextCheckingCompletion* completionCallback) { - base::string16 text(textToCheck); + base::string16 text(textToCheck.utf16()); if (text.empty() || !HasWordCharacters(text, 0)) { completionCallback->didCancelCheckingText(); return; diff --git a/atom/renderer/api/atom_api_spell_check_client.h b/atom/renderer/api/atom_api_spell_check_client.h index aa6abb0f56b2..cb4a36aadf09 100644 --- a/atom/renderer/api/atom_api_spell_check_client.h +++ b/atom/renderer/api/atom_api_spell_check_client.h @@ -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* optionalSuggestions) override; void requestCheckingOfText( const blink::WebString& textToCheck, - const blink::WebVector& markersInText, - const blink::WebVector& markerOffsets, blink::WebTextCheckingCompletion* completionCallback) override; void showSpellingUI(bool show) override; bool isShowingSpellingUI() override; diff --git a/atom/renderer/api/atom_api_web_frame.cc b/atom/renderer/api/atom_api_web_frame.cc index f103b89391d3..77928724c05b 100644 --- a/atom/renderer/api/atom_api_web_frame.cc +++ b/atom/renderer/api/atom_api_web_frame.cc @@ -16,7 +16,7 @@ #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" @@ -110,7 +110,8 @@ void WebFrame::SetLayoutZoomLevelLimits(double min_level, double max_level) { v8::Local WebFrame::RegisterEmbedderCustomElement( const base::string16& name, v8::Local 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,9 +146,6 @@ 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)); } void WebFrame::RegisterURLSchemeAsBypassingCSP(const std::string& scheme) { @@ -200,7 +198,10 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& 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::WebRange(), + 0); } void WebFrame::InsertCSS(const std::string& css) { @@ -216,7 +217,7 @@ void WebFrame::ExecuteJavaScript(const base::string16& code, std::unique_ptr callback( new ScriptExecutionCallback(completion_callback)); web_frame_->requestExecuteScriptAndReturnValue( - blink::WebScriptSource(code), + blink::WebScriptSource(blink::WebString::fromUTF16(code)), has_user_gesture, callback.release()); } diff --git a/atom/renderer/atom_render_frame_observer.cc b/atom/renderer/atom_render_frame_observer.cc index d9a41a48d4a9..3912a7bcc6dd 100644 --- a/atom/renderer/atom_render_frame_observer.cc +++ b/atom/renderer/atom_render_frame_observer.cc @@ -24,7 +24,6 @@ void AtomRenderFrameObserver::DidClearWindowObject() { void AtomRenderFrameObserver::DidCreateScriptContext( v8::Handle 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) { diff --git a/atom/renderer/atom_render_frame_observer.h b/atom/renderer/atom_render_frame_observer.h index 51cb21b3b0e7..6eeb32aac03f 100644 --- a/atom/renderer/atom_render_frame_observer.h +++ b/atom/renderer/atom_render_frame_observer.h @@ -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 context, - int extension_group, int world_id) override; void WillReleaseScriptContext(v8::Local context, int world_id) override; diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 5dafe084ce27..1ce17193dff9 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -172,8 +172,7 @@ void AtomRendererClient::WillDestroyWorkerContextOnWorkerThread( v8::Local 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(); } diff --git a/atom/renderer/renderer_client_base.cc b/atom/renderer/renderer_client_base.cc index 4d3675e2f6f6..8a4ed82f07c0 100644 --- a/atom/renderer/renderer_client_base.cc +++ b/atom/renderer/renderer_client_base.cc @@ -126,13 +126,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 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) { diff --git a/chromium_src/chrome/browser/media/native_desktop_media_list.cc b/chromium_src/chrome/browser/media/native_desktop_media_list.cc index 391bdd50a313..4a9c0e03c8b0 100644 --- a/chromium_src/chrome/browser/media/native_desktop_media_list.cc +++ b/chromium_src/chrome/browser/media/native_desktop_media_list.cc @@ -8,6 +8,8 @@ #include #include +using base::PlatformThreadRef; + #include "base/hash.h" #include "base/logging.h" #include "base/strings/string_number_conversions.h"