Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Side by Side Diff: chrome/common/extensions/api/extension_api.h

Issue 8540012: Enable extension APIs for content scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/common/extensions/api/extension_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
6 #define CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/singleton.h"
14
15 namespace base {
16 class DictionaryValue;
17 class ListValue;
18 }
19
20 namespace extensions {
21
22 // C++ Wrapper for the extension_api.json file.
23 class ExtensionAPI {
24 public:
25 // Returns the single instance of this class.
26 static ExtensionAPI* GetInstance();
27
28 const base::ListValue* value() const {
29 return value_.get();
30 }
31
32 // Returns ture if |name| is a privileged API. Privileged APIs can only be
33 // called from extension code which is running in its own designated extension
34 // process. They cannot be called from extension code running in content
35 // scripts, or other low-privileged processes.
36 bool IsPrivileged(const std::string& name) const;
37
38 private:
39 friend struct DefaultSingletonTraits<ExtensionAPI>;
40
41 ExtensionAPI();
42 ~ExtensionAPI();
43
44 // Find an item in |list| with the specified property name and value, or NULL
45 // if no such item exists.
46 base::DictionaryValue* FindListItem(base::ListValue* list,
47 const std::string& property_name,
48 const std::string& property_value) const;
49
50 // Returns true if the function or event under |namespace_node| with
51 // the specified |child_name| is privileged, or false otherwise. If the name
52 // is not found, defaults to privileged.
53 bool IsChildNamePrivileged(base::DictionaryValue* namespace_node,
54 const std::string& child_kind,
55 const std::string& child_name) const;
56
57 static ExtensionAPI* instance_;
58
59 scoped_ptr<base::ListValue> value_;
60
61 DISALLOW_COPY_AND_ASSIGN(ExtensionAPI);
62 };
63
64 } // extensions
65
66 #endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/common/extensions/api/extension_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698