#ifndef COMPONENTS_CAST_RECEIVER_BROWSER_PUBLIC_CONTENT_BROWSER_CLIENT_MIXINS_H_
#define COMPONENTS_CAST_RECEIVER_BROWSER_PUBLIC_CONTENT_BROWSER_CLIENT_MIXINS_H_
#include <memory>
#include <string_view>
#include <vector>
#include "base/functional/callback.h"
#include "components/cast_receiver/browser/runtime_application_dispatcher_impl.h"
#include "content/public/browser/frame_tree_node_id.h"
#include "services/network/public/cpp/network_context_getter.h"
namespace blink {
class URLLoaderThrottle;
}
namespace content {
class WebContents;
}
namespace cast_receiver {
class ApplicationClient;
class ApplicationStateObserver;
class ContentBrowserClientMixins {
public:
static std::unique_ptr<ContentBrowserClientMixins> Create(
network::NetworkContextGetter network_context_getter);
virtual ~ContentBrowserClientMixins() = default;
virtual void AddApplicationStateObserver(
ApplicationStateObserver* observer) = 0;
virtual void RemoveApplicationStateObserver(
ApplicationStateObserver* observer) = 0;
virtual void OnWebContentsCreated(content::WebContents* web_contents) = 0;
using CorsExemptHeaderCallback =
base::RepeatingCallback<bool(std::string_view)>;
virtual std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
CreateURLLoaderThrottles(
const base::RepeatingCallback<content::WebContents*()>& wc_getter,
content::FrameTreeNodeId frame_tree_node_id,
CorsExemptHeaderCallback is_cors_exempt_header_cb) = 0;
template <typename TEmbedderApplication>
std::unique_ptr<RuntimeApplicationDispatcher<TEmbedderApplication>>
CreateApplicationDispatcher() {
return std::make_unique<
RuntimeApplicationDispatcherImpl<TEmbedderApplication>>(
GetApplicationClient());
}
protected:
virtual ApplicationClient& GetApplicationClient() = 0;
};
}
#endif