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 "extensions/common/permissions/permissions_data.h" | 5 #include "extensions/common/permissions/permissions_data.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 const std::string& permission_str = *iter; | 176 const std::string& permission_str = *iter; |
177 | 177 |
178 // Check if it's a host pattern permission. | 178 // Check if it's a host pattern permission. |
179 URLPattern pattern = URLPattern(kAllowedSchemes); | 179 URLPattern pattern = URLPattern(kAllowedSchemes); |
180 URLPattern::ParseResult parse_result = pattern.Parse(permission_str); | 180 URLPattern::ParseResult parse_result = pattern.Parse(permission_str); |
181 if (parse_result == URLPattern::PARSE_SUCCESS) { | 181 if (parse_result == URLPattern::PARSE_SUCCESS) { |
182 // The path component is not used for host permissions, so we force it | 182 // The path component is not used for host permissions, so we force it |
183 // to match all paths. | 183 // to match all paths. |
184 pattern.SetPath("/*"); | 184 pattern.SetPath("/*"); |
185 int valid_schemes = pattern.valid_schemes(); | 185 int valid_schemes = pattern.valid_schemes(); |
186 if (pattern.MatchesScheme(chrome::kFileScheme) && | 186 if (pattern.MatchesScheme(content::kFileScheme) && |
187 !PermissionsData::CanExecuteScriptEverywhere(extension)) { | 187 !PermissionsData::CanExecuteScriptEverywhere(extension)) { |
188 extension->set_wants_file_access(true); | 188 extension->set_wants_file_access(true); |
189 if (!(extension->creation_flags() & Extension::ALLOW_FILE_ACCESS)) | 189 if (!(extension->creation_flags() & Extension::ALLOW_FILE_ACCESS)) |
190 valid_schemes &= ~URLPattern::SCHEME_FILE; | 190 valid_schemes &= ~URLPattern::SCHEME_FILE; |
191 } | 191 } |
192 | 192 |
193 if (pattern.scheme() != chrome::kChromeUIScheme && | 193 if (pattern.scheme() != chrome::kChromeUIScheme && |
194 !PermissionsData::CanExecuteScriptEverywhere(extension)) { | 194 !PermissionsData::CanExecuteScriptEverywhere(extension)) { |
195 // Keep chrome:// in allowed schemes only if it's explicitly requested | 195 // Keep chrome:// in allowed schemes only if it's explicitly requested |
196 // or CanExecuteScriptEverywhere is true. If the | 196 // or CanExecuteScriptEverywhere is true. If the |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 initial_optional_permissions_->api_permissions, | 618 initial_optional_permissions_->api_permissions, |
619 initial_optional_permissions_->manifest_permissions, | 619 initial_optional_permissions_->manifest_permissions, |
620 initial_optional_permissions_->host_permissions, | 620 initial_optional_permissions_->host_permissions, |
621 URLPatternSet()); | 621 URLPatternSet()); |
622 | 622 |
623 initial_required_permissions_.reset(); | 623 initial_required_permissions_.reset(); |
624 initial_optional_permissions_.reset(); | 624 initial_optional_permissions_.reset(); |
625 } | 625 } |
626 | 626 |
627 } // namespace extensions | 627 } // namespace extensions |
OLD | NEW |