| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 #include "chrome/browser/extensions/extension_menu_manager.h" | 10 #include "chrome/browser/extensions/extension_menu_manager.h" |
| 11 #include "chrome/common/extensions/url_pattern_set.h" | 11 #include "chrome/common/extensions/url_pattern_set.h" |
| 12 | 12 |
| 13 class DictionaryValue; | 13 class DictionaryValue; |
| 14 class ExtensionMenuItem; | 14 class ExtensionMenuItem; |
| 15 | 15 |
| 16 class ExtensionContextMenuFunction : public SyncExtensionFunction { | 16 class ExtensionContextMenuFunction : public SyncExtensionFunction { |
| 17 public: | 17 public: |
| 18 ~ExtensionContextMenuFunction() {} | 18 virtual ~ExtensionContextMenuFunction() {} |
| 19 | 19 |
| 20 protected: | 20 protected: |
| 21 // Helper function to read and parse a list of menu item contexts. | 21 // Helper function to read and parse a list of menu item contexts. |
| 22 bool ParseContexts(const DictionaryValue& properties, | 22 bool ParseContexts(const DictionaryValue& properties, |
| 23 const char* key, | 23 const char* key, |
| 24 ExtensionMenuItem::ContextList* result); | 24 ExtensionMenuItem::ContextList* result); |
| 25 | 25 |
| 26 // Looks in properties for the "type" key, and reads the value in |result|. On | 26 // Looks in properties for the "type" key, and reads the value in |result|. On |
| 27 // error, returns false and puts an error message into error_. If the key is | 27 // error, returns false and puts an error message into error_. If the key is |
| 28 // not present, |result| is set to |default_value| and the return value is | 28 // not present, |result| is set to |default_value| and the return value is |
| (...skipping 24 matching lines...) Expand all Loading... |
| 53 // on error, with an explanation written into error_. Note that if the | 53 // on error, with an explanation written into error_. Note that if the |
| 54 // parentId key is not in properties, this will return true and leave |result| | 54 // parentId key is not in properties, this will return true and leave |result| |
| 55 // unset. Also, it is considered an error if the item found has a type other | 55 // unset. Also, it is considered an error if the item found has a type other |
| 56 // than NORMAL. | 56 // than NORMAL. |
| 57 bool GetParent(const DictionaryValue& properties, | 57 bool GetParent(const DictionaryValue& properties, |
| 58 const ExtensionMenuManager& manager, | 58 const ExtensionMenuManager& manager, |
| 59 ExtensionMenuItem** result); | 59 ExtensionMenuItem** result); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 class CreateContextMenuFunction : public ExtensionContextMenuFunction { | 62 class CreateContextMenuFunction : public ExtensionContextMenuFunction { |
| 63 ~CreateContextMenuFunction() {} | 63 virtual ~CreateContextMenuFunction() {} |
| 64 virtual bool RunImpl(); | 64 virtual bool RunImpl(); |
| 65 DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.create") | 65 DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.create") |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class UpdateContextMenuFunction : public ExtensionContextMenuFunction { | 68 class UpdateContextMenuFunction : public ExtensionContextMenuFunction { |
| 69 ~UpdateContextMenuFunction() {} | 69 virtual ~UpdateContextMenuFunction() {} |
| 70 virtual bool RunImpl(); | 70 virtual bool RunImpl(); |
| 71 DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.update") | 71 DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.update") |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 class RemoveContextMenuFunction : public ExtensionContextMenuFunction { | 74 class RemoveContextMenuFunction : public ExtensionContextMenuFunction { |
| 75 ~RemoveContextMenuFunction() {} | 75 virtual ~RemoveContextMenuFunction() {} |
| 76 virtual bool RunImpl(); | 76 virtual bool RunImpl(); |
| 77 DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.remove") | 77 DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.remove") |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 class RemoveAllContextMenusFunction : public ExtensionContextMenuFunction { | 80 class RemoveAllContextMenusFunction : public ExtensionContextMenuFunction { |
| 81 ~RemoveAllContextMenusFunction() {} | 81 virtual ~RemoveAllContextMenusFunction() {} |
| 82 virtual bool RunImpl(); | 82 virtual bool RunImpl(); |
| 83 DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.removeAll") | 83 DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.removeAll") |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__ | 86 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__ |
| OLD | NEW |