#include "content/browser/file_system_access/file_system_access_observer_observation.h"
#include <memory>
#include <string>
#include <vector>
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "build/buildflag.h"
#include "content/browser/file_system_access/file_system_access_change_source.h"
#include "content/browser/file_system_access/file_system_access_directory_handle_impl.h"
#include "content/browser/file_system_access/file_system_access_file_handle_impl.h"
#include "content/browser/file_system_access/file_system_access_handle_base.h"
#include "content/browser/file_system_access/file_system_access_manager_impl.h"
#include "content/browser/file_system_access/file_system_access_observer_host.h"
#include "content/browser/file_system_access/file_system_access_watch_scope.h"
#include "content/browser/file_system_access/file_system_access_watcher_manager.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/public/browser/file_system_access_permission_context.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/web_contents.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_url.h"
#include "third_party/blink/public/mojom/file_system_access/file_system_access_directory_handle.mojom.h"
#include "third_party/blink/public/mojom/file_system_access/file_system_access_observer.mojom.h"
#include "third_party/blink/public/mojom/permissions/permission_status.mojom-shared.h"
#if BUILDFLAG(IS_WIN)
#include "base/strings/utf_string_conversions.h"
#endif
namespace content {
namespace {
FileSystemAccessPermissionContext::HandleType GetHandleType(
const absl::variant<std::unique_ptr<FileSystemAccessDirectoryHandleImpl>,
std::unique_ptr<FileSystemAccessFileHandleImpl>>&
handle) { … }
FileSystemAccessHandleBase& AsHandleBase(
const absl::variant<std::unique_ptr<FileSystemAccessDirectoryHandleImpl>,
std::unique_ptr<FileSystemAccessFileHandleImpl>>&
handle) { … }
std::vector<std::string> GetRelativePathAsVectorOfStrings(
const base::FilePath& relative_path) { … }
blink::mojom::FileSystemAccessEntryPtr CreateEntryForUrl(
FileSystemAccessManagerImpl& manager,
const FileSystemAccessManagerImpl::BindingContext& binding_context,
const FileSystemAccessManagerImpl::SharedHandleState& handle_state,
const storage::FileSystemURL& url,
FileSystemAccessPermissionContext::HandleType handle_type) { … }
std::optional<base::FilePath> GetRelativePath(const base::FilePath& root_path,
const base::FilePath& target) { … }
bool RenderFrameHostIsActive(
const FileSystemAccessManagerImpl::BindingContext& binding_context) { … }
}
FileSystemAccessObserverObservation::FileSystemAccessObserverObservation(
FileSystemAccessObserverHost* host,
std::unique_ptr<FileSystemAccessWatcherManager::Observation> observation,
mojo::PendingRemote<blink::mojom::FileSystemAccessObserver> remote,
absl::variant<std::unique_ptr<FileSystemAccessDirectoryHandleImpl>,
std::unique_ptr<FileSystemAccessFileHandleImpl>> handle)
: … { … }
FileSystemAccessObserverObservation::~FileSystemAccessObserverObservation() { … }
const storage::FileSystemURL& FileSystemAccessObserverObservation::handle_url()
const { … }
void FileSystemAccessObserverObservation::OnChanges(
const std::optional<
std::list<FileSystemAccessWatcherManager::Observation::Change>>&
changes_or_error) { … }
void FileSystemAccessObserverObservation::HandleError() { … }
void FileSystemAccessObserverObservation::RenderFrameHostStateChanged(
RenderFrameHost* render_frame_host,
RenderFrameHost::LifecycleState old_state,
RenderFrameHost::LifecycleState new_state) { … }
void FileSystemAccessObserverObservation::OnReceiverDisconnect() { … }
void FileSystemAccessObserverObservation::OnPermissionStatusChanged() { … }
void FileSystemAccessObserverObservation::RecordCallbackCountUMA() { … }
}