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"
|
2015-11-10 21:18:16 +01:00
|
|
|
#include "libcef/browser/browser_context_impl.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
|
|
|
#include "libcef/browser/extensions/pdf_web_contents_helper_client.h"
|
|
|
|
#include "libcef/browser/printing/print_view_manager.h"
|
|
|
|
|
2015-10-17 02:44:00 +02:00
|
|
|
#include "chrome/browser/ui/prefs/prefs_tab_helper.h"
|
2015-07-24 02:06:56 +02:00
|
|
|
#include "components/pdf/browser/pdf_web_contents_helper.h"
|
2015-11-10 21:18:16 +01:00
|
|
|
#include "extensions/browser/guest_view/extensions_guest_view_manager_delegate.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
|
|
|
CefExtensionsAPIClient::CefExtensionsAPIClient() {
|
|
|
|
}
|
|
|
|
|
|
|
|
AppViewGuestDelegate* CefExtensionsAPIClient::CreateAppViewGuestDelegate()
|
|
|
|
const {
|
|
|
|
// TODO(extensions): Implement to support Apps.
|
|
|
|
NOTREACHED();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<guest_view::GuestViewManagerDelegate>
|
2015-11-10 21:18:16 +01:00
|
|
|
CefExtensionsAPIClient::CreateGuestViewManagerDelegate(
|
|
|
|
content::BrowserContext* context) const {
|
|
|
|
// The GuestViewManager instance associated with the returned Delegate, which
|
|
|
|
// will be retrieved in the future via GuestViewManager::FromBrowserContext,
|
|
|
|
// will be associated with the CefBrowserContextImpl instead of |context| due
|
|
|
|
// to ShouldProxyUserData in browser_context_proxy.cc. Because the
|
|
|
|
// GuestViewManagerDelegate keeps a reference to the passed-in context we need
|
|
|
|
// to provide the *Impl object instead of |context| which may be a *Proxy
|
|
|
|
// object. If we don't do this then the Delegate may attempt to access a
|
|
|
|
// *Proxy object that has already been deleted.
|
|
|
|
return make_scoped_ptr(
|
|
|
|
new extensions::ExtensionsGuestViewManagerDelegate(
|
|
|
|
CefBrowserContextImpl::GetForContext(context).get()));
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
return make_scoped_ptr(new CefMimeHandlerViewGuestDelegate(guest));
|
|
|
|
}
|
|
|
|
|
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);
|
2015-07-24 02:06:56 +02:00
|
|
|
printing::PrintViewManager::CreateForWebContents(web_contents);
|
|
|
|
pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
|
|
|
|
web_contents,
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<pdf::PDFWebContentsHelperClient>(
|
2015-07-24 02:06:56 +02:00
|
|
|
new CefPDFWebContentsHelperClient()));
|
|
|
|
CefExtensionWebContentsObserver::CreateForWebContents(web_contents);
|
|
|
|
}
|
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
} // namespace extensions
|