#include "third_party/blink/renderer/modules/webshare/navigator_share.h"
#include <stdint.h>
#include <utility>
#include "base/files/safe_base_name.h"
#include "build/build_config.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom-blink.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom-blink.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/file_path_conversion.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_share_data.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fileapi/file.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/scheduler/public/frame_or_worker_scheduler.h"
namespace blink {
namespace {
constexpr size_t kMaxSharedFileCount = …;
constexpr uint32_t kMaxSharedFileBytes = …;
constexpr uint32_t kMaxTitleLength = …;
#if BUILDFLAG(IS_ANDROID)
constexpr uint32_t kMaxTextLength = 120U * 1024;
#else
constexpr uint32_t kMaxTextLength = …;
#endif
constexpr uint32_t kMaxUrlLength = …;
String ErrorToString(mojom::blink::ShareError error) { … }
bool HasFiles(const ShareData& data) { … }
bool CanShareInternal(const LocalDOMWindow& window,
const ShareData& data,
KURL& url,
ExceptionState* exception_state) { … }
}
class NavigatorShare::ShareClientImpl final
: public GarbageCollected<ShareClientImpl> { … };
NavigatorShare::ShareClientImpl::ShareClientImpl(
NavigatorShare* navigator_share,
bool has_files,
ScriptPromiseResolver<IDLUndefined>* resolver)
: … { … }
void NavigatorShare::ShareClientImpl::Callback(mojom::blink::ShareError error) { … }
void NavigatorShare::ShareClientImpl::OnConnectionError() { … }
NavigatorShare& NavigatorShare::From(Navigator& navigator) { … }
void NavigatorShare::Trace(Visitor* visitor) const { … }
const char NavigatorShare::kSupplementName[] = …;
bool NavigatorShare::canShare(ScriptState* script_state,
const ShareData* data) { … }
bool NavigatorShare::canShare(ScriptState* script_state,
Navigator& navigator,
const ShareData* data) { … }
ScriptPromise<IDLUndefined> NavigatorShare::share(
ScriptState* script_state,
const ShareData* data,
ExceptionState& exception_state) { … }
ScriptPromise<IDLUndefined> NavigatorShare::share(
ScriptState* script_state,
Navigator& navigator,
const ShareData* data,
ExceptionState& exception_state) { … }
void NavigatorShare::OnConnectionError() { … }
}