File: browser_file_system_helper.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (87 lines) | stat: -rw-r--r-- 3,323 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_HELPER_H_
#define CONTENT_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_HELPER_H_

#include "base/memory/scoped_refptr.h"
#include "content/common/content_export.h"
#include "storage/browser/file_system/file_system_context.h"
#include "ui/base/clipboard/file_info.h"

class GURL;

namespace base {
class FilePath;
}  // namespace base

namespace blink {
class StorageKey;
}  // namespace blink

namespace storage {
class FileSystemContext;
class FileSystemURL;
class QuotaManagerProxy;
}  // namespace storage

namespace content {

class BrowserContext;
class ChildProcessSecurityPolicyImpl;
struct DropData;

// Helper method that returns FileSystemContext constructed for
// the browser process.
CONTENT_EXPORT scoped_refptr<storage::FileSystemContext>
CreateFileSystemContext(
    BrowserContext* browser_context,
    const base::FilePath& profile_path,
    bool is_incognito,
    scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy);

// Verifies that `url` is valid and has a registered backend in `context`.
CONTENT_EXPORT bool FileSystemURLIsValid(storage::FileSystemContext* context,
                                         const storage::FileSystemURL& url);

// TODO(crbug.com/40810215): Consider making this a method on FileSystemContext.
// Get the platform path from a file system URL. This needs to be called
// on the FILE thread.
using DoGetPlatformPathCB = base::OnceCallback<void(const base::FilePath&)>;
CONTENT_EXPORT void DoGetPlatformPath(
    scoped_refptr<storage::FileSystemContext> context,
    int process_id,
    const GURL& path,
    const blink::StorageKey& storage_key,
    DoGetPlatformPathCB callback);

// Make it possible for a `drop_data`'s resources to be read by `child_id`'s
// process -- by granting permissions, rewriting `drop_data`, or both.
//
// `drop_data` can include references to local files and filesystem files that
// were accessible to the child process that is the source of the drag and drop,
// but might not (yet) be accessible to the child process that is the target of
// the drop.  PrepareDropDataForChildProcess makes sure that `child_id` has
// access to files referred to by `drop_data` - this method will 1) mutate
// `drop_data` as needed (e.g. to refer to files in a new isolated filesystem,
// rather than the original filesystem files) and 2) use `security_policy` to
// grant `child_id` appropriate file access.
CONTENT_EXPORT void PrepareDropDataForChildProcess(
    DropData* drop_data,
    ChildProcessSecurityPolicyImpl* security_policy,
    int child_id,
    const storage::FileSystemContext* file_system_context);

// Make it possible for local files to be read by `child_id`'s process. This is
// used by clipboard, and by drag-and-drop. Returns filesystem_id of the
// registered isolated filesystem.
CONTENT_EXPORT std::string PrepareDataTransferFilenamesForChildProcess(
    std::vector<ui::FileInfo>& filenames,
    ChildProcessSecurityPolicyImpl* security_policy,
    int child_id,
    const storage::FileSystemContext* file_system_context);

}  // namespace content

#endif  // CONTENT_BROWSER_FILE_SYSTEM_BROWSER_FILE_SYSTEM_HELPER_H_