| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 FileHandlersParser::FileHandlersParser() { | 36 FileHandlersParser::FileHandlersParser() { |
| 37 } | 37 } |
| 38 | 38 |
| 39 FileHandlersParser::~FileHandlersParser() { | 39 FileHandlersParser::~FileHandlersParser() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool LoadFileHandler(const std::string& handler_id, | 42 bool LoadFileHandler(const std::string& handler_id, |
| 43 const base::DictionaryValue& handler_info, | 43 const base::DictionaryValue& handler_info, |
| 44 std::vector<FileHandlerInfo>* file_handlers, | 44 std::vector<FileHandlerInfo>* file_handlers, |
| 45 string16* error) { | 45 base::string16* error) { |
| 46 DCHECK(error); | 46 DCHECK(error); |
| 47 FileHandlerInfo handler; | 47 FileHandlerInfo handler; |
| 48 | 48 |
| 49 handler.id = handler_id; | 49 handler.id = handler_id; |
| 50 | 50 |
| 51 const base::ListValue* mime_types = NULL; | 51 const base::ListValue* mime_types = NULL; |
| 52 if (handler_info.HasKey(keys::kFileHandlerTypes) && | 52 if (handler_info.HasKey(keys::kFileHandlerTypes) && |
| 53 !handler_info.GetList(keys::kFileHandlerTypes, &mime_types)) { | 53 !handler_info.GetList(keys::kFileHandlerTypes, &mime_types)) { |
| 54 *error = ErrorUtils::FormatErrorMessageUTF16( | 54 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 55 errors::kInvalidFileHandlerType, handler_id); | 55 errors::kInvalidFileHandlerType, handler_id); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return false; | 103 return false; |
| 104 } | 104 } |
| 105 handler.extensions.insert(file_extension); | 105 handler.extensions.insert(file_extension); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 file_handlers->push_back(handler); | 109 file_handlers->push_back(handler); |
| 110 return true; | 110 return true; |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool FileHandlersParser::Parse(Extension* extension, string16* error) { | 113 bool FileHandlersParser::Parse(Extension* extension, base::string16* error) { |
| 114 scoped_ptr<FileHandlers> info(new FileHandlers); | 114 scoped_ptr<FileHandlers> info(new FileHandlers); |
| 115 const base::DictionaryValue* all_handlers = NULL; | 115 const base::DictionaryValue* all_handlers = NULL; |
| 116 if (!extension->manifest()->GetDictionary(keys::kFileHandlers, | 116 if (!extension->manifest()->GetDictionary(keys::kFileHandlers, |
| 117 &all_handlers)) { | 117 &all_handlers)) { |
| 118 *error = ASCIIToUTF16(errors::kInvalidFileHandlers); | 118 *error = ASCIIToUTF16(errors::kInvalidFileHandlers); |
| 119 return false; | 119 return false; |
| 120 } | 120 } |
| 121 | 121 |
| 122 DCHECK(extension->is_platform_app()); | 122 DCHECK(extension->is_platform_app()); |
| 123 | 123 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 151 | 151 |
| 152 extension->SetManifestData(keys::kFileHandlers, info.release()); | 152 extension->SetManifestData(keys::kFileHandlers, info.release()); |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 | 155 |
| 156 const std::vector<std::string> FileHandlersParser::Keys() const { | 156 const std::vector<std::string> FileHandlersParser::Keys() const { |
| 157 return SingleKey(keys::kFileHandlers); | 157 return SingleKey(keys::kFileHandlers); |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace extensions | 160 } // namespace extensions |
| OLD | NEW |