feat: add excludeUrls and modify urls in WebRequestFilter for better URL filtering (#45678)
* feat: add excludeUrls and modify urls in WebRequestFilter for better URL filtering (#44692) * feat: add excludeUrls to web request filter * refactor: add deprecated field * test: update tests * lint: newline * docs: improve API doc * fix: add is filter defined property to match all urls * refactor: remove includeUrls * refactor: remove typescript binding * refactor: all_url * refactor: remove isDefined methods * refactor: remove comment * fix: logic * docs: add to breaking changes * docs: remove unneeded section
This commit is contained in:
		
					parent
					
						
							
								d291fa6ced
							
						
					
				
			
			
				commit
				
					
						5a641e02ee
					
				
			
		
					 6 changed files with 150 additions and 32 deletions
				
			
		| 
						 | 
				
			
			@ -51,6 +51,8 @@ class WebRequest final : public gin::Wrappable<WebRequest>,
 | 
			
		|||
  static gin::Handle<WebRequest> From(v8::Isolate* isolate,
 | 
			
		||||
                                      content::BrowserContext* browser_context);
 | 
			
		||||
 | 
			
		||||
  static const char* GetClassName() { return "WebRequest"; }
 | 
			
		||||
 | 
			
		||||
  // gin::Wrappable:
 | 
			
		||||
  static gin::WrapperInfo kWrapperInfo;
 | 
			
		||||
  gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
 | 
			
		||||
| 
						 | 
				
			
			@ -156,21 +158,28 @@ class WebRequest final : public gin::Wrappable<WebRequest>,
 | 
			
		|||
  class RequestFilter {
 | 
			
		||||
   public:
 | 
			
		||||
    RequestFilter(std::set<URLPattern>,
 | 
			
		||||
                  std::set<URLPattern>,
 | 
			
		||||
                  std::set<extensions::WebRequestResourceType>);
 | 
			
		||||
    RequestFilter(const RequestFilter&);
 | 
			
		||||
    RequestFilter();
 | 
			
		||||
    ~RequestFilter();
 | 
			
		||||
 | 
			
		||||
    void AddUrlPattern(URLPattern pattern);
 | 
			
		||||
    void AddUrlPattern(URLPattern pattern, bool is_match_pattern);
 | 
			
		||||
    void AddUrlPatterns(const std::set<std::string>& filter_patterns,
 | 
			
		||||
                        RequestFilter* filter,
 | 
			
		||||
                        gin::Arguments* args,
 | 
			
		||||
                        bool is_match_pattern = true);
 | 
			
		||||
    void AddType(extensions::WebRequestResourceType type);
 | 
			
		||||
 | 
			
		||||
    bool MatchesRequest(extensions::WebRequestInfo* info) const;
 | 
			
		||||
 | 
			
		||||
   private:
 | 
			
		||||
    bool MatchesURL(const GURL& url) const;
 | 
			
		||||
    bool MatchesURL(const GURL& url,
 | 
			
		||||
                    const std::set<URLPattern>& patterns) const;
 | 
			
		||||
    bool MatchesType(extensions::WebRequestResourceType type) const;
 | 
			
		||||
 | 
			
		||||
    std::set<URLPattern> url_patterns_;
 | 
			
		||||
    std::set<URLPattern> include_url_patterns_;
 | 
			
		||||
    std::set<URLPattern> exclude_url_patterns_;
 | 
			
		||||
    std::set<extensions::WebRequestResourceType> types_;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue