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/web_intents_handler.h" | 5 #include "chrome/common/extensions/web_intents_handler.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/common/extensions/extension_manifest_constants.h" | 12 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 13 #include "chrome/common/extensions/manifest.h" |
13 #include "extensions/common/error_utils.h" | 14 #include "extensions/common/error_utils.h" |
14 #include "webkit/glue/web_intent_service_data.h" | 15 #include "webkit/glue/web_intent_service_data.h" |
15 | 16 |
16 namespace extensions { | 17 namespace extensions { |
17 | 18 |
18 namespace keys = extension_manifest_keys; | 19 namespace keys = extension_manifest_keys; |
19 namespace values = extension_manifest_values; | 20 namespace values = extension_manifest_values; |
20 namespace errors = extension_manifest_errors; | 21 namespace errors = extension_manifest_errors; |
21 | 22 |
22 namespace { | 23 namespace { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 extension->GetManifestData(keys::kIntents)); | 161 extension->GetManifestData(keys::kIntents)); |
161 return info ? info->intents_services_ : g_empty_intents_data.Get(); | 162 return info ? info->intents_services_ : g_empty_intents_data.Get(); |
162 } | 163 } |
163 | 164 |
164 WebIntentsHandler::WebIntentsHandler() { | 165 WebIntentsHandler::WebIntentsHandler() { |
165 } | 166 } |
166 | 167 |
167 WebIntentsHandler::~WebIntentsHandler() { | 168 WebIntentsHandler::~WebIntentsHandler() { |
168 } | 169 } |
169 | 170 |
170 bool WebIntentsHandler::Parse(const base::Value* value, | 171 bool WebIntentsHandler::Parse(Extension* extension, string16* error) { |
171 Extension* extension, | |
172 string16* error) { | |
173 scoped_ptr<WebIntentsInfo> info(new WebIntentsInfo); | 172 scoped_ptr<WebIntentsInfo> info(new WebIntentsInfo); |
174 const DictionaryValue* all_services = NULL; | 173 const DictionaryValue* all_services = NULL; |
175 if (!value->GetAsDictionary(&all_services)) { | 174 if (!extension->manifest()->GetDictionary(keys::kIntents, &all_services)) { |
176 *error = ASCIIToUTF16(errors::kInvalidIntents); | 175 *error = ASCIIToUTF16(errors::kInvalidIntents); |
177 return false; | 176 return false; |
178 } | 177 } |
179 | 178 |
180 for (DictionaryValue::key_iterator iter(all_services->begin_keys()); | 179 for (DictionaryValue::key_iterator iter(all_services->begin_keys()); |
181 iter != all_services->end_keys(); ++iter) { | 180 iter != all_services->end_keys(); ++iter) { |
182 // Any entry in the intents dictionary can either have a list of | 181 // Any entry in the intents dictionary can either have a list of |
183 // dictionaries, or just a single dictionary attached to that. Try | 182 // dictionaries, or just a single dictionary attached to that. Try |
184 // lists first, fall back to single dictionary. | 183 // lists first, fall back to single dictionary. |
185 const ListValue* service_list = NULL; | 184 const ListValue* service_list = NULL; |
(...skipping 17 matching lines...) Expand all Loading... |
203 if (!LoadWebIntentsAction(*iter, *one_service, extension, | 202 if (!LoadWebIntentsAction(*iter, *one_service, extension, |
204 error, &info->intents_services_)) | 203 error, &info->intents_services_)) |
205 return false; | 204 return false; |
206 } | 205 } |
207 } | 206 } |
208 extension->SetManifestData(keys::kIntents, info.release()); | 207 extension->SetManifestData(keys::kIntents, info.release()); |
209 return true; | 208 return true; |
210 } | 209 } |
211 | 210 |
212 } // namespace extensions | 211 } // namespace extensions |
OLD | NEW |