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_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 // Create a handler for |context|. If a subclass of ChromeV8Extension wishes | 86 // Create a handler for |context|. If a subclass of ChromeV8Extension wishes |
87 // to support handlers, it should override this. | 87 // to support handlers, it should override this. |
88 virtual ChromeV8ExtensionHandler* CreateHandler(ChromeV8Context* context); | 88 virtual ChromeV8ExtensionHandler* CreateHandler(ChromeV8Context* context); |
89 | 89 |
90 // Returns the chromeHidden object for the current context. | 90 // Returns the chromeHidden object for the current context. |
91 static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args); | 91 static v8::Handle<v8::Value> GetChromeHidden(const v8::Arguments& args); |
92 | 92 |
93 ExtensionDispatcher* extension_dispatcher_; | 93 ExtensionDispatcher* extension_dispatcher_; |
94 | 94 |
95 private: | 95 private: |
96 static const char* GetStringResource(int resource_id); | 96 static base::StringPiece GetStringResourceAsStringPiece(int resource_id); |
Aaron Boodman
2011/10/14 21:41:09
Nit: No need to encode the returned type in the na
| |
97 static int GetStringResourceLength(int resource_id); | |
Aaron Boodman
2011/10/14 21:41:09
Nit: I don't think it's worth having this extra me
| |
97 | 98 |
98 // Helper to print from bindings javascript. | 99 // Helper to print from bindings javascript. |
99 static v8::Handle<v8::Value> Print(const v8::Arguments& args); | 100 static v8::Handle<v8::Value> Print(const v8::Arguments& args); |
100 | 101 |
101 // Handle a native function call from JavaScript. | 102 // Handle a native function call from JavaScript. |
102 static v8::Handle<v8::Value> HandleNativeFunction(const v8::Arguments& args); | 103 static v8::Handle<v8::Value> HandleNativeFunction(const v8::Arguments& args); |
103 | 104 |
104 // Get the handler instance for |context|, or NULL if no such context exists. | 105 // Get the handler instance for |context|, or NULL if no such context exists. |
105 ChromeV8ExtensionHandler* GetHandler(ChromeV8Context* context) const; | 106 ChromeV8ExtensionHandler* GetHandler(ChromeV8Context* context) const; |
106 | 107 |
107 // Map of all current handlers. | 108 // Map of all current handlers. |
108 typedef std::map<ChromeV8Context*, | 109 typedef std::map<ChromeV8Context*, |
109 linked_ptr<ChromeV8ExtensionHandler> > HandlerMap; | 110 linked_ptr<ChromeV8ExtensionHandler> > HandlerMap; |
110 HandlerMap handlers_; | 111 HandlerMap handlers_; |
111 | 112 |
112 DISALLOW_COPY_AND_ASSIGN(ChromeV8Extension); | 113 DISALLOW_COPY_AND_ASSIGN(ChromeV8Extension); |
113 }; | 114 }; |
114 | 115 |
115 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ | 116 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ |
OLD | NEW |