#include "chrome/browser/extensions/api/messaging/native_messaging_launch_from_native.h"
#include <memory>
#include <string_view>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/timer/timer.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/api/messaging/native_message_port.h"
#include "chrome/browser/extensions/api/messaging/native_message_process_host.h"
#include "chrome/browser/extensions/api/messaging/native_process_launcher.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/manifest_handlers/natively_connectable_handler.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/messaging/channel_endpoint.h"
#include "extensions/browser/api/messaging/message_service.h"
#include "extensions/browser/api/messaging/native_message_host.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/api/messaging/messaging_endpoint.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/mojom/message_port.mojom-shared.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
namespace extensions {
namespace {
ScopedAllowNativeAppConnectionForTest* g_allow_native_app_connection_for_test = …;
constexpr base::TimeDelta kNativeMessagingHostErrorTimeout = …;
ScopedNativeMessagingErrorTimeoutOverrideForTest*
g_native_messaging_host_timeout_override = …;
class NativeMessagingHostErrorReporter : public NativeMessageHost::Client { … };
}
bool ExtensionSupportsConnectionFromNativeApp(const ExtensionId& extension_id,
const std::string& host_id,
Profile* profile,
bool log_errors) { … }
ScopedAllowNativeAppConnectionForTest::ScopedAllowNativeAppConnectionForTest(
bool allow)
: … { … }
ScopedAllowNativeAppConnectionForTest::
~ScopedAllowNativeAppConnectionForTest() { … }
ScopedNativeMessagingErrorTimeoutOverrideForTest::
ScopedNativeMessagingErrorTimeoutOverrideForTest(base::TimeDelta timeout)
: … { … }
ScopedNativeMessagingErrorTimeoutOverrideForTest::
~ScopedNativeMessagingErrorTimeoutOverrideForTest() { … }
bool IsValidConnectionId(const std::string_view connection_id) { … }
void LaunchNativeMessageHostFromNativeApp(const ExtensionId& extension_id,
const std::string& host_id,
const std::string& connection_id,
Profile* profile) { … }
}