| 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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI; | 334 UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_CHROMEUI; |
| 335 | 335 |
| 336 Extension::Requirements::Requirements() | 336 Extension::Requirements::Requirements() |
| 337 : webgl(false), | 337 : webgl(false), |
| 338 css3d(false), | 338 css3d(false), |
| 339 npapi(false) { | 339 npapi(false) { |
| 340 } | 340 } |
| 341 | 341 |
| 342 Extension::Requirements::~Requirements() {} | 342 Extension::Requirements::~Requirements() {} |
| 343 | 343 |
| 344 Extension::OAuth2Info::OAuth2Info() {} | |
| 345 Extension::OAuth2Info::~OAuth2Info() {} | |
| 346 | |
| 347 Extension::ActionInfo::ActionInfo() {} | 344 Extension::ActionInfo::ActionInfo() {} |
| 348 Extension::ActionInfo::~ActionInfo() {} | 345 Extension::ActionInfo::~ActionInfo() {} |
| 349 | 346 |
| 350 // | 347 // |
| 351 // Extension | 348 // Extension |
| 352 // | 349 // |
| 353 | 350 |
| 354 bool Extension::InstallWarning::operator==(const InstallWarning& other) const { | 351 bool Extension::InstallWarning::operator==(const InstallWarning& other) const { |
| 355 return format == other.format && message == other.message; | 352 return format == other.format && message == other.message; |
| 356 } | 353 } |
| (...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1969 !LoadNaClModules(error) || | 1966 !LoadNaClModules(error) || |
| 1970 !LoadWebAccessibleResources(error) || | 1967 !LoadWebAccessibleResources(error) || |
| 1971 !LoadSandboxedPages(error) || | 1968 !LoadSandboxedPages(error) || |
| 1972 !LoadRequirements(error) || | 1969 !LoadRequirements(error) || |
| 1973 !LoadDefaultLocale(error) || | 1970 !LoadDefaultLocale(error) || |
| 1974 !LoadOfflineEnabled(error) || | 1971 !LoadOfflineEnabled(error) || |
| 1975 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). | 1972 // LoadBackgroundScripts() must be called before LoadBackgroundPage(). |
| 1976 !LoadBackgroundScripts(error) || | 1973 !LoadBackgroundScripts(error) || |
| 1977 !LoadBackgroundPage(api_permissions, error) || | 1974 !LoadBackgroundPage(api_permissions, error) || |
| 1978 !LoadBackgroundPersistent(api_permissions, error) || | 1975 !LoadBackgroundPersistent(api_permissions, error) || |
| 1979 !LoadBackgroundAllowJSAccess(api_permissions, error) || | 1976 !LoadBackgroundAllowJSAccess(api_permissions, error)) |
| 1980 !LoadOAuth2Info(error)) | |
| 1981 return false; | 1977 return false; |
| 1982 | 1978 |
| 1983 return true; | 1979 return true; |
| 1984 } | 1980 } |
| 1985 | 1981 |
| 1986 bool Extension::LoadDescription(string16* error) { | 1982 bool Extension::LoadDescription(string16* error) { |
| 1987 if (manifest_->HasKey(keys::kDescription) && | 1983 if (manifest_->HasKey(keys::kDescription) && |
| 1988 !manifest_->GetString(keys::kDescription, &description_)) { | 1984 !manifest_->GetString(keys::kDescription, &description_)) { |
| 1989 *error = ASCIIToUTF16(errors::kInvalidDescription); | 1985 *error = ASCIIToUTF16(errors::kInvalidDescription); |
| 1990 return false; | 1986 return false; |
| (...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3261 } | 3257 } |
| 3262 } else { | 3258 } else { |
| 3263 DCHECK(result->default_popup_url.is_empty()) | 3259 DCHECK(result->default_popup_url.is_empty()) |
| 3264 << "Shouldn't be possible for the popup to be set."; | 3260 << "Shouldn't be possible for the popup to be set."; |
| 3265 } | 3261 } |
| 3266 } | 3262 } |
| 3267 | 3263 |
| 3268 return result.Pass(); | 3264 return result.Pass(); |
| 3269 } | 3265 } |
| 3270 | 3266 |
| 3271 bool Extension::LoadOAuth2Info(string16* error) { | |
| 3272 if (!manifest_->HasKey(keys::kOAuth2)) | |
| 3273 return true; | |
| 3274 | |
| 3275 if (!manifest_->GetString(keys::kOAuth2ClientId, &oauth2_info_.client_id) || | |
| 3276 oauth2_info_.client_id.empty()) { | |
| 3277 *error = ASCIIToUTF16(errors::kInvalidOAuth2ClientId); | |
| 3278 return false; | |
| 3279 } | |
| 3280 | |
| 3281 ListValue* list = NULL; | |
| 3282 if (!manifest_->GetList(keys::kOAuth2Scopes, &list)) { | |
| 3283 *error = ASCIIToUTF16(errors::kInvalidOAuth2Scopes); | |
| 3284 return false; | |
| 3285 } | |
| 3286 | |
| 3287 for (size_t i = 0; i < list->GetSize(); ++i) { | |
| 3288 std::string scope; | |
| 3289 if (!list->GetString(i, &scope)) { | |
| 3290 *error = ASCIIToUTF16(errors::kInvalidOAuth2Scopes); | |
| 3291 return false; | |
| 3292 } | |
| 3293 oauth2_info_.scopes.push_back(scope); | |
| 3294 } | |
| 3295 | |
| 3296 return true; | |
| 3297 } | |
| 3298 | |
| 3299 bool Extension::HasMultipleUISurfaces() const { | 3267 bool Extension::HasMultipleUISurfaces() const { |
| 3300 int num_surfaces = 0; | 3268 int num_surfaces = 0; |
| 3301 | 3269 |
| 3302 if (page_action_info()) | 3270 if (page_action_info()) |
| 3303 ++num_surfaces; | 3271 ++num_surfaces; |
| 3304 | 3272 |
| 3305 if (browser_action_info()) | 3273 if (browser_action_info()) |
| 3306 ++num_surfaces; | 3274 ++num_surfaces; |
| 3307 | 3275 |
| 3308 if (is_app()) | 3276 if (is_app()) |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3480 | 3448 |
| 3481 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 3449 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
| 3482 const Extension* extension, | 3450 const Extension* extension, |
| 3483 const PermissionSet* permissions, | 3451 const PermissionSet* permissions, |
| 3484 Reason reason) | 3452 Reason reason) |
| 3485 : reason(reason), | 3453 : reason(reason), |
| 3486 extension(extension), | 3454 extension(extension), |
| 3487 permissions(permissions) {} | 3455 permissions(permissions) {} |
| 3488 | 3456 |
| 3489 } // namespace extensions | 3457 } // namespace extensions |
| OLD | NEW |