OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/common/extensions/api/file_system_provider/file_system_provider _handler.h" | |
6 | |
7 #include "base/memory/scoped_ptr.h" | |
8 #include "base/strings/utf_string_conversions.h" | |
9 #include "base/values.h" | |
10 #include "chrome/common/extensions/api/manifest_types.h" | |
11 #include "extensions/common/error_utils.h" | |
12 #include "extensions/common/manifest_constants.h" | |
13 #include "url/gurl.h" | |
14 | |
15 namespace extensions { | |
16 | |
17 namespace mkeys = manifest_keys; | |
18 namespace merrors = manifest_errors; | |
19 | |
20 FileSystemProviderCapabilities::FileSystemProviderCapabilities() | |
21 : configurable_(false), multiple_mounts_(false), source_(SOURCE_FILE) { | |
22 } | |
23 | |
24 FileSystemProviderCapabilities::FileSystemProviderCapabilities( | |
25 bool configurable, | |
26 bool multiple_mounts, | |
27 FileSystemProviderSource source) | |
28 : configurable_(configurable), | |
29 multiple_mounts_(multiple_mounts), | |
30 source_(source) { | |
31 } | |
32 | |
33 FileSystemProviderCapabilities::~FileSystemProviderCapabilities() { | |
34 } | |
35 | |
36 FileSystemProviderHandler::FileSystemProviderHandler() { | |
37 } | |
38 | |
39 FileSystemProviderHandler::~FileSystemProviderHandler() { | |
40 } | |
41 | |
42 // static | |
43 const FileSystemProviderCapabilities* FileSystemProviderCapabilities::Get( | |
44 const Extension* extension) { | |
45 return static_cast<FileSystemProviderCapabilities*>( | |
46 extension->GetManifestData(mkeys::kFileSystemProvider)); | |
47 } | |
48 | |
49 bool FileSystemProviderHandler::Parse(Extension* extension, | |
50 base::string16* error) { | |
51 const base::DictionaryValue* section = NULL; | |
not at google - send to devlin
2015/05/07 22:57:56
You should just read in |section| as a base::Value
| |
52 if (!extension->manifest()->GetDictionary(mkeys::kFileSystemProvider, | |
53 §ion)) { | |
54 *error = base::ASCIIToUTF16(merrors::kInvalidFileSystemProvider); | |
55 return false; | |
56 } | |
57 | |
58 api::manifest_types::FileSystemProviderCapabilities idl_capabilities; | |
59 if (!api::manifest_types::FileSystemProviderCapabilities::Populate( | |
60 *section, &idl_capabilities, error)) { | |
61 return false; | |
62 } | |
63 | |
64 FileSystemProviderSource source = SOURCE_FILE; | |
65 switch (idl_capabilities.source) { | |
66 case api::manifest_types::FILE_SYSTEM_PROVIDER_SOURCE_FILE: | |
67 source = SOURCE_FILE; | |
68 break; | |
69 case api::manifest_types::FILE_SYSTEM_PROVIDER_SOURCE_DEVICE: | |
70 source = SOURCE_DEVICE; | |
71 break; | |
72 case api::manifest_types::FILE_SYSTEM_PROVIDER_SOURCE_NETWORK: | |
73 source = SOURCE_NETWORK; | |
74 break; | |
75 case api::manifest_types::FILE_SYSTEM_PROVIDER_SOURCE_NONE: | |
76 NOTREACHED(); | |
77 } | |
78 | |
79 scoped_ptr<FileSystemProviderCapabilities> capabilities( | |
80 new FileSystemProviderCapabilities(idl_capabilities.configurable, | |
81 idl_capabilities.multiple_mounts, | |
82 source)); | |
83 | |
84 extension->SetManifestData(mkeys::kFileSystemProvider, | |
85 capabilities.release()); | |
86 return true; | |
87 } | |
88 | |
89 const std::vector<std::string> FileSystemProviderHandler::Keys() const { | |
90 return SingleKey(mkeys::kFileSystemProvider); | |
91 } | |
92 | |
93 } // namespace extensions | |
OLD | NEW |