| 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 GetStringResource(int resource_id); |
| 97 | 97 |
| 98 // Helper to print from bindings javascript. | 98 // Helper to print from bindings javascript. |
| 99 static v8::Handle<v8::Value> Print(const v8::Arguments& args); | 99 static v8::Handle<v8::Value> Print(const v8::Arguments& args); |
| 100 | 100 |
| 101 // Handle a native function call from JavaScript. | 101 // Handle a native function call from JavaScript. |
| 102 static v8::Handle<v8::Value> HandleNativeFunction(const v8::Arguments& args); | 102 static v8::Handle<v8::Value> HandleNativeFunction(const v8::Arguments& args); |
| 103 | 103 |
| 104 // Get the handler instance for |context|, or NULL if no such context exists. | 104 // Get the handler instance for |context|, or NULL if no such context exists. |
| 105 ChromeV8ExtensionHandler* GetHandler(ChromeV8Context* context) const; | 105 ChromeV8ExtensionHandler* GetHandler(ChromeV8Context* context) const; |
| 106 | 106 |
| 107 // Map of all current handlers. | 107 // Map of all current handlers. |
| 108 typedef std::map<ChromeV8Context*, | 108 typedef std::map<ChromeV8Context*, |
| 109 linked_ptr<ChromeV8ExtensionHandler> > HandlerMap; | 109 linked_ptr<ChromeV8ExtensionHandler> > HandlerMap; |
| 110 HandlerMap handlers_; | 110 HandlerMap handlers_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(ChromeV8Extension); | 112 DISALLOW_COPY_AND_ASSIGN(ChromeV8Extension); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ | 115 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_EXTENSION_H_ |
| OLD | NEW |