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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // Clears the WebFrame for this contexts and invalidates the associated | 39 // Clears the WebFrame for this contexts and invalidates the associated |
40 // ModuleSystem. | 40 // ModuleSystem. |
41 void Invalidate(); | 41 void Invalidate(); |
42 | 42 |
43 // Returns true if this context is still valid, false if it isn't. | 43 // Returns true if this context is still valid, false if it isn't. |
44 // A context becomes invalid via Invalidate(). | 44 // A context becomes invalid via Invalidate(). |
45 bool is_valid() const { return !v8_context_.IsEmpty(); } | 45 bool is_valid() const { return !v8_context_.IsEmpty(); } |
46 | 46 |
47 v8::Handle<v8::Context> v8_context() const { | 47 v8::Handle<v8::Context> v8_context() const { |
48 return v8_context_.NewHandle(v8::Isolate::GetCurrent()); | 48 return v8_context_.NewHandle(isolate()); |
49 } | 49 } |
50 | 50 |
51 const Extension* extension() const { return extension_.get(); } | 51 const Extension* extension() const { return extension_.get(); } |
52 | 52 |
53 blink::WebFrame* web_frame() const { return web_frame_; } | 53 blink::WebFrame* web_frame() const { return web_frame_; } |
54 | 54 |
55 Feature::Context context_type() const { return context_type_; } | 55 Feature::Context context_type() const { return context_type_; } |
56 | 56 |
57 void set_module_system(scoped_ptr<ModuleSystem> module_system) { | 57 void set_module_system(scoped_ptr<ModuleSystem> module_system) { |
58 module_system_ = module_system.Pass(); | 58 module_system_ = module_system.Pass(); |
59 } | 59 } |
60 | 60 |
61 ModuleSystem* module_system() { return module_system_.get(); } | 61 ModuleSystem* module_system() { return module_system_.get(); } |
62 | 62 |
63 SafeBuiltins* safe_builtins() { return &safe_builtins_; } | 63 SafeBuiltins* safe_builtins() { return &safe_builtins_; } |
64 | 64 |
65 const SafeBuiltins* safe_builtins() const { return &safe_builtins_; } | 65 const SafeBuiltins* safe_builtins() const { return &safe_builtins_; } |
66 | 66 |
67 // Returns the ID of the extension associated with this context, or empty | 67 // Returns the ID of the extension associated with this context, or empty |
68 // string if there is no such extension. | 68 // string if there is no such extension. |
69 std::string GetExtensionID() const; | 69 const std::string& GetExtensionID() const; |
70 | 70 |
71 // Returns the RenderView associated with this context. Can return NULL if the | 71 // Returns the RenderView associated with this context. Can return NULL if the |
72 // context is in the process of being destroyed. | 72 // context is in the process of being destroyed. |
73 content::RenderView* GetRenderView() const; | 73 content::RenderView* GetRenderView() const; |
74 | 74 |
75 // Runs |function| with appropriate scopes. Doesn't catch exceptions, callers | 75 // Runs |function| with appropriate scopes. Doesn't catch exceptions, callers |
76 // must do that if they want. | 76 // must do that if they want. |
77 // | 77 // |
78 // USE THIS METHOD RATHER THAN v8::Function::Call WHEREVER POSSIBLE. | 78 // USE THIS METHOD RATHER THAN v8::Function::Call WHEREVER POSSIBLE. |
79 v8::Local<v8::Value> CallFunction(v8::Handle<v8::Function> function, | 79 v8::Local<v8::Value> CallFunction(v8::Handle<v8::Function> function, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 SafeBuiltins safe_builtins_; | 143 SafeBuiltins safe_builtins_; |
144 | 144 |
145 v8::Isolate* isolate_; | 145 v8::Isolate* isolate_; |
146 | 146 |
147 DISALLOW_COPY_AND_ASSIGN(ScriptContext); | 147 DISALLOW_COPY_AND_ASSIGN(ScriptContext); |
148 }; | 148 }; |
149 | 149 |
150 } // namespace extensions | 150 } // namespace extensions |
151 | 151 |
152 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ | 152 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
OLD | NEW |