| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ | 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
| 6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ | 6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "extensions/common/features/feature.h" | 12 #include "extensions/common/features/feature.h" |
| 13 #include "extensions/renderer/module_system.h" | 13 #include "extensions/renderer/module_system.h" |
| 14 #include "extensions/renderer/request_sender.h" | 14 #include "extensions/renderer/request_sender.h" |
| 15 #include "extensions/renderer/safe_builtins.h" | 15 #include "extensions/renderer/safe_builtins.h" |
| 16 #include "extensions/renderer/scoped_persistent.h" | 16 #include "extensions/renderer/scoped_persistent.h" |
| 17 #include "gin/runner.h" | 17 #include "gin/runner.h" |
| 18 #include "v8/include/v8.h" | 18 #include "v8/include/v8.h" |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 class WebFrame; | 21 class WebFrame; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 class RenderFrame; |
| 25 class RenderView; | 26 class RenderView; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace extensions { | 29 namespace extensions { |
| 29 class Extension; | 30 class Extension; |
| 30 | 31 |
| 31 // Extensions wrapper for a v8 context. | 32 // Extensions wrapper for a v8 context. |
| 32 class ScriptContext : public RequestSender::Source, public gin::Runner { | 33 class ScriptContext : public RequestSender::Source, public gin::Runner { |
| 33 public: | 34 public: |
| 34 ScriptContext(const v8::Handle<v8::Context>& context, | 35 ScriptContext(const v8::Handle<v8::Context>& context, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 const SafeBuiltins* safe_builtins() const { return &safe_builtins_; } | 67 const SafeBuiltins* safe_builtins() const { return &safe_builtins_; } |
| 67 | 68 |
| 68 // Returns the ID of the extension associated with this context, or empty | 69 // Returns the ID of the extension associated with this context, or empty |
| 69 // string if there is no such extension. | 70 // string if there is no such extension. |
| 70 const std::string& GetExtensionID() const; | 71 const std::string& GetExtensionID() const; |
| 71 | 72 |
| 72 // Returns the RenderView associated with this context. Can return NULL if the | 73 // Returns the RenderView associated with this context. Can return NULL if the |
| 73 // context is in the process of being destroyed. | 74 // context is in the process of being destroyed. |
| 74 content::RenderView* GetRenderView() const; | 75 content::RenderView* GetRenderView() const; |
| 75 | 76 |
| 77 // Returns the RenderFrame associated with this context. Can return NULL if |
| 78 // the context is in the process of being destroyed. |
| 79 content::RenderFrame* GetRenderFrame() const; |
| 80 |
| 76 // Runs |function| with appropriate scopes. Doesn't catch exceptions, callers | 81 // Runs |function| with appropriate scopes. Doesn't catch exceptions, callers |
| 77 // must do that if they want. | 82 // must do that if they want. |
| 78 // | 83 // |
| 79 // USE THIS METHOD RATHER THAN v8::Function::Call WHEREVER POSSIBLE. | 84 // USE THIS METHOD RATHER THAN v8::Function::Call WHEREVER POSSIBLE. |
| 80 v8::Local<v8::Value> CallFunction(v8::Handle<v8::Function> function, | 85 v8::Local<v8::Value> CallFunction(v8::Handle<v8::Function> function, |
| 81 int argc, | 86 int argc, |
| 82 v8::Handle<v8::Value> argv[]) const; | 87 v8::Handle<v8::Value> argv[]) const; |
| 83 | 88 |
| 84 void DispatchEvent(const char* event_name, v8::Handle<v8::Array> args) const; | 89 void DispatchEvent(const char* event_name, v8::Handle<v8::Array> args) const; |
| 85 | 90 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 SafeBuiltins safe_builtins_; | 159 SafeBuiltins safe_builtins_; |
| 155 | 160 |
| 156 v8::Isolate* isolate_; | 161 v8::Isolate* isolate_; |
| 157 | 162 |
| 158 DISALLOW_COPY_AND_ASSIGN(ScriptContext); | 163 DISALLOW_COPY_AND_ASSIGN(ScriptContext); |
| 159 }; | 164 }; |
| 160 | 165 |
| 161 } // namespace extensions | 166 } // namespace extensions |
| 162 | 167 |
| 163 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ | 168 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
| OLD | NEW |