1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_
11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/extensions/api/declarative/declarative_rule.h"
25 namespace extensions {
28 // Base class for all ContentActions of the declarative content API.
29 class ContentAction : public base::RefCounted<ContentAction> {
31 // Type identifiers for concrete ContentActions.
33 ACTION_SHOW_PAGE_ACTION,
38 content::WebContents* tab;
43 virtual Type GetType() const = 0;
45 // Applies or reverts this ContentAction on a particular tab for a particular
46 // extension. Revert exists to keep the actions up to date as the page
48 virtual void Apply(const std::string& extension_id,
49 const base::Time& extension_install_time,
50 ApplyInfo* apply_info) const = 0;
51 virtual void Revert(const std::string& extension_id,
52 const base::Time& extension_install_time,
53 ApplyInfo* apply_info) const = 0;
55 // Factory method that instantiates a concrete ContentAction
56 // implementation according to |json_action|, the representation of the
57 // ContentAction as received from the extension API.
58 // Sets |error| and returns NULL in case of a semantic error that cannot
59 // be caught by schema validation. Sets |bad_message| and returns NULL
60 // in case the input is syntactically unexpected.
61 static scoped_refptr<ContentAction> Create(const Extension* extension,
62 const base::Value& json_action,
67 friend class base::RefCounted<ContentAction>;
68 virtual ~ContentAction();
71 typedef DeclarativeActionSet<ContentAction> ContentActionSet;
73 } // namespace extensions
75 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_