// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "extensions/common/manifest_handlers/csp_info.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "extensions/common/csp_validator.h" #include "extensions/common/install_warning.h" #include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_handlers/sandboxed_page_info.h" namespace extensions { namespace keys = manifest_keys; namespace errors = manifest_errors; using csp_validator::ContentSecurityPolicyIsLegal; using csp_validator::SanitizeContentSecurityPolicy; namespace { const char kDefaultContentSecurityPolicy[] = "script-src 'self' blob: filesystem: chrome-extension-resource:; " "object-src 'self' blob: filesystem:;"; #define PLATFORM_APP_LOCAL_CSP_SOURCES \ "'self' blob: filesystem: data: chrome-extension-resource:" const char kDefaultPlatformAppContentSecurityPolicy[] = // Platform apps can only use local resources by default. "default-src 'self' blob: filesystem: chrome-extension-resource:;" // For remote resources, they can fetch them via XMLHttpRequest. " connect-src * data: blob: filesystem:;" // And serve them via data: or same-origin (blob:, filesystem:) URLs " style-src " PLATFORM_APP_LOCAL_CSP_SOURCES " 'unsafe-inline';" " img-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";" " frame-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";" " font-src " PLATFORM_APP_LOCAL_CSP_SOURCES ";" // Media can be loaded from remote resources since: // 1.