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

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

Issue 9403006: Extensions: run "custom bindings" v8-extensions in content scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 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 "v8/include/v8.h" 12 #include "v8/include/v8.h"
13 13
14 namespace WebKit { 14 namespace WebKit {
15 class WebFrame; 15 class WebFrame;
16 } 16 }
17 17
18 namespace content { 18 namespace content {
19 class RenderView; 19 class RenderView;
20 } 20 }
21 21
22 // Chrome's wrapper for a v8 context. 22 // Chrome's wrapper for a v8 context.
23 // 23 //
24 // TODO(aa): Consider converting this back to a set of bindings_utils. It would 24 // TODO(aa): Consider converting this back to a set of bindings_utils. It would
25 // require adding WebFrame::GetIsolatedWorldIdByV8Context() to WebCore, but then 25 // require adding WebFrame::GetIsolatedWorldIdByV8Context() to WebCore, but then
26 // we won't need this object and it's a bit less state to keep track of. 26 // we won't need this object and it's a bit less state to keep track of.
27 class ChromeV8Context { 27 class ChromeV8Context {
28 public: 28 public:
29 enum ContextType {
30 FRAME,
31 CONTENT_SCRIPT
32 };
33
29 ChromeV8Context(v8::Handle<v8::Context> context, 34 ChromeV8Context(v8::Handle<v8::Context> context,
30 WebKit::WebFrame* frame, 35 WebKit::WebFrame* frame,
31 const std::string& extension_id); 36 const std::string& extension_id,
37 ContextType context_type);
32 ~ChromeV8Context(); 38 ~ChromeV8Context();
33 39
34 v8::Handle<v8::Context> v8_context() const { 40 v8::Handle<v8::Context> v8_context() const {
35 return v8_context_; 41 return v8_context_;
36 } 42 }
37 43
38 const std::string& extension_id() const { 44 const std::string& extension_id() const {
39 return extension_id_; 45 return extension_id_;
40 } 46 }
41 47
42 WebKit::WebFrame* web_frame() const { 48 WebKit::WebFrame* web_frame() const {
43 return web_frame_; 49 return web_frame_;
44 } 50 }
45 void clear_web_frame() { 51 void clear_web_frame() {
46 web_frame_ = NULL; 52 web_frame_ = NULL;
47 } 53 }
48 54
55 bool context_type() const {
Aaron Boodman 2012/02/16 02:01:53 "Ha ha! Got you!" signed, C++
56 return context_type_;
57 }
58
49 // Returns a special Chrome-specific hidden object that is associated with a 59 // Returns a special Chrome-specific hidden object that is associated with a
50 // context, but not reachable from the JavaScript in that context. This is 60 // context, but not reachable from the JavaScript in that context. This is
51 // used by our v8::Extension implementations as a way to share code and as a 61 // used by our v8::Extension implementations as a way to share code and as a
52 // bridge between C++ and JavaScript. 62 // bridge between C++ and JavaScript.
53 static v8::Handle<v8::Value> GetOrCreateChromeHidden( 63 static v8::Handle<v8::Value> GetOrCreateChromeHidden(
54 v8::Handle<v8::Context> context); 64 v8::Handle<v8::Context> context);
55 65
56 // Return the chromeHidden object associated with this context, or an empty 66 // Return the chromeHidden object associated with this context, or an empty
57 // handle if no chrome hidden has been created (by GetOrCreateChromeHidden) 67 // handle if no chrome hidden has been created (by GetOrCreateChromeHidden)
58 // yet for this context. 68 // yet for this context.
(...skipping 30 matching lines...) Expand all
89 // distinguish the two cases. 99 // distinguish the two cases.
90 v8::Persistent<v8::Context> v8_context_; 100 v8::Persistent<v8::Context> v8_context_;
91 101
92 // The WebFrame associated with this context. This can be NULL because this 102 // The WebFrame associated with this context. This can be NULL because this
93 // object can outlive is destroyed asynchronously. 103 // object can outlive is destroyed asynchronously.
94 WebKit::WebFrame* web_frame_; 104 WebKit::WebFrame* web_frame_;
95 105
96 // The extension ID this context is associated with. 106 // The extension ID this context is associated with.
97 std::string extension_id_; 107 std::string extension_id_;
98 108
109 // The type of context.
110 ContextType context_type_;
111
99 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); 112 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context);
100 }; 113 };
101 114
102 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ 115 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/storage.json ('k') | chrome/renderer/extensions/chrome_v8_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698