diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2018-01-23 10:36:52 +0100 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2018-01-29 08:22:49 +0000 |
commit | eb80f23942b5b4bef4285dc4b6bea5c226813b37 (patch) | |
tree | 4704788af5aeb9d6b004c0cea4925b7cc5dba4ea | |
parent | 3541bcae07fcea351a103d0ccbdef7526683de66 (diff) | |
download | qtwebengine-chromium-eb80f23942b5b4bef4285dc4b6bea5c226813b37.tar.gz |
Adapt ProtocolHandlerRegistry for WebEngine
Disable persistence, OS integration and Chrome-specific features.
Task-number: QTBUG-62783
Change-Id: I33d8c3a59de9876a466aacada7e5d5c307352d14
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
3 files changed, 33 insertions, 3 deletions
diff --git a/chromium/chrome/browser/custom_handlers/protocol_handler_registry.cc b/chromium/chrome/browser/custom_handlers/protocol_handler_registry.cc index 608da379d81..2d8f3249eb8 100755 --- a/chromium/chrome/browser/custom_handlers/protocol_handler_registry.cc +++ b/chromium/chrome/browser/custom_handlers/protocol_handler_registry.cc @@ -18,7 +18,6 @@ #include "base/stl_util.h" #include "build/build_config.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/profiles/profile_io_data.h" #include "chrome/common/custom_handlers/protocol_handler.h" #include "chrome/common/pref_names.h" #include "chrome/grit/generated_resources.h" @@ -47,6 +46,7 @@ const ProtocolHandler& LookupHandler( return ProtocolHandler::EmptyProtocolHandler(); } +#if !defined(TOOLKIT_QT) // If true default protocol handlers will be removed if the OS level // registration for a protocol is no longer Chrome. bool ShouldRemoveHandlersNotInOS() { @@ -61,6 +61,7 @@ bool ShouldRemoveHandlersNotInOS() { shell_integration::SET_DEFAULT_NOT_ALLOWED; #endif } +#endif } // namespace @@ -246,28 +247,36 @@ bool ProtocolHandlerRegistry::Delegate::IsExternalHandlerRegistered( const std::string& protocol) { // NOTE(koz): This function is safe to call from any thread, despite living // in ProfileIOData. +#if defined(TOOLKIT_QT) + return net::URLRequest::IsHandledProtocol(protocol); +#else return ProfileIOData::IsHandledProtocol(protocol); +#endif } void ProtocolHandlerRegistry::Delegate::RegisterWithOSAsDefaultClient( const std::string& protocol, ProtocolHandlerRegistry* registry) { +#if !defined(TOOLKIT_QT) // The worker pointer is reference counted. While it is running, the // sequence it runs on will hold references it will be automatically freed // once all its tasks have finished. base::MakeRefCounted<shell_integration::DefaultProtocolClientWorker>( registry->GetDefaultWebClientCallback(protocol), protocol) ->StartSetAsDefault(); +#endif } void ProtocolHandlerRegistry::Delegate::CheckDefaultClientWithOS( const std::string& protocol, ProtocolHandlerRegistry* registry) { +#if !defined(TOOLKIT_QT) // The worker pointer is reference counted. While it is running, the // sequence it runs on will hold references it will be automatically freed // once all its tasks have finished. base::MakeRefCounted<shell_integration::DefaultProtocolClientWorker>( registry->GetDefaultWebClientCallback(protocol), protocol) ->StartCheckIsDefault(); +#endif } // ProtocolHandlerRegistry ----------------------------------------------------- @@ -392,6 +401,7 @@ void ProtocolHandlerRegistry::InstallDefaultsForChromeOS() { } void ProtocolHandlerRegistry::InitProtocolSettings() { +#if !defined(TOOLKIT_QT) DCHECK_CURRENTLY_ON(BrowserThread::UI); // Any further default additions to the table will get rejected from now on. @@ -423,6 +433,7 @@ void ProtocolHandlerRegistry::InitProtocolSettings() { delegate_->CheckDefaultClientWithOS(p->second.protocol(), this); } } +#endif } int ProtocolHandlerRegistry::GetHandlerIndex(const std::string& scheme) const { @@ -660,11 +671,13 @@ void ProtocolHandlerRegistry::Shutdown() { // static void ProtocolHandlerRegistry::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { +#if !defined(TOOLKIT_QT) registry->RegisterListPref(prefs::kRegisteredProtocolHandlers); registry->RegisterListPref(prefs::kIgnoredProtocolHandlers); registry->RegisterListPref(prefs::kPolicyRegisteredProtocolHandlers); registry->RegisterListPref(prefs::kPolicyIgnoredProtocolHandlers); registry->RegisterBooleanPref(prefs::kCustomHandlersEnabled, true); +#endif } ProtocolHandlerRegistry::~ProtocolHandlerRegistry() { @@ -682,6 +695,7 @@ void ProtocolHandlerRegistry::PromoteHandler(const ProtocolHandler& handler) { } void ProtocolHandlerRegistry::Save() { +#if !defined(TOOLKIT_QT) DCHECK_CURRENTLY_ON(BrowserThread::UI); if (is_loading_) { return; @@ -697,6 +711,7 @@ void ProtocolHandlerRegistry::Save() { prefs->Set(prefs::kIgnoredProtocolHandlers, *ignored_protocol_handlers); prefs->SetBoolean(prefs::kCustomHandlersEnabled, enabled_); +#endif } const ProtocolHandlerRegistry::ProtocolHandlerList* @@ -800,6 +815,7 @@ void ProtocolHandlerRegistry::RegisterProtocolHandler( std::vector<const base::DictionaryValue*> ProtocolHandlerRegistry::GetHandlersFromPref(const char* pref_name) const { +#if !defined(TOOLKIT_QT) DCHECK_CURRENTLY_ON(BrowserThread::UI); std::vector<const base::DictionaryValue*> result; PrefService* prefs = user_prefs::UserPrefs::Get(context_); @@ -819,6 +835,10 @@ ProtocolHandlerRegistry::GetHandlersFromPref(const char* pref_name) const { } } return result; +#else + NOTREACHED(); + return {}; +#endif } void ProtocolHandlerRegistry::RegisterProtocolHandlersFromPref( @@ -886,6 +906,7 @@ void ProtocolHandlerRegistry::EraseHandler(const ProtocolHandler& handler, list->erase(std::find(list->begin(), list->end(), handler)); } +#if !defined(TOOLKIT_QT) void ProtocolHandlerRegistry::OnSetAsDefaultProtocolClientFinished( const std::string& protocol, shell_integration::DefaultWebClientState state) { @@ -896,6 +917,7 @@ void ProtocolHandlerRegistry::OnSetAsDefaultProtocolClientFinished( ClearDefault(protocol); } } +#endif void ProtocolHandlerRegistry::AddPredefinedHandler( const ProtocolHandler& handler) { @@ -904,6 +926,7 @@ void ProtocolHandlerRegistry::AddPredefinedHandler( SetDefault(handler); } +#if !defined(TOOLKIT_QT) shell_integration::DefaultWebClientWorkerCallback ProtocolHandlerRegistry::GetDefaultWebClientCallback( const std::string& protocol) { @@ -911,6 +934,7 @@ ProtocolHandlerRegistry::GetDefaultWebClientCallback( &ProtocolHandlerRegistry::OnSetAsDefaultProtocolClientFinished, weak_ptr_factory_.GetWeakPtr(), protocol); } +#endif std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> ProtocolHandlerRegistry::CreateJobInterceptorFactory() { diff --git a/chromium/chrome/browser/custom_handlers/protocol_handler_registry.h b/chromium/chrome/browser/custom_handlers/protocol_handler_registry.h index 92608305bab..127e5ede90f 100755 --- a/chromium/chrome/browser/custom_handlers/protocol_handler_registry.h +++ b/chromium/chrome/browser/custom_handlers/protocol_handler_registry.h @@ -15,7 +15,6 @@ #include "base/sequenced_task_runner_helpers.h" #include "base/values.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/shell_integration.h" #include "chrome/common/custom_handlers/protocol_handler.h" #include "components/keyed_service/core/keyed_service.h" #include "content/public/browser/browser_thread.h" @@ -227,10 +226,12 @@ class ProtocolHandlerRegistry : public KeyedService { // load command was issued, otherwise the command will be ignored. void AddPredefinedHandler(const ProtocolHandler& handler); +#if !defined(TOOLKIT_QT) // Gets the callback for DefaultProtocolClientWorker. Allows the Delegate to // create the worker on behalf of ProtocolHandlerRegistry. shell_integration::DefaultWebClientWorkerCallback GetDefaultWebClientCallback( const std::string& protocol); +#endif private: friend class base::DeleteHelper<ProtocolHandlerRegistry>; @@ -311,11 +312,13 @@ class ProtocolHandlerRegistry : public KeyedService { // Erases the handler that is guaranteed to exist from the list. void EraseHandler(const ProtocolHandler& handler, ProtocolHandlerList* list); +#if !defined(TOOLKIT_QT) // Called with the default state when the default protocol client worker is // done. void OnSetAsDefaultProtocolClientFinished( const std::string& protocol, shell_integration::DefaultWebClientState state); +#endif // Map from protocols (strings) to protocol handlers. ProtocolHandlerMultiMap protocol_handlers_; diff --git a/chromium/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc b/chromium/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc index 4f725d2c254..33a5fa7cbf9 100755 --- a/chromium/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc +++ b/chromium/chrome/browser/custom_handlers/protocol_handler_registry_factory.cc @@ -7,7 +7,6 @@ #include "base/memory/singleton.h" #include "build/build_config.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" -#include "chrome/browser/profiles/incognito_helpers.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" // static @@ -42,7 +41,11 @@ ProtocolHandlerRegistryFactory::ServiceIsCreatedWithBrowserContext() const { // Allows the produced registry to be used in incognito mode. content::BrowserContext* ProtocolHandlerRegistryFactory::GetBrowserContextToUse( content::BrowserContext* context) const { +#if defined(TOOLKIT_QT) + return context; +#else return chrome::GetBrowserContextRedirectedInIncognito(context); +#endif } // Do not create this service for tests. MANY tests will fail |