1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtWebEngine module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef PROFILE_QT_H 41 #define PROFILE_QT_H 42 43 #include "chrome/browser/profiles/profile.h" 44 #include "content/public/browser/content_browser_client.h" 45 #include "content/public/browser/resource_context.h" 46 #include "extensions/buildflags/buildflags.h" 47 #include "pref_service_adapter.h" 48 #include "profile_io_data_qt.h" 49 #include <QtGlobal> 50 51 QT_BEGIN_NAMESPACE 52 class QStringList; 53 QT_END_NAMESPACE 54 class InMemoryPrefStore; 55 class PrefService; 56 57 namespace extensions { 58 class ExtensionSystemQt; 59 } 60 61 namespace QtWebEngineCore { 62 63 class BrowsingDataRemoverDelegateQt; 64 class ProfileAdapter; 65 class PermissionManagerQt; 66 class SSLHostStateDelegateQt; 67 68 class ProfileQt : public Profile 69 { 70 public: 71 explicit ProfileQt(ProfileAdapter *profileAdapter); 72 73 virtual ~ProfileQt(); 74 75 base::FilePath GetCachePath() const; 76 77 // BrowserContext implementation: 78 base::FilePath GetPath() override; 79 bool IsOffTheRecord() override; 80 81 content::ResourceContext *GetResourceContext() override; 82 content::DownloadManagerDelegate *GetDownloadManagerDelegate() override; 83 content::BrowserPluginGuestManager *GetGuestManager() override; 84 storage::SpecialStoragePolicy *GetSpecialStoragePolicy() override; 85 content::PushMessagingService *GetPushMessagingService() override; 86 content::SSLHostStateDelegate *GetSSLHostStateDelegate() override; 87 std::unique_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate( 88 const base::FilePath &partition_path) override; 89 content::PermissionControllerDelegate * GetPermissionControllerDelegate() override; 90 content::BackgroundFetchDelegate *GetBackgroundFetchDelegate() override; 91 content::BackgroundSyncController *GetBackgroundSyncController() override; 92 content::BrowsingDataRemoverDelegate *GetBrowsingDataRemoverDelegate() override; 93 content::ClientHintsControllerDelegate *GetClientHintsControllerDelegate() override; 94 content::StorageNotificationService *GetStorageNotificationService() override; 95 void SetCorsOriginAccessListForOrigin(const url::Origin &source_origin, 96 std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns, 97 std::vector<network::mojom::CorsOriginPatternPtr> block_patterns, 98 base::OnceClosure closure) override; 99 content::SharedCorsOriginAccessList *GetSharedCorsOriginAccessList() override; 100 std::string GetMediaDeviceIDSalt() override; 101 102 // Profile implementation: 103 PrefService *GetPrefs() override; 104 const PrefService *GetPrefs() const override; 105 106 void Initialize(); profileAdapter()107 ProfileAdapter *profileAdapter() { return m_profileAdapter; } 108 109 content::PlatformNotificationService *platformNotificationService(); 110 111 #if QT_CONFIG(webengine_spellchecker) 112 void FailedToLoadDictionary(const std::string &language) override; 113 #endif 114 #if BUILDFLAG(ENABLE_EXTENSIONS) 115 extensions::ExtensionSystemQt* GetExtensionSystem(); 116 #endif // defined(ENABLE_EXTENSIONS) 117 118 // Build/Re-build the preference service. Call when updating the storage 119 // data path. 120 void setupPrefService(); 121 122 PrefServiceAdapter &prefServiceAdapter(); 123 124 const PrefServiceAdapter &prefServiceAdapter() const; 125 126 private: 127 friend class ContentBrowserClientQt; 128 friend class ProfileIODataQt; 129 friend class WebContentsAdapter; 130 std::unique_ptr<BrowsingDataRemoverDelegateQt> m_removerDelegate; 131 std::unique_ptr<PermissionManagerQt> m_permissionManager; 132 std::unique_ptr<SSLHostStateDelegateQt> m_sslHostStateDelegate; 133 scoped_refptr<content::SharedCorsOriginAccessList> m_sharedCorsOriginAccessList; 134 std::unique_ptr<ProfileIODataQt> m_profileIOData; 135 std::unique_ptr<content::PlatformNotificationService> m_platformNotificationService; 136 ProfileAdapter *m_profileAdapter; 137 PrefServiceAdapter m_prefServiceAdapter; 138 139 friend class ProfileAdapter; 140 #if BUILDFLAG(ENABLE_EXTENSIONS) 141 extensions::ExtensionSystemQt *m_extensionSystem; 142 #endif //ENABLE_EXTENSIONS 143 friend class BrowserContextAdapter; 144 145 DISALLOW_COPY_AND_ASSIGN(ProfileQt); 146 }; 147 148 } // namespace QtWebEngineCore 149 150 #endif // PROFILE_QT_H 151