OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/extensions/api/declarative/declarative_rule.h" |
| 13 |
| 14 class Profile; |
| 15 |
| 16 namespace base { |
| 17 class Time; |
| 18 class Value; |
| 19 } |
| 20 |
| 21 namespace content { |
| 22 class WebContents; |
| 23 } |
| 24 |
| 25 namespace extensions { |
| 26 |
| 27 // Base class for all ContentActions of the declarative content API. |
| 28 class ContentAction { |
| 29 public: |
| 30 // Type identifiers for concrete ContentActions. |
| 31 enum Type { |
| 32 ACTION_SHOW_PAGE_ACTION, |
| 33 }; |
| 34 |
| 35 struct ApplyInfo { |
| 36 Profile* profile; |
| 37 content::WebContents* tab; |
| 38 }; |
| 39 |
| 40 ContentAction(); |
| 41 virtual ~ContentAction(); |
| 42 |
| 43 virtual Type GetType() const = 0; |
| 44 |
| 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 |
| 47 // changes. |
| 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; |
| 54 |
| 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_ptr<ContentAction> Create(const base::Value& json_action, |
| 62 std::string* error, |
| 63 bool* bad_message); |
| 64 }; |
| 65 |
| 66 typedef DeclarativeActionSet<ContentAction> ContentActionSet; |
| 67 |
| 68 } // namespace extensions |
| 69 |
| 70 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ |
OLD | NEW |