From d0a34e679e094759ee6d61b6da711cb2b2ed5294 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 21 Mar 2017 15:10:18 +0100 Subject: Register a Mojo SensitiveInputVisibilityService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't use or need the service, but Mojo doesn't like when it doesn't get to do pointless things. Change-Id: I1be66d1679bf688aa0139e84822de32a28ba3132 Reviewed-by: Michael BrĂ¼ning --- src/core/content_browser_client_qt.cpp | 61 ++++++++++++++++++++++++++++++++++ src/core/content_browser_client_qt.h | 7 ++++ 2 files changed, 68 insertions(+) diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 8dbfc8ab2..1ae6f1307 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -59,11 +59,16 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/resource_dispatcher_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_user_data.h" #include "content/public/common/content_switches.h" #include "content/public/common/main_function_params.h" #include "content/public/common/url_constants.h" #include "device/geolocation/geolocation_delegate.h" #include "device/geolocation/geolocation_provider.h" +#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/bindings/binding_set.h" +#include "services/service_manager/public/cpp/interface_registry.h" +#include "third_party/WebKit/public/platform/modules/sensitive_input_visibility/sensitive_input_visibility_service.mojom.h" #include "ui/base/ui_base_switches.h" #include "ui/display/screen.h" #include "ui/gl/gl_context.h" @@ -526,4 +531,60 @@ content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDele return new DevToolsManagerDelegateQt; } +// This is a really complicated way of doing absolutely nothing, but Mojo demands it: +class ServiceDriver + : public blink::mojom::SensitiveInputVisibilityService + , public content::WebContentsUserData +{ +public: + static void CreateForRenderFrameHost(content::RenderFrameHost *renderFrameHost) + { + content::WebContents* web_contents = content::WebContents::FromRenderFrameHost(renderFrameHost); + if (!web_contents) + return; + CreateForWebContents(web_contents); + + } + static ServiceDriver* FromRenderFrameHost(content::RenderFrameHost *renderFrameHost) + { + content::WebContents* web_contents = content::WebContents::FromRenderFrameHost(renderFrameHost); + if (!web_contents) + return nullptr; + return FromWebContents(web_contents); + } + static void BindSensitiveInputVisibilityService(content::RenderFrameHost* render_frame_host, + blink::mojom::SensitiveInputVisibilityServiceRequest request) + { + CreateForRenderFrameHost(render_frame_host); + ServiceDriver *driver = FromRenderFrameHost(render_frame_host); + + if (driver) + driver->BindSensitiveInputVisibilityServiceInternal(std::move(request)); + } + void BindSensitiveInputVisibilityServiceInternal(blink::mojom::SensitiveInputVisibilityServiceRequest request) + { + m_sensitiveInputVisibilityBindings.AddBinding(this, std::move(request)); + } + + // blink::mojom::SensitiveInputVisibility: + void PasswordFieldVisibleInInsecureContext() override + { } + void AllPasswordFieldsInInsecureContextInvisible() override + { } + +private: + explicit ServiceDriver(content::WebContents* /*web_contents*/) { } + friend class content::WebContentsUserData; + mojo::BindingSet m_sensitiveInputVisibilityBindings; + +}; + +void ContentBrowserClientQt::RegisterRenderFrameMojoInterfaces(service_manager::InterfaceRegistry* registry, + content::RenderFrameHost* render_frame_host) +{ + registry->AddInterface(base::Bind(&ServiceDriver::BindSensitiveInputVisibilityService, render_frame_host)); +} + } // namespace QtWebEngineCore + +DEFINE_WEB_CONTENTS_USER_DATA_KEY(QtWebEngineCore::ServiceDriver); diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h index b20175439..80ae6057e 100644 --- a/src/core/content_browser_client_qt.h +++ b/src/core/content_browser_client_qt.h @@ -58,6 +58,7 @@ class BrowserPpapiHost; #endif class DevToolsManagerDelegate; +class RenderFrameHost; class RenderProcessHost; class RenderViewHostDelegateView; class ResourceContext; @@ -70,6 +71,10 @@ namespace gl { class GLShareGroup; } +namespace service_manager { +class InterfaceRegistry; +} + namespace QtWebEngineCore { class BrowserContextQt; class BrowserMainPartsQt; @@ -108,6 +113,8 @@ public: virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) Q_DECL_OVERRIDE; virtual void GetAdditionalWebUISchemes(std::vector* additional_schemes) Q_DECL_OVERRIDE; + void RegisterRenderFrameMojoInterfaces(service_manager::InterfaceRegistry* registry, content::RenderFrameHost* render_frame_host) override; + #if defined(Q_OS_LINUX) virtual void GetAdditionalMappedFilesForChildProcess(const base::CommandLine& command_line, int child_process_id, content::FileDescriptorInfo* mappings) Q_DECL_OVERRIDE; #endif -- cgit v1.2.3