1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "extensions/browser/api/declarative_net_request/constants.h" 6 7 #include "extensions/common/constants.h" 8 #include "url/url_constants.h" 9 10 namespace extensions { 11 namespace declarative_net_request { 12 13 const char* const kAllowedTransformSchemes[4] = { 14 url::kHttpScheme, url::kHttpsScheme, url::kFtpScheme, 15 extensions::kExtensionScheme}; 16 17 const char kErrorResourceTypeDuplicated[] = 18 "Rule with id * includes and excludes the same resource."; 19 const char kErrorInvalidRuleKey[] = 20 "Rule with id * has an invalid value for * key. This should be greater " 21 "than or equal to *."; 22 const char kErrorEmptyRulePriority[] = 23 "Rule with id * does not specify the value for priority key."; 24 const char kErrorNoApplicableResourceTypes[] = 25 "Rule with id * is not applicable to any resource type."; 26 const char kErrorEmptyList[] = 27 "Rule with id * cannot have an empty list as the value for * key."; 28 const char kErrorEmptyKey[] = 29 "Rule with id * cannot have an empty value for * key."; 30 const char kErrorInvalidRedirectUrl[] = 31 "Rule with id * does not provide a valid URL for * key."; 32 const char kErrorDuplicateIDs[] = "Rule with id * does not have a unique ID."; 33 // Don't surface the actual error to the user, since it's an implementation 34 // detail. 35 const char kErrorPersisting[] = "Internal error while parsing rules."; 36 const char kErrorNonAscii[] = 37 "Rule with id * cannot have non-ascii characters as part of \"*\" key."; 38 const char kErrorInvalidKey[] = 39 "Rule with id * specifies an incorrect value for the \"*\" key."; 40 const char kErrorInvalidTransformScheme[] = 41 "Rule with id * specifies an incorrect value for the \"*\" key. Allowed " 42 "values are: [*]."; 43 const char kErrorQueryAndTransformBothSpecified[] = 44 "Rule with id * cannot specify both \"*\" and \"*\" keys."; 45 const char kErrorJavascriptRedirect[] = 46 "Rule with id * specifies an incorrect value for the \"*\" key. Redirects " 47 "to javascript urls are not supported."; 48 const char kErrorMultipleFilters[] = 49 "Rule with id * can only specify one of \"*\" or \"*\" keys."; 50 const char kErrorRegexSubstitutionWithoutFilter[] = 51 "Rule with id * can't specify the \"*\" key without specifying the \"*\" " 52 "key."; 53 const char kErrorInvalidAllowAllRequestsResourceType[] = 54 "Rule with id * is an \"allowAllRequests\" rule and must specify the " 55 "\"resourceTypes\" key. It may only include the \"main_frame\" and " 56 "\"sub_frame\" resource types."; 57 const char kErrorRegexTooLarge[] = 58 "Rule with id * specified a more complex regex than allowed as part of the " 59 "\"*\" key."; 60 const char kErrorRegexesTooLarge[] = 61 "Rules with ids [*] specified a more complex regex than allowed as part of " 62 "the \"*\" key."; 63 const char kErrorNoHeaderListsSpecified[] = 64 "Rule with id * does not specify a value for \"*\" or \"*\" key. At least " 65 "one of these keys must be specified with a non-empty list."; 66 const char kErrorInvalidHeaderName[] = 67 "Rule with id * must specify a valid header name to be modified."; 68 const char kErrorInvalidHeaderValue[] = 69 "Rule with id * specifies an invalid header value."; 70 const char kErrorNoHeaderValueSpecified[] = 71 "Rule with id * must provide a value for a header to be appended/set."; 72 const char kErrorHeaderValuePresent[] = 73 "Rule with id * must not provide a header value for a header to be " 74 "removed."; 75 const char kErrorCannotAppendRequestHeader[] = 76 "Rule with id * must not specify a request header to be appended."; 77 const char kErrorListNotPassed[] = "Rules file must contain a list."; 78 79 const char kRuleCountExceeded[] = 80 "Rule count exceeded. Some rules were ignored."; 81 const char kRegexRuleCountExceeded[] = 82 "Regular expression rule count exceeded. Some rules were ignored."; 83 const char kEnabledRuleCountExceeded[] = 84 "The number of enabled rules exceeds the API limits. Some rulesets will be " 85 "ignored."; 86 const char kEnabledRegexRuleCountExceeded[] = 87 "The number of enabled regular expression rules exceeds the API limits. " 88 "Some rulesets will be ignored."; 89 const char kRuleNotParsedWarning[] = 90 "Rule with * couldn't be parsed. Parse error: *."; 91 const char kTooManyParseFailuresWarning[] = 92 "Too many rule parse failures; Reporting the first *."; 93 const char kIndexingRuleLimitExceeded[] = 94 "Ruleset with id * exceeds the indexing rule limit and will be ignored."; 95 const char kInternalErrorUpdatingDynamicRules[] = 96 "Internal error while updating dynamic rules."; 97 const char kInternalErrorGettingDynamicRules[] = 98 "Internal error while getting dynamic rules."; 99 const char kDynamicRuleCountExceeded[] = "Dynamic rule count exceeded."; 100 const char kDynamicRegexRuleCountExceeded[] = 101 "Dynamic rule count for regex rules exceeded."; 102 103 const char kInvalidRulesetIDError[] = "Invalid ruleset id: *."; 104 const char kEnabledRulesetsRuleCountExceeded[] = 105 "The set of enabled rulesets exceeds the rule count limit."; 106 const char kEnabledRulesetsRegexRuleCountExceeded[] = 107 "The set of enabled rulesets exceeds the regular expression rule count " 108 "limit."; 109 const char kInternalErrorUpdatingEnabledRulesets[] = "Internal error."; 110 111 const char kIndexAndPersistRulesTimeHistogram[] = 112 "Extensions.DeclarativeNetRequest.IndexAndPersistRulesTime"; 113 const char kManifestRulesCountHistogram[] = 114 "Extensions.DeclarativeNetRequest.ManifestRulesCount2"; 115 const char kManifestEnabledRulesCountHistogram[] = 116 "Extensions.DeclarativeNetRequest.ManifestEnabledRulesCount2"; 117 const char kUpdateDynamicRulesStatusHistogram[] = 118 "Extensions.DeclarativeNetRequest.UpdateDynamicRulesStatus"; 119 const char kReadDynamicRulesJSONStatusHistogram[] = 120 "Extensions.DeclarativeNetRequest.ReadDynamicRulesJSONStatus"; 121 const char kIsLargeRegexHistogram[] = 122 "Extensions.DeclarativeNetRequest.IsLargeRegexRule"; 123 const char kLoadRulesetResultHistogram[] = 124 "Extensions.DeclarativeNetRequest.LoadRulesetResult"; 125 126 const char kActionCountPlaceholderBadgeText[] = 127 "<<declarativeNetRequestActionCount>>"; 128 129 const char kErrorGetMatchedRulesMissingPermissions[] = 130 "The extension must have the declarativeNetRequestFeedback permission or " 131 "have activeTab granted for the specified tab ID in order to call this " 132 "function."; 133 134 const base::Feature kDeclarativeNetRequestGlobalRules{ 135 "DeclarativeNetRequestGlobalRules", base::FEATURE_DISABLED_BY_DEFAULT}; 136 137 } // namespace declarative_net_request 138 } // namespace extensions 139