summaryrefslogtreecommitdiff
path: root/chromium/url/url_util_qt.h
blob: 1a7cf682171e5e69655964ea20f5e74615fadea7 (plain)
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
#ifndef URL_URL_UTIL_QT_H_
#define URL_URL_UTIL_QT_H_

#include <string>

#include "url/url_util.h"

namespace base {
class CommandLine;
} // namespace base

namespace url {

// Configuration of a custom scheme.
//
// Each process has a list of CustomSchemes. The list is filled in the main
// process and transmitted to subprocesses via command-line flags
// (SaveSchemes/LoadSchemes). We cannot use IPC for this because the url library
// scheme lists are filled and locked before IPC is initialized.
//
// To implement the required semantics, the lists are accessed not only from the
// url library but all over the codebase (grep CustomScheme).
struct COMPONENT_EXPORT(URL) CustomScheme {
  enum Flag {
    Secure = 0x1,
    Local = 0x2,
    LocalAccessAllowed = 0x4,
    NoAccessAllowed = 0x8,
    ServiceWorkersAllowed = 0x10,
    ViewSourceAllowed = 0x20,
    ContentSecurityPolicyIgnored = 0x40,
    CorsEnabled = 0x80,
  };

  std::string name;
  SchemeType type = SCHEME_WITHOUT_AUTHORITY;
  int default_port = PORT_UNSPECIFIED;
  int flags = 0;

  bool has_host_component() const { return type != SCHEME_WITHOUT_AUTHORITY; }
  bool has_port_component() const { return type <= SCHEME_WITH_HOST_AND_PORT; }

  static const std::vector<CustomScheme>& GetSchemes();
  static std::vector<CustomScheme>& GetMutableSchemes();
  static void ClearSchemes();

  static void AddScheme(const CustomScheme& cs);
  static const CustomScheme* FindScheme(base::StringPiece name);

  static const char kCommandLineFlag[];
  static void SaveSchemes(base::CommandLine* command_line);
  static void LoadSchemes(const base::CommandLine* command_line);
};

// Check if |scheme| is handled by Chromium, QtWebEngine (qrc), or the
// application (custom schemes). If so, then the scheme cannot be overridden by
// web APIs such as registerProtocolHandler.
//
// Implemented in QtWebEngine repository.
//
// Thread-safe.
bool IsHandledProtocol(base::StringPiece scheme);

} // namespace url

#endif // URL_URL_UTIL_QT_H_