2020-01-13 22:55:58 +00:00
|
|
|
// Copyright (c) 2019 Slack Technologies, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "shell/browser/extensions/electron_extensions_api_client.h"
|
|
|
|
|
|
|
|
#include <memory>
|
2020-02-13 00:39:12 +00:00
|
|
|
#include <string>
|
2020-01-13 22:55:58 +00:00
|
|
|
|
2020-09-16 22:15:01 +00:00
|
|
|
#include "electron/buildflags/buildflags.h"
|
2020-02-13 00:39:12 +00:00
|
|
|
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h"
|
2020-08-17 15:25:20 +00:00
|
|
|
#include "printing/buildflags/buildflags.h"
|
2020-09-02 00:59:56 +00:00
|
|
|
#include "shell/browser/extensions/api/management/electron_management_api_delegate.h"
|
2020-02-03 22:01:10 +00:00
|
|
|
#include "shell/browser/extensions/electron_extension_web_contents_observer.h"
|
2020-01-13 22:55:58 +00:00
|
|
|
#include "shell/browser/extensions/electron_messaging_delegate.h"
|
|
|
|
|
2020-09-16 22:15:01 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
2020-09-21 02:08:15 +00:00
|
|
|
#include "components/pdf/browser/pdf_web_contents_helper.h" // nogncheck
|
2020-08-17 15:25:20 +00:00
|
|
|
#include "shell/browser/electron_pdf_web_contents_helper_client.h"
|
|
|
|
#endif
|
|
|
|
|
2020-01-13 22:55:58 +00:00
|
|
|
namespace extensions {
|
|
|
|
|
2020-02-13 00:39:12 +00:00
|
|
|
class ElectronMimeHandlerViewGuestDelegate
|
|
|
|
: public MimeHandlerViewGuestDelegate {
|
|
|
|
public:
|
|
|
|
ElectronMimeHandlerViewGuestDelegate() {}
|
|
|
|
~ElectronMimeHandlerViewGuestDelegate() override {}
|
|
|
|
|
|
|
|
// MimeHandlerViewGuestDelegate.
|
|
|
|
bool HandleContextMenu(content::WebContents* web_contents,
|
|
|
|
const content::ContextMenuParams& params) override {
|
|
|
|
// TODO(nornagon): surface this event to JS
|
|
|
|
LOG(INFO) << "HCM";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
void RecordLoadMetric(bool in_main_frame,
|
|
|
|
const std::string& mime_type) override {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ElectronMimeHandlerViewGuestDelegate);
|
|
|
|
};
|
|
|
|
|
2020-01-13 22:55:58 +00:00
|
|
|
ElectronExtensionsAPIClient::ElectronExtensionsAPIClient() = default;
|
|
|
|
ElectronExtensionsAPIClient::~ElectronExtensionsAPIClient() = default;
|
|
|
|
|
|
|
|
MessagingDelegate* ElectronExtensionsAPIClient::GetMessagingDelegate() {
|
|
|
|
if (!messaging_delegate_)
|
|
|
|
messaging_delegate_ = std::make_unique<ElectronMessagingDelegate>();
|
|
|
|
return messaging_delegate_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ElectronExtensionsAPIClient::AttachWebContentsHelpers(
|
|
|
|
content::WebContents* web_contents) const {
|
2020-02-03 22:01:10 +00:00
|
|
|
extensions::ElectronExtensionWebContentsObserver::CreateForWebContents(
|
2020-01-13 22:55:58 +00:00
|
|
|
web_contents);
|
2020-08-17 15:25:20 +00:00
|
|
|
|
2020-09-16 22:15:01 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
2020-08-17 15:25:20 +00:00
|
|
|
pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
|
|
|
|
web_contents, std::make_unique<ElectronPDFWebContentsHelperClient>());
|
|
|
|
#endif
|
2020-01-13 22:55:58 +00:00
|
|
|
}
|
|
|
|
|
2020-09-02 00:59:56 +00:00
|
|
|
ManagementAPIDelegate*
|
|
|
|
ElectronExtensionsAPIClient::CreateManagementAPIDelegate() const {
|
|
|
|
return new ElectronManagementAPIDelegate;
|
|
|
|
}
|
|
|
|
|
2020-02-13 00:39:12 +00:00
|
|
|
std::unique_ptr<MimeHandlerViewGuestDelegate>
|
|
|
|
ElectronExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
|
|
|
|
MimeHandlerViewGuest* guest) const {
|
|
|
|
return std::make_unique<ElectronMimeHandlerViewGuestDelegate>();
|
|
|
|
}
|
|
|
|
|
2020-01-13 22:55:58 +00:00
|
|
|
} // namespace extensions
|