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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 const std::string& permission_str = *iter; | 173 const std::string& permission_str = *iter; |
174 | 174 |
175 // Check if it's a host pattern permission. | 175 // Check if it's a host pattern permission. |
176 URLPattern pattern = URLPattern(kAllowedSchemes); | 176 URLPattern pattern = URLPattern(kAllowedSchemes); |
177 URLPattern::ParseResult parse_result = pattern.Parse(permission_str); | 177 URLPattern::ParseResult parse_result = pattern.Parse(permission_str); |
178 if (parse_result == URLPattern::PARSE_SUCCESS) { | 178 if (parse_result == URLPattern::PARSE_SUCCESS) { |
179 // The path component is not used for host permissions, so we force it | 179 // The path component is not used for host permissions, so we force it |
180 // to match all paths. | 180 // to match all paths. |
181 pattern.SetPath("/*"); | 181 pattern.SetPath("/*"); |
182 int valid_schemes = pattern.valid_schemes(); | 182 int valid_schemes = pattern.valid_schemes(); |
183 if (pattern.MatchesScheme(content::kFileScheme) && | 183 if (pattern.MatchesScheme(url::kFileScheme) && |
184 !PermissionsData::CanExecuteScriptEverywhere(extension)) { | 184 !PermissionsData::CanExecuteScriptEverywhere(extension)) { |
185 extension->set_wants_file_access(true); | 185 extension->set_wants_file_access(true); |
186 if (!(extension->creation_flags() & Extension::ALLOW_FILE_ACCESS)) | 186 if (!(extension->creation_flags() & Extension::ALLOW_FILE_ACCESS)) |
187 valid_schemes &= ~URLPattern::SCHEME_FILE; | 187 valid_schemes &= ~URLPattern::SCHEME_FILE; |
188 } | 188 } |
189 | 189 |
190 if (pattern.scheme() != content::kChromeUIScheme && | 190 if (pattern.scheme() != content::kChromeUIScheme && |
191 !PermissionsData::CanExecuteScriptEverywhere(extension)) { | 191 !PermissionsData::CanExecuteScriptEverywhere(extension)) { |
192 // Keep chrome:// in allowed schemes only if it's explicitly requested | 192 // Keep chrome:// in allowed schemes only if it's explicitly requested |
193 // or CanExecuteScriptEverywhere is true. If the | 193 // or CanExecuteScriptEverywhere is true. If the |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 initial_optional_permissions_->api_permissions, | 647 initial_optional_permissions_->api_permissions, |
648 initial_optional_permissions_->manifest_permissions, | 648 initial_optional_permissions_->manifest_permissions, |
649 initial_optional_permissions_->host_permissions, | 649 initial_optional_permissions_->host_permissions, |
650 URLPatternSet()); | 650 URLPatternSet()); |
651 | 651 |
652 initial_required_permissions_.reset(); | 652 initial_required_permissions_.reset(); |
653 initial_optional_permissions_.reset(); | 653 initial_optional_permissions_.reset(); |
654 } | 654 } |
655 | 655 |
656 } // namespace extensions | 656 } // namespace extensions |
OLD | NEW |