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

Side by Side Diff: chrome/renderer/extensions/chrome_v8_context.h

Issue 9653022: Revert 125811 - Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CONTEXT_H_ 5 #ifndef CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_
6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ 6 #define CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "chrome/common/extensions/feature.h"
13 #include "chrome/renderer/module_system.h" 12 #include "chrome/renderer/module_system.h"
14 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
15 14
16 namespace WebKit { 15 namespace WebKit {
17 class WebFrame; 16 class WebFrame;
18 } 17 }
19 18
20 namespace content { 19 namespace content {
21 class RenderView; 20 class RenderView;
22 } 21 }
23 22
24 // Chrome's wrapper for a v8 context. 23 // Chrome's wrapper for a v8 context.
25 // 24 //
26 // TODO(aa): Consider converting this back to a set of bindings_utils. It would 25 // TODO(aa): Consider converting this back to a set of bindings_utils. It would
27 // require adding WebFrame::GetIsolatedWorldIdByV8Context() to WebCore, but then 26 // require adding WebFrame::GetIsolatedWorldIdByV8Context() to WebCore, but then
28 // we won't need this object and it's a bit less state to keep track of. 27 // we won't need this object and it's a bit less state to keep track of.
29 class ChromeV8Context { 28 class ChromeV8Context {
30 public: 29 public:
30 enum ContextType {
31 CONTENT_SCRIPT,
32
33 // TODO(kalman): for now, have this as OTHER, since we only currently need
34 // know whether something is a content script or not. However, when
35 // necessary this should enumerate the other types, such as FRAME.
36 OTHER
37 };
38
31 ChromeV8Context(v8::Handle<v8::Context> context, 39 ChromeV8Context(v8::Handle<v8::Context> context,
32 WebKit::WebFrame* frame, 40 WebKit::WebFrame* frame,
33 const std::string& extension_id, 41 const std::string& extension_id,
34 extensions::Feature::Context context_type); 42 ContextType context_type);
35 ~ChromeV8Context(); 43 ~ChromeV8Context();
36 44
37 v8::Handle<v8::Context> v8_context() const { 45 v8::Handle<v8::Context> v8_context() const {
38 return v8_context_; 46 return v8_context_;
39 } 47 }
40 48
41 const std::string& extension_id() const { 49 const std::string& extension_id() const {
42 return extension_id_; 50 return extension_id_;
43 } 51 }
44 52
45 WebKit::WebFrame* web_frame() const { 53 WebKit::WebFrame* web_frame() const {
46 return web_frame_; 54 return web_frame_;
47 } 55 }
48 void clear_web_frame() { 56 void clear_web_frame() {
49 web_frame_ = NULL; 57 web_frame_ = NULL;
50 } 58 }
51 59
52 extensions::Feature::Context context_type() const { 60 ContextType context_type() const {
53 return context_type_; 61 return context_type_;
54 } 62 }
55 63
56 void set_module_system(scoped_ptr<ModuleSystem> module_system) { 64 void set_module_system(scoped_ptr<ModuleSystem> module_system) {
57 module_system_ = module_system.Pass(); 65 module_system_ = module_system.Pass();
58 } 66 }
59 67
60 // Returns a special Chrome-specific hidden object that is associated with a 68 // Returns a special Chrome-specific hidden object that is associated with a
61 // context, but not reachable from the JavaScript in that context. This is 69 // context, but not reachable from the JavaScript in that context. This is
62 // used by our v8::Extension implementations as a way to share code and as a 70 // used by our v8::Extension implementations as a way to share code and as a
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 v8::Persistent<v8::Context> v8_context_; 109 v8::Persistent<v8::Context> v8_context_;
102 110
103 // The WebFrame associated with this context. This can be NULL because this 111 // The WebFrame associated with this context. This can be NULL because this
104 // object can outlive is destroyed asynchronously. 112 // object can outlive is destroyed asynchronously.
105 WebKit::WebFrame* web_frame_; 113 WebKit::WebFrame* web_frame_;
106 114
107 // The extension ID this context is associated with. 115 // The extension ID this context is associated with.
108 std::string extension_id_; 116 std::string extension_id_;
109 117
110 // The type of context. 118 // The type of context.
111 extensions::Feature::Context context_type_; 119 ContextType context_type_;
112 120
113 // Owns and structures the JS that is injected to set up extension bindings. 121 // Owns and structures the JS that is injected to set up extension bindings.
114 scoped_ptr<ModuleSystem> module_system_; 122 scoped_ptr<ModuleSystem> module_system_;
115 123
116 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); 124 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context);
117 }; 125 };
118 126
119 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ 127 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/app_bindings.cc ('k') | chrome/renderer/extensions/chrome_v8_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698