chromium/chrome/browser/extensions/api/declarative_content/content_predicate_evaluator.h

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_PREDICATE_EVALUATOR_H_
#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_PREDICATE_EVALUATOR_H_

#include <map>
#include <vector>

#include "chrome/browser/extensions/api/declarative_content/content_predicate.h"

namespace content {
class BrowserContext;
class NavigationHandle;
class WebContents;
}  // namespace content

namespace extensions {

// Creates and manages instances of an associated ContentPredicate subclass and
// tracks the url and browser context state required to evaluate the predicates.
//
// A ContentPredicateEvaluator corresponds to a single attribute name across all
// chrome.declarativeContent.PageStateMatchers provided in all rules in the
// Declarative Content API. For example, given the rules:
//
// var rule1 = {
//   conditions: [
//     new chrome.declarativeContent.PageStateMatcher({
//       pageUrl: { hostEquals: 'www.google.com', schemes: ['https'] },
//       css: ['input[type=\'password\']']
//     })
//   ],
//   actions: [ new chrome.declarativeContent.ShowPageAction() ]
// };
//
// var rule2 = {
//   conditions: [
//     new chrome.declarativeContent.PageStateMatcher({
//       pageUrl: { hostEquals: 'www.example.com' },
//       css: ['a', 'image']
//     })
//   ],
//   actions: [ new chrome.declarativeContent.ShowPageAction() ]
// };
//
// The subclass of ContentPredicateEvaluator whose
// GetPredicateApiAttributeName() function returns "pageUrl" is responsible for
// creating and managing the predicates
// { hostEquals: 'www.google.com', schemes: ['https'] } and
// { hostEquals: 'www.example.com' }.
//
// The subclass of ContentPredicateEvaluator whose
// GetPredicateApiAttributeName() function returns "css" is responsible for
// creating and managing the predicates ['input[type=\'password\']'] and
// ['a', 'image'].
class ContentPredicateEvaluator : public ContentPredicateFactory {};

// Allows an evaluator to notify that predicate evaluation state has been
// updated, and determine whether it should manage predicates for a context.
class ContentPredicateEvaluator::Delegate {};

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_PREDICATE_EVALUATOR_H_