#include "chrome/browser/bluetooth/chrome_bluetooth_delegate.h"
#include <memory>
#include "components/guest_view/buildflags/buildflags.h"
#include "components/permissions/bluetooth_delegate_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_frame_host.h"
#include "url/gurl.h"
#if BUILDFLAG(ENABLE_GUEST_VIEW)
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#endif
ChromeBluetoothDelegate::ChromeBluetoothDelegate(std::unique_ptr<Client> client)
: permissions::BluetoothDelegateImpl(std::move(client)) {}
bool ChromeBluetoothDelegate::MayUseBluetooth(content::RenderFrameHost* rfh) {
#if BUILDFLAG(ENABLE_GUEST_VIEW)
if (extensions::WebViewGuest::FromRenderFrameHost(rfh)) {
return false;
}
#endif
if (rfh->GetStoragePartition() !=
rfh->GetBrowserContext()->GetDefaultStoragePartition()) {
return !rfh->GetLastCommittedURL().SchemeIsHTTPOrHTTPS();
}
return true;
}