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

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

Issue 12253022: Manifest handler for all keys background-related. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months 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
« no previous file with comments | « chrome/common/extensions/csp_handler.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/csp_handler.h" 5 #include "chrome/common/extensions/csp_handler.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 CSPHandler::CSPHandler(bool is_platform_app) 63 CSPHandler::CSPHandler(bool is_platform_app)
64 : is_platform_app_(is_platform_app) { 64 : is_platform_app_(is_platform_app) {
65 } 65 }
66 66
67 CSPHandler::~CSPHandler() { 67 CSPHandler::~CSPHandler() {
68 } 68 }
69 69
70 bool CSPHandler::Parse(Extension* extension, string16* error) { 70 bool CSPHandler::Parse(Extension* extension, string16* error) {
71 const std::string& key = is_platform_app_ ? 71 const std::string key = Keys()[0];
72 keys::kPlatformAppContentSecurityPolicy : keys::kContentSecurityPolicy;
73
74 if (!extension->manifest()->HasPath(key)) { 72 if (!extension->manifest()->HasPath(key)) {
75 if (extension->manifest_version() >= 2) { 73 if (extension->manifest_version() >= 2) {
76 // TODO(abarth): Should we continue to let extensions override the 74 // TODO(abarth): Should we continue to let extensions override the
77 // default Content-Security-Policy? 75 // default Content-Security-Policy?
78 std::string content_security_policy = is_platform_app_ ? 76 std::string content_security_policy = is_platform_app_ ?
79 kDefaultPlatformAppContentSecurityPolicy : 77 kDefaultPlatformAppContentSecurityPolicy :
80 kDefaultContentSecurityPolicy; 78 kDefaultContentSecurityPolicy;
81 79
82 CHECK(ContentSecurityPolicyIsSecure(content_security_policy, 80 CHECK(ContentSecurityPolicyIsSecure(content_security_policy,
83 extension->GetType())); 81 extension->GetType()));
(...skipping 17 matching lines...) Expand all
101 extension->GetType())) { 99 extension->GetType())) {
102 *error = ASCIIToUTF16(errors::kInsecureContentSecurityPolicy); 100 *error = ASCIIToUTF16(errors::kInsecureContentSecurityPolicy);
103 return false; 101 return false;
104 } 102 }
105 103
106 extension->SetManifestData(keys::kContentSecurityPolicy, 104 extension->SetManifestData(keys::kContentSecurityPolicy,
107 new CSPInfo(content_security_policy)); 105 new CSPInfo(content_security_policy));
108 return true; 106 return true;
109 } 107 }
110 108
111 bool CSPHandler::AlwaysParseForType(Manifest::Type type) { 109 bool CSPHandler::AlwaysParseForType(Manifest::Type type) const {
112 if (is_platform_app_) 110 if (is_platform_app_)
113 return type == Manifest::TYPE_PLATFORM_APP; 111 return type == Manifest::TYPE_PLATFORM_APP;
114 else 112 else
115 return type == Manifest::TYPE_EXTENSION || 113 return type == Manifest::TYPE_EXTENSION ||
116 type == Manifest::TYPE_LEGACY_PACKAGED_APP; 114 type == Manifest::TYPE_LEGACY_PACKAGED_APP;
117 } 115 }
118 116
117 const std::vector<std::string> CSPHandler::Keys() const {
118 const std::string& key = is_platform_app_ ?
119 keys::kPlatformAppContentSecurityPolicy : keys::kContentSecurityPolicy;
120 return SingleKey(key);
121 }
122
119 } // namespace extensions 123 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/csp_handler.h ('k') | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698