OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_browser_handlers/file_browser_handle
r.h" | 5 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 return result.release(); | 247 return result.release(); |
248 } | 248 } |
249 | 249 |
250 // Loads FileBrowserHandlers from |extension_actions| into a list in |result|. | 250 // Loads FileBrowserHandlers from |extension_actions| into a list in |result|. |
251 bool LoadFileBrowserHandlers( | 251 bool LoadFileBrowserHandlers( |
252 const std::string& extension_id, | 252 const std::string& extension_id, |
253 const base::ListValue* extension_actions, | 253 const base::ListValue* extension_actions, |
254 FileBrowserHandler::List* result, | 254 FileBrowserHandler::List* result, |
255 base::string16* error) { | 255 base::string16* error) { |
256 for (base::ListValue::const_iterator iter = extension_actions->begin(); | 256 for (const auto& entry : *extension_actions) { |
257 iter != extension_actions->end(); | 257 base::DictionaryValue* dict; |
258 ++iter) { | 258 if (!entry->GetAsDictionary(&dict)) { |
259 if (!(*iter)->IsType(base::Value::TYPE_DICTIONARY)) { | |
260 *error = base::ASCIIToUTF16(errors::kInvalidFileBrowserHandler); | 259 *error = base::ASCIIToUTF16(errors::kInvalidFileBrowserHandler); |
261 return false; | 260 return false; |
262 } | 261 } |
263 std::unique_ptr<FileBrowserHandler> action(LoadFileBrowserHandler( | 262 std::unique_ptr<FileBrowserHandler> action( |
264 extension_id, reinterpret_cast<base::DictionaryValue*>(*iter), error)); | 263 LoadFileBrowserHandler(extension_id, dict, error)); |
265 if (!action.get()) | 264 if (!action.get()) |
266 return false; // Failed to parse file browser action definition. | 265 return false; // Failed to parse file browser action definition. |
267 result->push_back(linked_ptr<FileBrowserHandler>(action.release())); | 266 result->push_back(linked_ptr<FileBrowserHandler>(action.release())); |
268 } | 267 } |
269 return true; | 268 return true; |
270 } | 269 } |
271 | 270 |
272 } // namespace | 271 } // namespace |
273 | 272 |
274 bool FileBrowserHandlerParser::Parse(extensions::Extension* extension, | 273 bool FileBrowserHandlerParser::Parse(extensions::Extension* extension, |
(...skipping 25 matching lines...) Expand all Loading... |
300 return false; // Failed to parse file browser actions definition. | 299 return false; // Failed to parse file browser actions definition. |
301 } | 300 } |
302 | 301 |
303 extension->SetManifestData(keys::kFileBrowserHandlers, info.release()); | 302 extension->SetManifestData(keys::kFileBrowserHandlers, info.release()); |
304 return true; | 303 return true; |
305 } | 304 } |
306 | 305 |
307 const std::vector<std::string> FileBrowserHandlerParser::Keys() const { | 306 const std::vector<std::string> FileBrowserHandlerParser::Keys() const { |
308 return SingleKey(keys::kFileBrowserHandlers); | 307 return SingleKey(keys::kFileBrowserHandlers); |
309 } | 308 } |
OLD | NEW |