#include "chrome/browser/printing/web_api/web_printing_service_binder.h"
#include <utility>
#include "base/feature_list.h"
#include "content/public/browser/isolated_context_util.h"
#include "content/public/browser/render_frame_host.h"
#include "printing/buildflags/buildflags.h"
#include "third_party/blink/public/common/features_generated.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom.h"
#if BUILDFLAG(IS_CHROMEOS) && BUILDFLAG(USE_CUPS)
#include "chrome/browser/printing/web_api/web_printing_service_chromeos.h"
#include "chrome/browser/web_applications/web_app_tab_helper.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_registry.h"
#endif
namespace printing {
#if BUILDFLAG(IS_CHROMEOS) && BUILDFLAG(USE_CUPS)
std::optional<std::string> InferAssociatedAppId(
content::RenderFrameHost* render_frame_host) {
if (auto* web_app_id = web_app::WebAppTabHelper::GetAppId(
content::WebContents::FromRenderFrameHost(render_frame_host))) {
return *web_app_id;
}
auto* extension =
extensions::ExtensionRegistry::Get(render_frame_host->GetBrowserContext())
->enabled_extensions()
.GetExtensionOrAppByURL(render_frame_host->GetLastCommittedURL());
if (extension && extension->is_platform_app()) {
return extension->id();
}
return std::nullopt;
}
#endif
void CreateWebPrintingServiceForFrame(
content::RenderFrameHost* render_frame_host,
mojo::PendingReceiver<blink::mojom::WebPrintingService> receiver) { … }
}