2015-07-16 23:40:01 +02:00
|
|
|
// Copyright 2015 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "libcef/browser/extensions/extensions_api_client.h"
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
#include "include/internal/cef_types_wrappers.h"
|
2019-03-22 23:11:51 +01:00
|
|
|
#include "libcef/browser/browser_context.h"
|
2021-08-19 21:05:52 +02:00
|
|
|
#include "libcef/browser/extensions/api/file_system/cef_file_system_delegate.h"
|
2017-09-11 20:42:30 +02:00
|
|
|
#include "libcef/browser/extensions/api/storage/sync_value_store_cache.h"
|
2015-07-24 02:06:56 +02:00
|
|
|
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/browser/extensions/mime_handler_view_guest_delegate.h"
|
2015-07-24 02:06:56 +02:00
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
#include "base/memory/ptr_util.h"
|
2022-10-12 23:53:06 +02:00
|
|
|
#include "chrome/browser/printing/print_view_manager.h"
|
2015-10-17 02:44:00 +02:00
|
|
|
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
2016-07-20 20:03:38 +02:00
|
|
|
#include "components/zoom/zoom_controller.h"
|
2015-11-10 21:18:16 +01:00
|
|
|
#include "extensions/browser/guest_view/extensions_guest_view_manager_delegate.h"
|
2021-07-23 18:40:13 +02:00
|
|
|
#include "printing/mojom/print.mojom.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
CefExtensionsAPIClient::CefExtensionsAPIClient() {}
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
AppViewGuestDelegate* CefExtensionsAPIClient::CreateAppViewGuestDelegate()
|
|
|
|
const {
|
|
|
|
// TODO(extensions): Implement to support Apps.
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false);
|
2020-01-15 14:36:24 +01:00
|
|
|
return nullptr;
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<guest_view::GuestViewManagerDelegate>
|
2023-07-21 00:11:34 +02:00
|
|
|
CefExtensionsAPIClient::CreateGuestViewManagerDelegate() const {
|
2015-11-10 21:18:16 +01:00
|
|
|
// The GuestViewManager instance associated with the returned Delegate, which
|
|
|
|
// will be retrieved in the future via GuestViewManager::FromBrowserContext,
|
2019-03-22 23:11:51 +01:00
|
|
|
// will be associated with the CefBrowserContext.
|
2023-07-21 00:11:34 +02:00
|
|
|
return base::WrapUnique(new extensions::ExtensionsGuestViewManagerDelegate());
|
2015-11-10 21:18:16 +01:00
|
|
|
}
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<MimeHandlerViewGuestDelegate>
|
2015-07-16 23:40:01 +02:00
|
|
|
CefExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
|
|
|
|
MimeHandlerViewGuest* guest) const {
|
2016-05-25 01:35:43 +02:00
|
|
|
return base::WrapUnique(new CefMimeHandlerViewGuestDelegate(guest));
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
void CefExtensionsAPIClient::AttachWebContentsHelpers(
|
|
|
|
content::WebContents* web_contents) const {
|
2015-10-17 02:44:00 +02:00
|
|
|
PrefsTabHelper::CreateForWebContents(web_contents);
|
2022-10-12 23:53:06 +02:00
|
|
|
printing::PrintViewManager::CreateForWebContents(web_contents);
|
2016-07-20 20:03:38 +02:00
|
|
|
|
|
|
|
// Used by the tabs extension API.
|
|
|
|
zoom::ZoomController::CreateForWebContents(web_contents);
|
2015-07-24 02:06:56 +02:00
|
|
|
}
|
|
|
|
|
2017-09-11 20:42:30 +02:00
|
|
|
void CefExtensionsAPIClient::AddAdditionalValueStoreCaches(
|
|
|
|
content::BrowserContext* context,
|
2021-09-20 11:06:23 +02:00
|
|
|
const scoped_refptr<value_store::ValueStoreFactory>& factory,
|
2022-03-26 02:12:30 +01:00
|
|
|
SettingsChangedCallback observer,
|
2017-09-11 20:42:30 +02:00
|
|
|
std::map<settings_namespace::Namespace, ValueStoreCache*>* caches) {
|
|
|
|
// Add support for chrome.storage.sync.
|
|
|
|
// Because we don't support syncing with Google, we follow the behavior of
|
|
|
|
// chrome.storage.sync as if Chrome were permanently offline, by using a local
|
|
|
|
// store see: https://developer.chrome.com/apps/storage for more information
|
|
|
|
(*caches)[settings_namespace::SYNC] = new cef::SyncValueStoreCache(factory);
|
|
|
|
}
|
|
|
|
|
2021-08-19 21:05:52 +02:00
|
|
|
FileSystemDelegate* CefExtensionsAPIClient::GetFileSystemDelegate() {
|
2023-01-02 23:59:03 +01:00
|
|
|
if (!file_system_delegate_) {
|
2021-08-19 21:05:52 +02:00
|
|
|
file_system_delegate_ = std::make_unique<cef::CefFileSystemDelegate>();
|
2023-01-02 23:59:03 +01:00
|
|
|
}
|
2021-08-19 21:05:52 +02:00
|
|
|
return file_system_delegate_.get();
|
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
} // namespace extensions
|