summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/pepper_file_ref.h
blob: 88020c19988f121c7ed6443408a2b5867f7a1420 (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
// Copyright (c) 2010 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.

#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FILE_REF_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_FILE_REF_H_

#include <string>

#include "base/file_path.h"
#include "ppapi/c/dev/ppb_file_ref_dev.h"
#include "webkit/glue/plugins/pepper_resource.h"

namespace pepper {

class FileSystem;
class PluginInstance;
class PluginModule;

class FileRef : public Resource {
 public:
  FileRef();
  FileRef(PluginModule* module,
          scoped_refptr<FileSystem> file_system,
          const std::string& validated_path);
  FileRef(PluginModule* module,
          const FilePath& external_file_path);
  virtual ~FileRef();

  // Returns a pointer to the interface implementing PPB_FileRef that is
  // exposed to the plugin.
  static const PPB_FileRef_Dev* GetInterface();

  // Resource overrides.
  FileRef* AsFileRef() { return this; }

  // PPB_FileRef implementation.
  std::string GetName() const;
  scoped_refptr<FileRef> GetParent();

  // Returns the file system to which this FileRef belongs.
  scoped_refptr<FileSystem> GetFileSystem() const;

  // Returns the type of the file system to which this FileRef belongs.
  PP_FileSystemType_Dev GetFileSystemType() const;

  // Returns the virtual path (i.e., the path that the pepper plugin sees)
  // corresponding to this file.
  std::string GetPath() const;

  // Returns the system path corresponding to this file.
  FilePath GetSystemPath() const;

 private:
  scoped_refptr<FileSystem> file_system_;
  std::string virtual_path_;  // UTF-8 encoded
  FilePath system_path_;
};

}  // namespace pepper

#endif  // WEBKIT_GLUE_PLUGINS_PEPPER_FILE_REF_H_