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

Side by Side Diff: extensions/renderer/script_context.h

Issue 359413004: Add support for using AMD modules from extensions modules. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: extensions_renderer should depend on gin Created 6 years, 5 months 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 | « extensions/renderer/module_system.cc ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "v8/include/v8.h" 18 #include "v8/include/v8.h"
18 19
19 namespace blink { 20 namespace blink {
20 class WebFrame; 21 class WebFrame;
21 } 22 }
22 23
23 namespace content { 24 namespace content {
24 class RenderView; 25 class RenderView;
25 } 26 }
26 27
27 namespace extensions { 28 namespace extensions {
28 class Extension; 29 class Extension;
29 30
30 // Extensions wrapper for a v8 context. 31 // Extensions wrapper for a v8 context.
31 class ScriptContext : public RequestSender::Source { 32 class ScriptContext : public RequestSender::Source, public gin::Runner {
32 public: 33 public:
33 ScriptContext(const v8::Handle<v8::Context>& context, 34 ScriptContext(const v8::Handle<v8::Context>& context,
34 blink::WebFrame* frame, 35 blink::WebFrame* frame,
35 const Extension* extension, 36 const Extension* extension,
36 Feature::Context context_type); 37 Feature::Context context_type);
37 virtual ~ScriptContext(); 38 virtual ~ScriptContext();
38 39
39 // Clears the WebFrame for this contexts and invalidates the associated 40 // Clears the WebFrame for this contexts and invalidates the associated
40 // ModuleSystem. 41 // ModuleSystem.
41 void Invalidate(); 42 void Invalidate();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 bool match_about_blank); 114 bool match_about_blank);
114 115
115 // RequestSender::Source implementation. 116 // RequestSender::Source implementation.
116 virtual ScriptContext* GetContext() OVERRIDE; 117 virtual ScriptContext* GetContext() OVERRIDE;
117 virtual void OnResponseReceived(const std::string& name, 118 virtual void OnResponseReceived(const std::string& name,
118 int request_id, 119 int request_id,
119 bool success, 120 bool success,
120 const base::ListValue& response, 121 const base::ListValue& response,
121 const std::string& error) OVERRIDE; 122 const std::string& error) OVERRIDE;
122 123
124 // gin::Runner overrides.
125 virtual void Run(const std::string& source,
126 const std::string& resource_name) OVERRIDE;
127 virtual v8::Handle<v8::Value> Call(v8::Handle<v8::Function> function,
128 v8::Handle<v8::Value> receiver,
129 int argc,
130 v8::Handle<v8::Value> argv[]) OVERRIDE;
131 virtual gin::ContextHolder* GetContextHolder() OVERRIDE;
132
123 protected: 133 protected:
124 // The v8 context the bindings are accessible to. 134 // The v8 context the bindings are accessible to.
125 ScopedPersistent<v8::Context> v8_context_; 135 ScopedPersistent<v8::Context> v8_context_;
126 136
127 private: 137 private:
128 // The WebFrame associated with this context. This can be NULL because this 138 // The WebFrame associated with this context. This can be NULL because this
129 // object can outlive is destroyed asynchronously. 139 // object can outlive is destroyed asynchronously.
130 blink::WebFrame* web_frame_; 140 blink::WebFrame* web_frame_;
131 141
132 // The extension associated with this context, or NULL if there is none. This 142 // The extension associated with this context, or NULL if there is none. This
(...skipping 10 matching lines...) Expand all
143 SafeBuiltins safe_builtins_; 153 SafeBuiltins safe_builtins_;
144 154
145 v8::Isolate* isolate_; 155 v8::Isolate* isolate_;
146 156
147 DISALLOW_COPY_AND_ASSIGN(ScriptContext); 157 DISALLOW_COPY_AND_ASSIGN(ScriptContext);
148 }; 158 };
149 159
150 } // namespace extensions 160 } // namespace extensions
151 161
152 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 162 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
OLDNEW
« no previous file with comments | « extensions/renderer/module_system.cc ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698