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 26 matching lines...) Expand all Loading... |
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 JSONFileValueDeserializer deserializer(file_path); | 46 JSONFileValueDeserializer deserializer(file_path); |
47 scoped_ptr<base::Value> parsed(deserializer.Deserialize(NULL, error_message)); | 47 scoped_ptr<base::Value> parsed = |
| 48 deserializer.Deserialize(NULL, error_message); |
48 if (!parsed) { | 49 if (!parsed) { |
49 return scoped_ptr<NativeMessagingHostManifest>(); | 50 return scoped_ptr<NativeMessagingHostManifest>(); |
50 } | 51 } |
51 | 52 |
52 base::DictionaryValue* dictionary; | 53 base::DictionaryValue* dictionary; |
53 if (!parsed->GetAsDictionary(&dictionary)) { | 54 if (!parsed->GetAsDictionary(&dictionary)) { |
54 *error_message = "Invalid manifest file."; | 55 *error_message = "Invalid manifest file."; |
55 return scoped_ptr<NativeMessagingHostManifest>(); | 56 return scoped_ptr<NativeMessagingHostManifest>(); |
56 } | 57 } |
57 | 58 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 return false; | 129 return false; |
129 } | 130 } |
130 | 131 |
131 allowed_origins_.AddPattern(pattern); | 132 allowed_origins_.AddPattern(pattern); |
132 } | 133 } |
133 | 134 |
134 return true; | 135 return true; |
135 } | 136 } |
136 | 137 |
137 } // namespace extensions | 138 } // namespace extensions |
OLD | NEW |