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

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

Issue 199074: Don't allow updating tabs to javascript URLs without host (Closed)
Patch Set: Remove unchanged file Created 11 years, 3 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 } 975 }
976 976
977 // Only accept http/https persmissions at the moment. 977 // Only accept http/https persmissions at the moment.
978 if ((pattern.scheme() != chrome::kHttpScheme) && 978 if ((pattern.scheme() != chrome::kHttpScheme) &&
979 (pattern.scheme() != chrome::kHttpsScheme)) { 979 (pattern.scheme() != chrome::kHttpsScheme)) {
980 *error = ExtensionErrorUtils::FormatErrorMessage( 980 *error = ExtensionErrorUtils::FormatErrorMessage(
981 errors::kInvalidPermissionScheme, IntToString(i)); 981 errors::kInvalidPermissionScheme, IntToString(i));
982 return false; 982 return false;
983 } 983 }
984 984
985 // The path component is not used for host permissions, so we force it to
Erik does not do reviews 2009/09/10 18:23:21 I guess this means we can wind up with multiple du
Aaron Boodman 2009/09/10 18:55:31 Actually the permissions are kept in a vector now,
986 // match all paths.
987 pattern.set_path("/*");
988
985 host_permissions_.push_back(pattern); 989 host_permissions_.push_back(pattern);
986 } 990 }
987 } 991 }
988 992
989 // Initialize default locale (if present). 993 // Initialize default locale (if present).
990 if (source.HasKey(keys::kDefaultLocale)) { 994 if (source.HasKey(keys::kDefaultLocale)) {
991 std::string default_locale; 995 std::string default_locale;
992 if (!source.GetString(keys::kDefaultLocale, &default_locale)) { 996 if (!source.GetString(keys::kDefaultLocale, &default_locale)) {
993 *error = errors::kInvalidDefaultLocale; 997 *error = errors::kInvalidDefaultLocale;
994 return false; 998 return false;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 } 1084 }
1081 1085
1082 FilePath Extension::GetIconPath(Icons icon) { 1086 FilePath Extension::GetIconPath(Icons icon) {
1083 std::map<int, std::string>::const_iterator iter = 1087 std::map<int, std::string>::const_iterator iter =
1084 icons_.find(Extension::EXTENSION_ICON_LARGE); 1088 icons_.find(Extension::EXTENSION_ICON_LARGE);
1085 if (iter == icons_.end()) 1089 if (iter == icons_.end())
1086 return FilePath(); 1090 return FilePath();
1087 return GetResourcePath(iter->second); 1091 return GetResourcePath(iter->second);
1088 } 1092 }
1089 1093
1094 bool Extension::CanAccessHost(const GURL& url) const {
1095 for (HostPermissions::const_iterator host = host_permissions_.begin();
1096 host != host_permissions_.end(); ++host) {
1097 if (host->MatchesUrl(url))
1098 return true;
1099 }
1100
1101 return false;
1102 }
1103
1090 const std::set<std::string> Extension::GetEffectiveHostPermissions() const { 1104 const std::set<std::string> Extension::GetEffectiveHostPermissions() const {
1091 std::set<std::string> effective_hosts; 1105 std::set<std::string> effective_hosts;
1092 1106
1093 for (HostPermissions::const_iterator host = host_permissions_.begin(); 1107 for (HostPermissions::const_iterator host = host_permissions_.begin();
1094 host != host_permissions_.end(); ++host) 1108 host != host_permissions_.end(); ++host)
1095 effective_hosts.insert(host->host()); 1109 effective_hosts.insert(host->host());
1096 1110
1097 for (UserScriptList::const_iterator content_script = content_scripts_.begin(); 1111 for (UserScriptList::const_iterator content_script = content_scripts_.begin();
1098 content_script != content_scripts_.end(); ++content_script) { 1112 content_script != content_scripts_.end(); ++content_script) {
1099 UserScript::PatternList::const_iterator pattern = 1113 UserScript::PatternList::const_iterator pattern =
(...skipping 17 matching lines...) Expand all
1117 UserScript::PatternList::const_iterator pattern = 1131 UserScript::PatternList::const_iterator pattern =
1118 content_script->url_patterns().begin(); 1132 content_script->url_patterns().begin();
1119 for (; pattern != content_script->url_patterns().end(); ++pattern) { 1133 for (; pattern != content_script->url_patterns().end(); ++pattern) {
1120 if (pattern->match_subdomains() && pattern->host().empty()) 1134 if (pattern->match_subdomains() && pattern->host().empty())
1121 return true; 1135 return true;
1122 } 1136 }
1123 } 1137 }
1124 1138
1125 return false; 1139 return false;
1126 } 1140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698