1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__
#include "chrome/browser/extensions/extension_function.h"
#include "chrome/browser/extensions/extension_menu_manager.h"
#include "chrome/common/extensions/extension_extent.h"
class ExtensionMenuItem;
class ExtensionContextMenuFunction : public SyncExtensionFunction {
public:
~ExtensionContextMenuFunction() {}
protected:
// Helper function to read and parse a list of menu item contexts.
bool ParseContexts(const DictionaryValue& properties,
const wchar_t* key,
ExtensionMenuItem::ContextList* result);
// Looks in properties for the "type" key, and reads the value in |result|. On
// error, returns false and puts an error message into error_. If the key is
// not present, |result| is set to |default_value| and the return value is
// true.
bool ParseType(const DictionaryValue& properties,
const ExtensionMenuItem::Type& default_value,
ExtensionMenuItem::Type* result);
// Helper to read and parse the "checked" property.
bool ParseChecked(ExtensionMenuItem::Type type,
const DictionaryValue& properties,
bool default_value,
bool* checked);
// Helper to read in a set of url patterns from a property with the given key
// name.
bool ParseURLPatterns(const DictionaryValue& properties,
const wchar_t* key,
ExtensionExtent* result);
// Reads in any document and targetUrl patterns from |properties| and sets
// them on |item|.
bool SetURLPatterns(const DictionaryValue& properties,
ExtensionMenuItem* item);
// If the parentId key was specified in properties, this will try looking up
// an ExtensionMenuItem with that id and set it into |result|. Returns false
// on error, with an explanation written into error_. Note that if the
// parentId key is not in properties, this will return true and leave |result|
// unset. Also, it is considered an error if the item found has a type other
// than NORMAL.
bool GetParent(const DictionaryValue& properties,
const ExtensionMenuManager& manager,
ExtensionMenuItem** result);
};
class CreateContextMenuFunction : public ExtensionContextMenuFunction {
~CreateContextMenuFunction() {}
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.create")
};
class UpdateContextMenuFunction : public ExtensionContextMenuFunction {
~UpdateContextMenuFunction() {}
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.update")
};
class RemoveContextMenuFunction : public ExtensionContextMenuFunction {
~RemoveContextMenuFunction() {}
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.remove")
};
class RemoveAllContextMenusFunction : public ExtensionContextMenuFunction {
~RemoveAllContextMenusFunction() {}
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME("contextMenus.removeAll")
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTEXT_MENU_API_H__
|