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/linked_ptr.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/scoped_vector.h" |
| 14 #include "chrome/browser/extensions/api/declarative/declarative_rule.h" |
| 15 |
| 16 class Profile; |
| 17 |
| 18 namespace base { |
| 19 class Time; |
| 20 class Value; |
| 21 } |
| 22 |
| 23 namespace content { |
| 24 class WebContents; |
| 25 } |
| 26 |
| 27 namespace extensions { |
| 28 |
| 29 // Base class for all ContentActions of the declarative Web Request API. |
| 30 class ContentAction { |
| 31 public: |
| 32 // Type identifiers for concrete ContentActions. |
| 33 enum Type { |
| 34 ACTION_SHOW_PAGE_ACTION, |
| 35 }; |
| 36 |
| 37 struct ApplyInfo { |
| 38 Profile* profile; |
| 39 content::WebContents* tab; |
| 40 }; |
| 41 |
| 42 ContentAction(); |
| 43 virtual ~ContentAction(); |
| 44 |
| 45 virtual Type GetType() const = 0; |
| 46 |
| 47 // Applies or reverts this ContentAction on a particular tab for a particular |
| 48 // extension. Revert exists to keep the actions up to date as the page |
| 49 // changes. |
| 50 virtual void Apply(const std::string& extension_id, |
| 51 const base::Time& extension_install_time, |
| 52 const ApplyInfo& apply_info) = 0; |
| 53 virtual void Revert(const std::string& extension_id, |
| 54 const base::Time& extension_install_time, |
| 55 const ApplyInfo& apply_info) = 0; |
| 56 |
| 57 // Factory method that instantiates a concrete ContentAction |
| 58 // implementation according to |json_action|, the representation of the |
| 59 // ContentAction as received from the extension API. |
| 60 // Sets |error| and returns NULL in case of a semantic error that cannot |
| 61 // be caught by schema validation. Sets |bad_message| and returns NULL |
| 62 // in case the input is syntactically unexpected. |
| 63 static scoped_ptr<ContentAction> Create(const base::Value& json_action, |
| 64 std::string* error, |
| 65 bool* bad_message); |
| 66 }; |
| 67 |
| 68 typedef DeclarativeActionSet<ContentAction> ContentActionSet; |
| 69 |
| 70 } // namespace extensions |
| 71 |
| 72 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_ACTION_H_ |
OLD | NEW |