Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: chrome/common/extensions/extension.cc

Issue 8417043: Add webkit_glue namespace. Improve some variable and test names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 if (isolation_string == values::kIsolatedStorage) { 1159 if (isolation_string == values::kIsolatedStorage) {
1160 is_storage_isolated_ = true; 1160 is_storage_isolated_ = true;
1161 } else { 1161 } else {
1162 LOG(WARNING) << "Did not recognize isolation type: " 1162 LOG(WARNING) << "Did not recognize isolation type: "
1163 << isolation_string; 1163 << isolation_string;
1164 } 1164 }
1165 } 1165 }
1166 return true; 1166 return true;
1167 } 1167 }
1168 1168
1169 bool Extension::LoadWebIntents(const base::DictionaryValue& manifest, 1169 bool Extension::LoadWebIntentsServices(const base::DictionaryValue& manifest,
1170 std::string* error) { 1170 std::string* error) {
1171 DCHECK(error); 1171 DCHECK(error);
1172 1172
1173 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) 1173 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents))
1174 return true; 1174 return true;
1175 1175
1176 if (!manifest.HasKey(keys::kIntents)) 1176 if (!manifest.HasKey(keys::kIntents))
1177 return true; 1177 return true;
1178 1178
1179 DictionaryValue* all_intents = NULL; 1179 DictionaryValue* all_services = NULL;
1180 if (!manifest.GetDictionary(keys::kIntents, &all_intents)) { 1180 if (!manifest.GetDictionary(keys::kIntents, &all_services)) {
1181 *error = errors::kInvalidIntents; 1181 *error = errors::kInvalidIntents;
1182 return false; 1182 return false;
1183 } 1183 }
1184 1184
1185 std::string value; 1185 std::string value;
1186 for (DictionaryValue::key_iterator iter(all_intents->begin_keys()); 1186 for (DictionaryValue::key_iterator iter(all_services->begin_keys());
1187 iter != all_intents->end_keys(); ++iter) { 1187 iter != all_services->end_keys(); ++iter) {
1188 WebIntentServiceData intent; 1188 webkit_glue::WebIntentServiceData service;
1189 1189
1190 DictionaryValue* one_intent = NULL; 1190 DictionaryValue* one_service = NULL;
1191 if (!all_intents->GetDictionaryWithoutPathExpansion(*iter, &one_intent)) { 1191 if (!all_services->GetDictionaryWithoutPathExpansion(*iter, &one_service)) {
1192 *error = errors::kInvalidIntent; 1192 *error = errors::kInvalidIntent;
1193 return false; 1193 return false;
1194 } 1194 }
1195 intent.action = UTF8ToUTF16(*iter); 1195 service.action = UTF8ToUTF16(*iter);
1196 1196
1197 // TODO(groby): Support an array of types. 1197 // TODO(groby): Support an array of types.
1198 if (one_intent->HasKey(keys::kIntentType) && 1198 if (one_service->HasKey(keys::kIntentType) &&
1199 !one_intent->GetString(keys::kIntentType, &intent.type)) { 1199 !one_service->GetString(keys::kIntentType, &service.type)) {
1200 *error = errors::kInvalidIntentType; 1200 *error = errors::kInvalidIntentType;
1201 return false; 1201 return false;
1202 } 1202 }
1203 1203
1204 if (one_intent->HasKey(keys::kIntentPath)) { 1204 if (one_service->HasKey(keys::kIntentPath)) {
1205 if (!one_intent->GetString(keys::kIntentPath, &value)) { 1205 if (!one_service->GetString(keys::kIntentPath, &value)) {
1206 *error = errors::kInvalidIntentPath; 1206 *error = errors::kInvalidIntentPath;
1207 return false; 1207 return false;
1208 } 1208 }
1209 intent.service_url = GetResourceURL(value); 1209 service.service_url = GetResourceURL(value);
1210 } 1210 }
1211 1211
1212 if (one_intent->HasKey(keys::kIntentTitle) && 1212 if (one_service->HasKey(keys::kIntentTitle) &&
1213 !one_intent->GetString(keys::kIntentTitle, &intent.title)) { 1213 !one_service->GetString(keys::kIntentTitle, &service.title)) {
1214 *error = errors::kInvalidIntentTitle; 1214 *error = errors::kInvalidIntentTitle;
1215 return false; 1215 return false;
1216 } 1216 }
1217 1217
1218 if (one_intent->HasKey(keys::kIntentDisposition)) { 1218 if (one_service->HasKey(keys::kIntentDisposition)) {
1219 if (!one_intent->GetString(keys::kIntentDisposition, &value) || 1219 if (!one_service->GetString(keys::kIntentDisposition, &value) ||
1220 (value != values::kIntentDispositionWindow && 1220 (value != values::kIntentDispositionWindow &&
1221 value != values::kIntentDispositionInline)) { 1221 value != values::kIntentDispositionInline)) {
1222 *error = errors::kInvalidIntentDisposition; 1222 *error = errors::kInvalidIntentDisposition;
1223 return false; 1223 return false;
1224 } 1224 }
1225 if (value == values::kIntentDispositionInline) 1225 if (value == values::kIntentDispositionInline) {
1226 intent.disposition = WebIntentServiceData::DISPOSITION_INLINE; 1226 service.disposition =
1227 else 1227 webkit_glue::WebIntentServiceData::DISPOSITION_INLINE;
1228 intent.disposition = WebIntentServiceData::DISPOSITION_WINDOW; 1228 } else {
1229 service.disposition =
1230 webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW;
1231 }
1229 } 1232 }
1230 1233
1231 intents_.push_back(intent); 1234 intents_services_.push_back(service);
1232 } 1235 }
1233 return true; 1236 return true;
1234 } 1237 }
1235 1238
1236 1239
1237 bool Extension::EnsureNotHybridApp(const DictionaryValue* manifest, 1240 bool Extension::EnsureNotHybridApp(const DictionaryValue* manifest,
1238 std::string* error) { 1241 std::string* error) {
1239 if (web_extent().is_empty()) 1242 if (web_extent().is_empty())
1240 return true; 1243 return true;
1241 1244
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 voice_data.event_types.insert(event_type); 2312 voice_data.event_types.insert(event_type);
2310 } 2313 }
2311 } 2314 }
2312 2315
2313 tts_voices_.push_back(voice_data); 2316 tts_voices_.push_back(voice_data);
2314 } 2317 }
2315 } 2318 }
2316 } 2319 }
2317 2320
2318 // Initialize web intents (optional). 2321 // Initialize web intents (optional).
2319 if (!LoadWebIntents(source, error)) 2322 if (!LoadWebIntentsServices(source, error))
groby-ooo-7-16 2011/10/31 20:53:37 nit: Should that be LoadWebIntentServices (i.e. si
Greg Billock 2011/11/01 17:11:17 Yeah, that sounds better.
2320 return false; 2323 return false;
2321 2324
2322 // Initialize incognito behavior. Apps default to split mode, extensions 2325 // Initialize incognito behavior. Apps default to split mode, extensions
2323 // default to spanning. 2326 // default to spanning.
2324 incognito_split_mode_ = is_app(); 2327 incognito_split_mode_ = is_app();
2325 if (source.HasKey(keys::kIncognito)) { 2328 if (source.HasKey(keys::kIncognito)) {
2326 std::string value; 2329 std::string value;
2327 if (!source.GetString(keys::kIncognito, &value)) { 2330 if (!source.GetString(keys::kIncognito, &value)) {
2328 *error = errors::kInvalidIncognitoBehavior; 2331 *error = errors::kInvalidIncognitoBehavior;
2329 return false; 2332 return false;
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
2988 already_disabled(false), 2991 already_disabled(false),
2989 extension(extension) {} 2992 extension(extension) {}
2990 2993
2991 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 2994 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
2992 const Extension* extension, 2995 const Extension* extension,
2993 const ExtensionPermissionSet* permissions, 2996 const ExtensionPermissionSet* permissions,
2994 Reason reason) 2997 Reason reason)
2995 : reason(reason), 2998 : reason(reason),
2996 extension(extension), 2999 extension(extension),
2997 permissions(permissions) {} 3000 permissions(permissions) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698