| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/browser/extensions/api/messaging/native_messaging_host_manifest
.h" | 5 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest
.h" |
| 6 | 6 |
| 7 #include "base/json/json_file_value_serializer.h" | 7 #include "base/json/json_file_value_serializer.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 return true; | 37 return true; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // static | 40 // static |
| 41 scoped_ptr<NativeMessagingHostManifest> NativeMessagingHostManifest::Load( | 41 scoped_ptr<NativeMessagingHostManifest> NativeMessagingHostManifest::Load( |
| 42 const base::FilePath& file_path, | 42 const base::FilePath& file_path, |
| 43 std::string* error_message) { | 43 std::string* error_message) { |
| 44 DCHECK(error_message); | 44 DCHECK(error_message); |
| 45 | 45 |
| 46 JSONFileValueSerializer serializer(file_path); | 46 JSONFileValueDeserializer deserializer(file_path); |
| 47 scoped_ptr<base::Value> parsed(serializer.Deserialize(NULL, error_message)); | 47 scoped_ptr<base::Value> parsed(deserializer.Deserialize(NULL, error_message)); |
| 48 if (!parsed) { | 48 if (!parsed) { |
| 49 return scoped_ptr<NativeMessagingHostManifest>(); | 49 return scoped_ptr<NativeMessagingHostManifest>(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 base::DictionaryValue* dictionary; | 52 base::DictionaryValue* dictionary; |
| 53 if (!parsed->GetAsDictionary(&dictionary)) { | 53 if (!parsed->GetAsDictionary(&dictionary)) { |
| 54 *error_message = "Invalid manifest file."; | 54 *error_message = "Invalid manifest file."; |
| 55 return scoped_ptr<NativeMessagingHostManifest>(); | 55 return scoped_ptr<NativeMessagingHostManifest>(); |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return false; | 128 return false; |
| 129 } | 129 } |
| 130 | 130 |
| 131 allowed_origins_.AddPattern(pattern); | 131 allowed_origins_.AddPattern(pattern); |
| 132 } | 132 } |
| 133 | 133 |
| 134 return true; | 134 return true; |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace extensions | 137 } // namespace extensions |
| OLD | NEW |