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.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_EXTENSIONS_ELECTRON_MESSAGING_DELEGATE_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_EXTENSIONS_ELECTRON_MESSAGING_DELEGATE_H_
|
2020-01-13 22:55:58 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "extensions/browser/api/messaging/messaging_delegate.h"
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
|
|
|
// Helper class for Chrome-specific features of the extension messaging API.
|
|
|
|
class ElectronMessagingDelegate : public MessagingDelegate {
|
|
|
|
public:
|
|
|
|
ElectronMessagingDelegate();
|
|
|
|
~ElectronMessagingDelegate() override;
|
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
ElectronMessagingDelegate(const ElectronMessagingDelegate&) = delete;
|
|
|
|
ElectronMessagingDelegate& operator=(const ElectronMessagingDelegate&) =
|
|
|
|
delete;
|
|
|
|
|
2020-01-13 22:55:58 +00:00
|
|
|
// MessagingDelegate:
|
|
|
|
PolicyPermission IsNativeMessagingHostAllowed(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const std::string& native_host_name) override;
|
|
|
|
std::unique_ptr<base::DictionaryValue> MaybeGetTabInfo(
|
|
|
|
content::WebContents* web_contents) override;
|
|
|
|
content::WebContents* GetWebContentsByTabId(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
int tab_id) override;
|
|
|
|
std::unique_ptr<MessagePort> CreateReceiverForTab(
|
|
|
|
base::WeakPtr<MessagePort::ChannelDelegate> channel_delegate,
|
|
|
|
const std::string& extension_id,
|
|
|
|
const PortId& receiver_port_id,
|
|
|
|
content::WebContents* receiver_contents,
|
|
|
|
int receiver_frame_id) override;
|
|
|
|
std::unique_ptr<MessagePort> CreateReceiverForNativeApp(
|
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
base::WeakPtr<MessagePort::ChannelDelegate> channel_delegate,
|
|
|
|
content::RenderFrameHost* source,
|
|
|
|
const std::string& extension_id,
|
|
|
|
const PortId& receiver_port_id,
|
|
|
|
const std::string& native_app_name,
|
|
|
|
bool allow_user_level,
|
|
|
|
std::string* error_out) override;
|
|
|
|
void QueryIncognitoConnectability(
|
|
|
|
content::BrowserContext* context,
|
|
|
|
const Extension* extension,
|
2021-06-01 01:46:25 +00:00
|
|
|
content::WebContents* source_contents,
|
2020-01-13 22:55:58 +00:00
|
|
|
const GURL& url,
|
2021-01-12 23:31:23 +00:00
|
|
|
base::OnceCallback<void(bool)> callback) override;
|
2020-01-13 22:55:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace extensions
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_EXTENSIONS_ELECTRON_MESSAGING_DELEGATE_H_
|