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

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

Issue 7811006: Add full support for filesystem URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added TODO for markusheintz Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 return NULL; 828 return NULL;
829 } 829 }
830 for (size_t i = 0; i < list_value->GetSize(); ++i) { 830 for (size_t i = 0; i < list_value->GetSize(); ++i) {
831 std::string filter; 831 std::string filter;
832 if (!list_value->GetString(i, &filter)) { 832 if (!list_value->GetString(i, &filter)) {
833 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 833 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
834 errors::kInvalidFileFilterValue, base::IntToString(i)); 834 errors::kInvalidFileFilterValue, base::IntToString(i));
835 return NULL; 835 return NULL;
836 } 836 }
837 StringToLowerASCII(&filter); 837 StringToLowerASCII(&filter);
838 if (filter.substr(0, 10) != chrome::kFileSystemScheme ||
Aaron Boodman 2012/03/12 23:17:13 Can you use StartsWith()?
ericu 2012/03/13 21:58:47 Done.
839 filter[10] != ':') {
840 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
841 errors::kInvalidURLPatternError, filter);
842 return NULL;
843 }
844 filter.replace(11, 0, "chrome-extension://*/");
Aaron Boodman 2012/03/12 23:21:45 Why?
ericu 2012/03/13 21:58:47 Added a comment.
838 URLPattern pattern(URLPattern::SCHEME_FILESYSTEM); 845 URLPattern pattern(URLPattern::SCHEME_FILESYSTEM);
846 pattern.SetValidInnerSchemes(URLPattern::SCHEME_EXTENSION);
839 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { 847 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) {
840 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 848 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
841 errors::kInvalidURLPatternError, filter); 849 errors::kInvalidURLPatternError, filter);
842 return NULL; 850 return NULL;
843 } 851 }
844 std::string path = pattern.path(); 852 std::string path = pattern.path();
845 bool allowed = path == "*" || path == "*.*" || 853 bool allowed = path == "/*" || path == "/*.*" ||
846 (path.compare(0, 2, "*.") == 0 && 854 (path.compare(0, 3, "/*.") == 0 &&
847 path.find_first_of('*', 2) == std::string::npos); 855 path.find_first_of('*', 3) == std::string::npos);
848 if (!allowed) { 856 if (!allowed) {
849 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 857 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
850 errors::kInvalidURLPatternError, filter); 858 errors::kInvalidURLPatternError, filter);
851 return NULL; 859 return NULL;
852 } 860 }
853 result->AddPattern(pattern); 861 result->AddPattern(pattern);
854 } 862 }
855 863
856 std::string default_icon; 864 std::string default_icon;
857 // Read the file browser action |default_icon| (optional). 865 // Read the file browser action |default_icon| (optional).
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after
3080 already_disabled(false), 3088 already_disabled(false),
3081 extension(extension) {} 3089 extension(extension) {}
3082 3090
3083 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3091 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3084 const Extension* extension, 3092 const Extension* extension,
3085 const ExtensionPermissionSet* permissions, 3093 const ExtensionPermissionSet* permissions,
3086 Reason reason) 3094 Reason reason)
3087 : reason(reason), 3095 : reason(reason),
3088 extension(extension), 3096 extension(extension),
3089 permissions(permissions) {} 3097 permissions(permissions) {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698