OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/api/file_handlers/file_handlers_parser.h" | 5 #include "chrome/common/extensions/api/file_handlers/file_handlers_parser.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 bool FileHandlersParser::Parse(Extension* extension, base::string16* error) { | 110 bool FileHandlersParser::Parse(Extension* extension, base::string16* error) { |
111 scoped_ptr<FileHandlers> info(new FileHandlers); | 111 scoped_ptr<FileHandlers> info(new FileHandlers); |
112 const base::DictionaryValue* all_handlers = NULL; | 112 const base::DictionaryValue* all_handlers = NULL; |
113 if (!extension->manifest()->GetDictionary(keys::kFileHandlers, | 113 if (!extension->manifest()->GetDictionary(keys::kFileHandlers, |
114 &all_handlers)) { | 114 &all_handlers)) { |
115 *error = base::ASCIIToUTF16(errors::kInvalidFileHandlers); | 115 *error = base::ASCIIToUTF16(errors::kInvalidFileHandlers); |
116 return false; | 116 return false; |
117 } | 117 } |
118 | 118 |
119 DCHECK(extension->is_platform_app()); | |
120 | |
121 for (base::DictionaryValue::Iterator iter(*all_handlers); !iter.IsAtEnd(); | 119 for (base::DictionaryValue::Iterator iter(*all_handlers); !iter.IsAtEnd(); |
122 iter.Advance()) { | 120 iter.Advance()) { |
123 // A file handler entry is a title and a list of MIME types to handle. | 121 // A file handler entry is a title and a list of MIME types to handle. |
124 const base::DictionaryValue* handler = NULL; | 122 const base::DictionaryValue* handler = NULL; |
125 if (iter.value().GetAsDictionary(&handler)) { | 123 if (iter.value().GetAsDictionary(&handler)) { |
126 if (!LoadFileHandler(iter.key(), *handler, &info->file_handlers, error)) | 124 if (!LoadFileHandler(iter.key(), *handler, &info->file_handlers, error)) |
127 return false; | 125 return false; |
128 } else { | 126 } else { |
129 *error = base::ASCIIToUTF16(errors::kInvalidFileHandlers); | 127 *error = base::ASCIIToUTF16(errors::kInvalidFileHandlers); |
130 return false; | 128 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
148 | 146 |
149 extension->SetManifestData(keys::kFileHandlers, info.release()); | 147 extension->SetManifestData(keys::kFileHandlers, info.release()); |
150 return true; | 148 return true; |
151 } | 149 } |
152 | 150 |
153 const std::vector<std::string> FileHandlersParser::Keys() const { | 151 const std::vector<std::string> FileHandlersParser::Keys() const { |
154 return SingleKey(keys::kFileHandlers); | 152 return SingleKey(keys::kFileHandlers); |
155 } | 153 } |
156 | 154 |
157 } // namespace extensions | 155 } // namespace extensions |
OLD | NEW |