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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // doesn't begin or end with a dot. | 33 // doesn't begin or end with a dot. |
34 if (c == '.' && (i == 0 || name[i - 1] == '.' || i == name.size() - 1)) { | 34 if (c == '.' && (i == 0 || name[i - 1] == '.' || i == name.size() - 1)) { |
35 return false; | 35 return false; |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 return true; | 39 return true; |
40 } | 40 } |
41 | 41 |
42 // static | 42 // static |
43 scoped_ptr<NativeMessagingHostManifest> NativeMessagingHostManifest::Load( | 43 std::unique_ptr<NativeMessagingHostManifest> NativeMessagingHostManifest::Load( |
44 const base::FilePath& file_path, | 44 const base::FilePath& file_path, |
45 std::string* error_message) { | 45 std::string* error_message) { |
46 DCHECK(error_message); | 46 DCHECK(error_message); |
47 | 47 |
48 JSONFileValueDeserializer deserializer(file_path); | 48 JSONFileValueDeserializer deserializer(file_path); |
49 scoped_ptr<base::Value> parsed = | 49 std::unique_ptr<base::Value> parsed = |
50 deserializer.Deserialize(NULL, error_message); | 50 deserializer.Deserialize(NULL, error_message); |
51 if (!parsed) { | 51 if (!parsed) { |
52 return scoped_ptr<NativeMessagingHostManifest>(); | 52 return std::unique_ptr<NativeMessagingHostManifest>(); |
53 } | 53 } |
54 | 54 |
55 base::DictionaryValue* dictionary; | 55 base::DictionaryValue* dictionary; |
56 if (!parsed->GetAsDictionary(&dictionary)) { | 56 if (!parsed->GetAsDictionary(&dictionary)) { |
57 *error_message = "Invalid manifest file."; | 57 *error_message = "Invalid manifest file."; |
58 return scoped_ptr<NativeMessagingHostManifest>(); | 58 return std::unique_ptr<NativeMessagingHostManifest>(); |
59 } | 59 } |
60 | 60 |
61 scoped_ptr<NativeMessagingHostManifest> result( | 61 std::unique_ptr<NativeMessagingHostManifest> result( |
62 new NativeMessagingHostManifest()); | 62 new NativeMessagingHostManifest()); |
63 if (!result->Parse(dictionary, error_message)) { | 63 if (!result->Parse(dictionary, error_message)) { |
64 return scoped_ptr<NativeMessagingHostManifest>(); | 64 return std::unique_ptr<NativeMessagingHostManifest>(); |
65 } | 65 } |
66 | 66 |
67 return result; | 67 return result; |
68 } | 68 } |
69 | 69 |
70 NativeMessagingHostManifest::NativeMessagingHostManifest() { | 70 NativeMessagingHostManifest::NativeMessagingHostManifest() { |
71 } | 71 } |
72 | 72 |
73 bool NativeMessagingHostManifest::Parse(base::DictionaryValue* dictionary, | 73 bool NativeMessagingHostManifest::Parse(base::DictionaryValue* dictionary, |
74 std::string* error_message) { | 74 std::string* error_message) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 return false; | 131 return false; |
132 } | 132 } |
133 | 133 |
134 allowed_origins_.AddPattern(pattern); | 134 allowed_origins_.AddPattern(pattern); |
135 } | 135 } |
136 | 136 |
137 return true; | 137 return true; |
138 } | 138 } |
139 | 139 |
140 } // namespace extensions | 140 } // namespace extensions |
OLD | NEW |