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

Side by Side Diff: chrome/common/extensions/url_pattern.h

Issue 2870027: Fix a memory leak in ExtensionExtentUnittest by fixing a bad (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: remove unneeded header from url_pattern.h Created 10 years, 6 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 #ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ 4 #ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_
5 #define CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ 5 #define CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // subdomain matching. We can pick up at least another 10% by supporting 66 // subdomain matching. We can pick up at least another 10% by supporting
67 // subdomain matching. It is probably possible to coerce more of the existing 67 // subdomain matching. It is probably possible to coerce more of the existing
68 // patterns to URLPattern, but the resulting pattern will be more restrictive 68 // patterns to URLPattern, but the resulting pattern will be more restrictive
69 // than the original glob, which is probably better than nothing. 69 // than the original glob, which is probably better than nothing.
70 class URLPattern { 70 class URLPattern {
71 public: 71 public:
72 // Returns true if the specified scheme can be used in URL patterns, and false 72 // Returns true if the specified scheme can be used in URL patterns, and false
73 // otherwise. 73 // otherwise.
74 static bool IsValidScheme(const std::string& scheme); 74 static bool IsValidScheme(const std::string& scheme);
75 75
76 // Convenience to create a pattern from a string. 76 URLPattern();
77 static URLPattern* CreateFromString(const std::string& pattern);
78 77
79 URLPattern() : match_subdomains_(false) {} 78 // Convenience to construct a URLPattern from a string. The string is expected
79 // to be a valid pattern. If the string is not known ahead of time, use
80 // Parse() instead, which returns success or failure.
81 explicit URLPattern(const std::string& pattern);
80 82
81 // Initializes this instance by parsing the provided string. On failure, the 83 // Initializes this instance by parsing the provided string. On failure, the
82 // instance will have some intermediate values and is in an invalid state. 84 // instance will have some intermediate values and is in an invalid state.
83 bool Parse(const std::string& pattern_str); 85 bool Parse(const std::string& pattern_str);
84 86
85 // Returns true if this instance matches the specified URL. 87 // Returns true if this instance matches the specified URL.
86 bool MatchesUrl(const GURL& url) const; 88 bool MatchesUrl(const GURL& url) const;
87 89
88 // Returns true if |test| matches our host. 90 // Returns true if |test| matches our host.
89 bool MatchesHost(const std::string& host) const; 91 bool MatchesHost(const std::string& host) const;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // everything after the scheme in the case of file:// URLs. 133 // everything after the scheme in the case of file:// URLs.
132 std::string path_; 134 std::string path_;
133 135
134 // The path with "?" and "\" characters escaped for use with the 136 // The path with "?" and "\" characters escaped for use with the
135 // MatchPatternASCII() function. This is populated lazily, the first time it 137 // MatchPatternASCII() function. This is populated lazily, the first time it
136 // is needed. 138 // is needed.
137 mutable std::string path_escaped_; 139 mutable std::string path_escaped_;
138 }; 140 };
139 141
140 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_ 142 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_extent_unittest.cc ('k') | chrome/common/extensions/url_pattern.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698