summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/api/file_browser_handler.json
blob: 20fd92bb4592a2004ca9b9b7c9cc16fbd14ff588 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

[
  {
    "namespace":"fileBrowserHandler",
    "platforms": ["chromeos"],
    "types": [
      {
        "id": "FileHandlerExecuteEventDetails",
        "type": "object",
        "description": "Event details payload for fileBrowserHandler.onExecute event.",
        "properties": {
          "entries": {
            "type": "array",
            "items": { "type": "any" },
            "description": "Array of Entry instances representing files that are targets of this action (selected in ChromeOS file browser)."
          },
          "tab_id" : {
            "type": "integer",
            "optional": true,
            "description": "The ID of the tab that raised this event. Tab IDs are unique within a browser session."
          }
        }
      }
    ],

    "events": [
      {
        "name": "onExecute",
        "type": "function",
        "description": "Fired when file system action is executed from ChromeOS file browser.",
        "parameters": [
          {
            "name": "id",
            "type": "string",
            "description": "File browser action id as specified in the listener component's manifest."
          },
          {
            "name": "details",
            "$ref": "FileHandlerExecuteEventDetails",
            "description": "File handler execute event details."
          }
        ]
      },
      {
        "name": "onExecuteContentHandler",
        "type": "function",
        "description": "Fired when a resource is fetched which matches a mime type handled by this extension. The resource request is cancelled, and the extension is expected to handle the request. The event is restricted to a small number of white-listed fileBrowserHandlers.",
        "parameters": [
          {
            "name": "mime_type",
            "type": "string",
            "description": "The MIME type of the intercepted URL request."
          },
          {
            "name": "content_url",
            "type": "string",
            "description": "The intercepted URL request. The handler should fetch and handle data referenced by the URL."
          }
        ]
      }
    ],

    "functions": [
      {
        "name": "selectFile",
        "type": "function",
        "description": "Prompts user to select file path under which file should be saved. When the file is selected, file access permission required to use the file (read, write and create) are granted to the caller. The file will not actually get created during the function call, so function caller must ensure its existence before using it. The function has to be invoked with a user gesture.",
        "parameters": [
          {
            "name": "selectionParams",
            "type": "object",
            "description": "Parameters that will be used while selecting the file.",
            "properties": {
              "suggestedName": {
                  "type": "string",
                  "description": "Suggested name for the file."
              },
              "allowedFileExtensions": {
                  "type": "array",
                  "items": { "type": "string" },
                  "optional": true,
                  "description": "List of file extensions that the selected file can have. The list is also used to specify what files to be shown in the select file dialog. Files with the listed extensions are only shown in the dialog. Extensions should not include the leading '.'. Example: ['jpg', 'png']"
              }
            }
          },
          {
            "name": "callback",
            "type": "function",
            "description": "Function called upon completion.",
            "parameters": [
              {
                "name": "result",
                "description": "Result of the method.",
                "type": "object",
                "properties": {
                  "success": {
                    "type": "boolean",
                    "description": "Whether the file has been selected."
                  },
                  "entry": {
                    "type": "object",
                    "constructor": "Entry",
                    "additionalProperties": { "type": "any" },
                    "optional": true,
                    "description": "Selected file entry. It will be null if a file hasn't been selected."
                  }
                }
              }
            ]
          }
        ]
      }
    ]
  }
]