diff options
Diffstat (limited to 'chrome/common/extensions/url_pattern.h')
-rw-r--r-- | chrome/common/extensions/url_pattern.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/chrome/common/extensions/url_pattern.h b/chrome/common/extensions/url_pattern.h index 723dc2c..edd92d4 100644 --- a/chrome/common/extensions/url_pattern.h +++ b/chrome/common/extensions/url_pattern.h @@ -91,15 +91,23 @@ class URLPattern { SCHEME_ALL = -1, }; + // Options for URLPattern::Parse(). + enum ParseOption { + PARSE_LENIENT, + PARSE_STRICT + }; + // Error codes returned from Parse(). enum ParseResult { - PARSE_SUCCESS, + PARSE_SUCCESS = 0, PARSE_ERROR_MISSING_SCHEME_SEPARATOR, PARSE_ERROR_INVALID_SCHEME, PARSE_ERROR_WRONG_SCHEME_SEPARATOR, PARSE_ERROR_EMPTY_HOST, PARSE_ERROR_INVALID_HOST_WILDCARD, PARSE_ERROR_EMPTY_PATH, + PARSE_ERROR_HAS_COLON, // Only checked when strict checks are enabled. + NUM_PARSE_RESULTS }; // The <all_urls> string pattern. @@ -149,8 +157,16 @@ class URLPattern { // Initializes this instance by parsing the provided string. Returns // URLPattern::PARSE_SUCCESS on success, or an error code otherwise. On // failure, this instance will have some intermediate values and is in an - // invalid state. - ParseResult Parse(const std::string& pattern_str); + // invalid state. Adding error checks to URLPattern::Parse() can cause + // patterns in installed extensions to fail. If an installed extension + // uses a pattern that was valid but fails a new error check, the + // extension will fail to load when chrome is auto-updated. To avoid + // this, new parse checks are enabled only when |strictness| is + // OPTION_STRICT. OPTION_STRICT should be used when loading in developer + // mode, or when an extension's patterns are controlled by chrome (such + // as component extensions). + ParseResult Parse(const std::string& pattern_str, + ParseOption strictness); // Sets the scheme for pattern matches. This can be a single '*' if the // pattern matches all valid schemes (as defined by the valid_schemes_ @@ -205,6 +221,9 @@ class URLPattern { }; }; + // Get an error string for a ParseResult. + static const char* GetParseResultString(URLPattern::ParseResult parse_result); + private: #if !(defined(_MSC_VER) && _MSC_VER >= 1600) friend class std::vector<URLPattern>; |