diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-30 17:23:41 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-03-15 16:52:17 +0000 |
commit | d5bffb5125da23718e8098441b4a4269a5cf2f33 (patch) | |
tree | 48a39ba7f833116cba7dcc7917d13d34a062949c /src/core/content_browser_client_qt.cpp | |
parent | 789f375411b542db3ac3be79cbe0a6153720abf1 (diff) |
Basic adaptations for 64-based
Change-Id: I11e2da206e4e59872a38c178f57a5879c1bbf229
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src/core/content_browser_client_qt.cpp')
-rw-r--r-- | src/core/content_browser_client_qt.cpp | 113 |
1 files changed, 68 insertions, 45 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 446764f19..18d0ff1c9 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -39,6 +39,7 @@ #include "content_browser_client_qt.h" +#include "base/json/json_reader.h" #include "base/memory/ptr_util.h" #include "base/message_loop/message_loop.h" #include "base/threading/thread_restrictions.h" @@ -64,15 +65,15 @@ #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/service_names.mojom.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 "printing/features/features.h" #include "net/ssl/client_cert_identity.h" #include "services/service_manager/public/cpp/bind_source_info.h" #include "services/service_manager/public/cpp/binder_registry.h" +#include "services/service_manager/public/cpp/service.h" #include "third_party/WebKit/public/platform/modules/insecure_input/insecure_input_service.mojom.h" #include "ui/base/ui_base_switches.h" #include "ui/display/screen.h" @@ -81,7 +82,8 @@ #include "ui/gl/gl_share_group.h" #include "ui/gl/gpu_timing.h" -#include "access_token_store_qt.h" +#include "chrome/grit/qt_webengine_resources.h" + #include "browser_context_adapter.h" #include "browser_context_qt.h" #include "browser_message_filter_qt.h" @@ -89,11 +91,6 @@ #include "certificate_error_controller_p.h" #include "desktop_screen_qt.h" #include "devtools_manager_delegate_qt.h" -#ifdef QT_USE_POSITIONING -#include "location_provider_qt.h" -#else -#include "device/geolocation/location_provider.h" -#endif #include "media_capture_devices_dispatcher.h" #include "network_delegate_qt.h" #if BUILDFLAG(ENABLE_BASIC_PRINTING) @@ -249,28 +246,6 @@ std::unique_ptr<base::MessagePump> messagePumpFactory() return base::WrapUnique(new MessagePumpForUIQt); } -// A provider of services needed by Geolocation. -class GeolocationDelegateQt : public device::GeolocationDelegate { -public: - GeolocationDelegateQt() {} - scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() final - { - return scoped_refptr<device::AccessTokenStore>(new AccessTokenStoreQt); - } - - std::unique_ptr<device::LocationProvider> OverrideSystemLocationProvider() final - { -#ifdef QT_USE_POSITIONING - return base::WrapUnique(new LocationProviderQt); -#else - return nullptr; -#endif - } - -private: - DISALLOW_COPY_AND_ASSIGN(GeolocationDelegateQt); -}; - } // anonymous namespace class BrowserMainPartsQt : public content::BrowserMainParts @@ -285,11 +260,6 @@ public: base::MessageLoop::InitMessagePumpForUIFactory(messagePumpFactory); } - void PreMainMessageLoopRun() override - { - device::GeolocationProvider::SetGeolocationDelegate(new GeolocationDelegateQt()); - } - void PostMainMessageLoopRun() override { // The BrowserContext's destructor uses the MessageLoop so it should be deleted @@ -620,19 +590,72 @@ void ContentBrowserClientQt::BindInterfaceRequestFromFrame(content::RenderFrameH m_frameInterfaces->TryBindInterface(interface_name, &interface_pipe); } -void ContentBrowserClientQt::ExposeInterfacesToRenderer(service_manager::BinderRegistry *registry, - content::AssociatedInterfaceRegistry */*associated_registry*/, - content::RenderProcessHost *render_process_host) +class ServiceQt : public service_manager::Service { +public: + ServiceQt(); + + static std::unique_ptr<service_manager::Service> Create() + { + return base::MakeUnique<ServiceQt>(); + } + +private: + // service_manager::Service: + void OnBindInterface(const service_manager::BindSourceInfo& remote_info, + const std::string& name, + mojo::ScopedMessagePipeHandle handle) override; + + service_manager::BinderRegistry m_registry; + service_manager::BinderRegistryWithArgs<const service_manager::BindSourceInfo&> m_registry_with_source_info; + + DISALLOW_COPY_AND_ASSIGN(ServiceQt); +}; + +ServiceQt::ServiceQt() { + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); #if BUILDFLAG(ENABLE_SPELLCHECK) - registry->AddInterface(base::Bind(&SpellCheckHostImpl::Create, render_process_host->GetID()), - content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::UI)); -#else - Q_UNUSED(registry); - Q_UNUSED(render_process_host); + m_registry_with_source_info.AddInterface( + base::Bind(&SpellCheckHostImpl::Create), + content::BrowserThread::GetTaskRunnerForThread(content::BrowserThread::UI)); #endif } +void ServiceQt::OnBindInterface(const service_manager::BindSourceInfo& remote_info, + const std::string& name, + mojo::ScopedMessagePipeHandle handle) +{ + content::OverrideOnBindInterface(remote_info, name, &handle); + if (!handle.is_valid()) + return; + + if (!m_registry.TryBindInterface(name, &handle)) + m_registry_with_source_info.TryBindInterface(name, &handle, remote_info); +} + +void ContentBrowserClientQt::RegisterInProcessServices(StaticServiceMap* services) +{ + service_manager::EmbeddedServiceInfo info; + info.factory = base::Bind(&ServiceQt::Create); + services->insert(std::make_pair("qtwebengine", info)); +} + +std::unique_ptr<base::Value> ContentBrowserClientQt::GetServiceManifestOverlay(base::StringPiece name) +{ + ui::ResourceBundle &rb = ui::ResourceBundle::GetSharedInstance(); + int id = -1; + if (name == content::mojom::kPackagedServicesServiceName) + id = IDR_QTWEBENGINE_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY; + else if (name == content::mojom::kRendererServiceName) + id = IDR_QTWEBENGINE_CONTENT_RENDERER_MANIFEST_OVERLAY; + if (id == -1) + return nullptr; + + base::StringPiece manifest_contents = + rb.GetRawDataResourceForScale(id, ui::ScaleFactor::SCALE_FACTOR_NONE); + return base::JSONReader::Read(manifest_contents); +} + bool ContentBrowserClientQt::CanCreateWindow( content::RenderFrameHost* opener, const GURL& opener_url, @@ -688,14 +711,14 @@ bool ContentBrowserClientQt::AllowGetCookie(const GURL &url, bool ContentBrowserClientQt::AllowSetCookie(const GURL &url, const GURL &first_party, - const std::string &cookie_line, + const net::CanonicalCookie& /*cookie*/, content::ResourceContext *context, int /*render_process_id*/, int /*render_frame_id*/, const net::CookieOptions& /*options*/) { NetworkDelegateQt *networkDelegate = static_cast<NetworkDelegateQt *>(context->GetRequestContext()->network_delegate()); - return networkDelegate->canSetCookies(first_party, url, cookie_line); + return networkDelegate->canSetCookies(first_party, url, std::string()); } } // namespace QtWebEngineCore |