OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
38 #include "googleurl/src/url_util.h" | 38 #include "googleurl/src/url_util.h" |
39 #include "grit/chromium_strings.h" | 39 #include "grit/chromium_strings.h" |
40 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
41 #include "grit/theme_resources.h" | 41 #include "grit/theme_resources.h" |
42 #include "net/base/registry_controlled_domain.h" | 42 #include "net/base/registry_controlled_domain.h" |
43 #include "third_party/skia/include/core/SkBitmap.h" | 43 #include "third_party/skia/include/core/SkBitmap.h" |
44 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
45 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
46 #include "webkit/glue/image_decoder.h" | 46 #include "webkit/glue/image_decoder.h" |
| 47 #include "webkit/glue/web_intent_service_data.h" |
47 | 48 |
48 namespace keys = extension_manifest_keys; | 49 namespace keys = extension_manifest_keys; |
49 namespace values = extension_manifest_values; | 50 namespace values = extension_manifest_values; |
50 namespace errors = extension_manifest_errors; | 51 namespace errors = extension_manifest_errors; |
51 | 52 |
52 namespace { | 53 namespace { |
53 | 54 |
54 const int kPEMOutputColumns = 65; | 55 const int kPEMOutputColumns = 65; |
55 | 56 |
56 // KEY MARKERS | 57 // KEY MARKERS |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 if (isolation_string == values::kIsolatedStorage) { | 1156 if (isolation_string == values::kIsolatedStorage) { |
1156 is_storage_isolated_ = true; | 1157 is_storage_isolated_ = true; |
1157 } else { | 1158 } else { |
1158 LOG(WARNING) << "Did not recognize isolation type: " | 1159 LOG(WARNING) << "Did not recognize isolation type: " |
1159 << isolation_string; | 1160 << isolation_string; |
1160 } | 1161 } |
1161 } | 1162 } |
1162 return true; | 1163 return true; |
1163 } | 1164 } |
1164 | 1165 |
| 1166 bool Extension::LoadWebIntents(const base::DictionaryValue& manifest, |
| 1167 std::string* error) { |
| 1168 DCHECK(error); |
| 1169 |
| 1170 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) |
| 1171 return true; |
| 1172 |
| 1173 if (!manifest.HasKey(keys::kIntents)) |
| 1174 return true; |
| 1175 |
| 1176 DictionaryValue* all_intents = NULL; |
| 1177 if (!manifest.GetDictionary(keys::kIntents, &all_intents)) { |
| 1178 *error = errors::kInvalidIntents; |
| 1179 return false; |
| 1180 } |
| 1181 |
| 1182 std::string value; |
| 1183 for (DictionaryValue::key_iterator iter(all_intents->begin_keys()); |
| 1184 iter != all_intents->end_keys(); ++iter) { |
| 1185 WebIntentServiceData intent; |
| 1186 |
| 1187 DictionaryValue* one_intent = NULL; |
| 1188 if (!all_intents->GetDictionaryWithoutPathExpansion(*iter, &one_intent)) { |
| 1189 *error = errors::kInvalidIntent; |
| 1190 return false; |
| 1191 } |
| 1192 intent.action = UTF8ToUTF16(*iter); |
| 1193 |
| 1194 // TODO(groby): Support an array of types. |
| 1195 if (one_intent->HasKey(keys::kIntentType) && |
| 1196 !one_intent->GetString(keys::kIntentType, &intent.type)) { |
| 1197 *error = errors::kInvalidIntentType; |
| 1198 return false; |
| 1199 } |
| 1200 |
| 1201 if (one_intent->HasKey(keys::kIntentPath)) { |
| 1202 if (!one_intent->GetString(keys::kIntentPath, &value)) { |
| 1203 *error = errors::kInvalidIntentPath; |
| 1204 return false; |
| 1205 } |
| 1206 intent.service_url = GetResourceURL(value); |
| 1207 } |
| 1208 |
| 1209 if (one_intent->HasKey(keys::kIntentTitle) && |
| 1210 !one_intent->GetString(keys::kIntentTitle, &intent.title)) { |
| 1211 *error = errors::kInvalidIntentTitle; |
| 1212 return false; |
| 1213 } |
| 1214 |
| 1215 if (one_intent->HasKey(keys::kIntentDisposition)) { |
| 1216 if (!one_intent->GetString(keys::kIntentDisposition, &value) || |
| 1217 (value != values::kIntentDispositionWindow && |
| 1218 value != values::kIntentDispositionInline)) { |
| 1219 *error = errors::kInvalidIntentDisposition; |
| 1220 return false; |
| 1221 } |
| 1222 if (value == values::kIntentDispositionInline) |
| 1223 intent.disposition = WebIntentServiceData::DISPOSITION_INLINE; |
| 1224 else |
| 1225 intent.disposition = WebIntentServiceData::DISPOSITION_WINDOW; |
| 1226 } |
| 1227 |
| 1228 intents_.push_back(intent); |
| 1229 } |
| 1230 return true; |
| 1231 } |
| 1232 |
| 1233 |
1165 bool Extension::EnsureNotHybridApp(const DictionaryValue* manifest, | 1234 bool Extension::EnsureNotHybridApp(const DictionaryValue* manifest, |
1166 std::string* error) { | 1235 std::string* error) { |
1167 if (web_extent().is_empty()) | 1236 if (web_extent().is_empty()) |
1168 return true; | 1237 return true; |
1169 | 1238 |
1170 for (DictionaryValue::key_iterator key = manifest->begin_keys(); | 1239 for (DictionaryValue::key_iterator key = manifest->begin_keys(); |
1171 key != manifest->end_keys(); ++key) { | 1240 key != manifest->end_keys(); ++key) { |
1172 if (!IsBaseCrxKey(*key) && | 1241 if (!IsBaseCrxKey(*key) && |
1173 *key != keys::kApp && | 1242 *key != keys::kApp && |
1174 *key != keys::kPermissions && | 1243 *key != keys::kPermissions && |
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 } | 2334 } |
2266 voice_data.event_types.insert(event_type); | 2335 voice_data.event_types.insert(event_type); |
2267 } | 2336 } |
2268 } | 2337 } |
2269 | 2338 |
2270 tts_voices_.push_back(voice_data); | 2339 tts_voices_.push_back(voice_data); |
2271 } | 2340 } |
2272 } | 2341 } |
2273 } | 2342 } |
2274 | 2343 |
| 2344 // Initialize web intents (optional). |
| 2345 if (!LoadWebIntents(source, error)) |
| 2346 return false; |
| 2347 |
2275 // Initialize incognito behavior. Apps default to split mode, extensions | 2348 // Initialize incognito behavior. Apps default to split mode, extensions |
2276 // default to spanning. | 2349 // default to spanning. |
2277 incognito_split_mode_ = is_app(); | 2350 incognito_split_mode_ = is_app(); |
2278 if (source.HasKey(keys::kIncognito)) { | 2351 if (source.HasKey(keys::kIncognito)) { |
2279 std::string value; | 2352 std::string value; |
2280 if (!source.GetString(keys::kIncognito, &value)) { | 2353 if (!source.GetString(keys::kIncognito, &value)) { |
2281 *error = errors::kInvalidIncognitoBehavior; | 2354 *error = errors::kInvalidIncognitoBehavior; |
2282 return false; | 2355 return false; |
2283 } | 2356 } |
2284 if (value == values::kIncognitoSpanning) { | 2357 if (value == values::kIncognitoSpanning) { |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 already_disabled(false), | 2970 already_disabled(false), |
2898 extension(extension) {} | 2971 extension(extension) {} |
2899 | 2972 |
2900 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 2973 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
2901 const Extension* extension, | 2974 const Extension* extension, |
2902 const ExtensionPermissionSet* permissions, | 2975 const ExtensionPermissionSet* permissions, |
2903 Reason reason) | 2976 Reason reason) |
2904 : reason(reason), | 2977 : reason(reason), |
2905 extension(extension), | 2978 extension(extension), |
2906 permissions(permissions) {} | 2979 permissions(permissions) {} |
OLD | NEW |