summaryrefslogtreecommitdiffstats
path: root/webkit/plugins/ppapi/ppb_file_ref_impl.h
blob: 234e15087e3db7a0b46df50da29b4c665cb949eb (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
// Copyright (c) 2011 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_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_

#include <string>

#include "base/file_path.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/dev/ppb_file_ref_dev.h"
#include "webkit/plugins/ppapi/resource.h"

namespace webkit {
namespace ppapi {

class PPB_FileSystem_Impl;
class PluginInstance;
class PluginModule;

class PPB_FileRef_Impl : public Resource {
 public:
  PPB_FileRef_Impl();
  PPB_FileRef_Impl(PluginInstance* instance,
                   scoped_refptr<PPB_FileSystem_Impl> file_system,
                   const std::string& validated_path);
  PPB_FileRef_Impl(PluginInstance* instance,
                   const FilePath& external_file_path);
  virtual ~PPB_FileRef_Impl();

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

  // Resource overrides.
  virtual PPB_FileRef_Impl* AsPPB_FileRef_Impl();

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

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

  // Returns the type of the file system to which this PPB_FileRef_Impl 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;

  // Returns the FileSystem API URL corresponding to this file.
  GURL GetFileSystemURL() const;

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

  DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl);
};

}  // namespace ppapi
}  // namespace webkit

#endif  // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_