| 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 FileSystemProviderCapabilities::FileSystemProviderCapabilities() | |
| 18 : configurable_(false), multiple_mounts_(false), source_(SOURCE_FILE) { | |
| 19 } | |
| 20 | |
| 21 FileSystemProviderCapabilities::FileSystemProviderCapabilities( | |
| 22 bool configurable, | |
| 23 bool multiple_mounts, | |
| 24 FileSystemProviderSource source) | |
| 25 : configurable_(configurable), | |
| 26 multiple_mounts_(multiple_mounts), | |
| 27 source_(source) { | |
| 28 } | |
| 29 | |
| 30 FileSystemProviderCapabilities::~FileSystemProviderCapabilities() { | |
| 31 } | |
| 32 | |
| 33 FileSystemProviderHandler::FileSystemProviderHandler() { | |
| 34 } | |
| 35 | |
| 36 FileSystemProviderHandler::~FileSystemProviderHandler() { | |
| 37 } | |
| 38 | |
| 39 // static | |
| 40 const FileSystemProviderCapabilities* FileSystemProviderCapabilities::Get( | |
| 41 const Extension* extension) { | |
| 42 return static_cast<FileSystemProviderCapabilities*>( | |
| 43 extension->GetManifestData(manifest_keys::kFileSystemProvider)); | |
| 44 } | |
| 45 | |
| 46 bool FileSystemProviderHandler::Parse(Extension* extension, | |
| 47 base::string16* error) { | |
| 48 const base::DictionaryValue* section = NULL; | |
| 49 extension->manifest()->GetDictionary(manifest_keys::kFileSystemProvider, | |
| 50 §ion); | |
| 51 DCHECK(section); | |
| 52 | |
| 53 api::manifest_types::FileSystemProviderCapabilities idl_capabilities; | |
| 54 if (!api::manifest_types::FileSystemProviderCapabilities::Populate( | |
| 55 *section, &idl_capabilities, error)) { | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 FileSystemProviderSource source = SOURCE_FILE; | |
| 60 switch (idl_capabilities.source) { | |
| 61 case api::manifest_types::FILE_SYSTEM_PROVIDER_SOURCE_FILE: | |
| 62 source = SOURCE_FILE; | |
| 63 break; | |
| 64 case api::manifest_types::FILE_SYSTEM_PROVIDER_SOURCE_DEVICE: | |
| 65 source = SOURCE_DEVICE; | |
| 66 break; | |
| 67 case api::manifest_types::FILE_SYSTEM_PROVIDER_SOURCE_NETWORK: | |
| 68 source = SOURCE_NETWORK; | |
| 69 break; | |
| 70 case api::manifest_types::FILE_SYSTEM_PROVIDER_SOURCE_NONE: | |
| 71 NOTREACHED(); | |
| 72 } | |
| 73 | |
| 74 scoped_ptr<FileSystemProviderCapabilities> capabilities( | |
| 75 new FileSystemProviderCapabilities(idl_capabilities.configurable, | |
| 76 idl_capabilities.multiple_mounts, | |
| 77 source)); | |
| 78 | |
| 79 extension->SetManifestData(manifest_keys::kFileSystemProvider, | |
| 80 capabilities.release()); | |
| 81 return true; | |
| 82 } | |
| 83 | |
| 84 const std::vector<std::string> FileSystemProviderHandler::Keys() const { | |
| 85 return SingleKey(manifest_keys::kFileSystemProvider); | |
| 86 } | |
| 87 | |
| 88 } // namespace extensions | |
| OLD | NEW |