#include "chrome/browser/extensions/api/messaging/chrome_messaging_delegate.h"
#include <memory>
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/functional/callback.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/api/messaging/incognito_connectability.h"
#include "chrome/browser/extensions/api/messaging/native_message_port.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/api/messaging/extension_message_port.h"
#include "extensions/browser/api/messaging/native_message_host.h"
#include "extensions/browser/extension_api_frame_id_map.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/api/messaging/port_id.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_id.h"
#include "ui/gfx/native_widget_types.h"
#include "url/gurl.h"
namespace extensions {
ChromeMessagingDelegate::ChromeMessagingDelegate() = default;
ChromeMessagingDelegate::~ChromeMessagingDelegate() = default;
MessagingDelegate::PolicyPermission
ChromeMessagingDelegate::IsNativeMessagingHostAllowed(
content::BrowserContext* browser_context,
const std::string& native_host_name) { … }
std::optional<base::Value::Dict> ChromeMessagingDelegate::MaybeGetTabInfo(
content::WebContents* web_contents) { … }
content::WebContents* ChromeMessagingDelegate::GetWebContentsByTabId(
content::BrowserContext* browser_context,
int tab_id) { … }
std::unique_ptr<MessagePort> ChromeMessagingDelegate::CreateReceiverForTab(
base::WeakPtr<MessagePort::ChannelDelegate> channel_delegate,
const ExtensionId& extension_id,
const PortId& receiver_port_id,
content::WebContents* receiver_contents,
int receiver_frame_id,
const std::string& receiver_document_id) { … }
std::unique_ptr<MessagePort>
ChromeMessagingDelegate::CreateReceiverForNativeApp(
content::BrowserContext* browser_context,
base::WeakPtr<MessagePort::ChannelDelegate> channel_delegate,
content::RenderFrameHost* source,
const ExtensionId& extension_id,
const PortId& receiver_port_id,
const std::string& native_app_name,
bool allow_user_level,
std::string* error_out) { … }
void ChromeMessagingDelegate::QueryIncognitoConnectability(
content::BrowserContext* context,
const Extension* target_extension,
content::WebContents* source_contents,
const GURL& source_url,
base::OnceCallback<void(bool)> callback) { … }
}