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

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
(...skipping 10 matching lines...) Expand all
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 ChromeV8Context(v8::Handle<v8::Context> context, 29 ChromeV8Context(v8::Handle<v8::Context> context,
30 WebKit::WebFrame* frame, 30 WebKit::WebFrame* frame,
31 const std::string& extension_id); 31 const std::string& extension_id,
32 bool is_content_script);
32 ~ChromeV8Context(); 33 ~ChromeV8Context();
33 34
34 v8::Handle<v8::Context> v8_context() const { 35 v8::Handle<v8::Context> v8_context() const {
35 return v8_context_; 36 return v8_context_;
36 } 37 }
37 38
38 const std::string& extension_id() const { 39 const std::string& extension_id() const {
39 return extension_id_; 40 return extension_id_;
40 } 41 }
41 42
42 WebKit::WebFrame* web_frame() const { 43 WebKit::WebFrame* web_frame() const {
43 return web_frame_; 44 return web_frame_;
44 } 45 }
45 void clear_web_frame() { 46 void clear_web_frame() {
46 web_frame_ = NULL; 47 web_frame_ = NULL;
47 } 48 }
48 49
50 bool is_content_script() const {
51 return is_content_script_;
52 }
53
49 // Returns a special Chrome-specific hidden object that is associated with a 54 // 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 55 // 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 56 // used by our v8::Extension implementations as a way to share code and as a
52 // bridge between C++ and JavaScript. 57 // bridge between C++ and JavaScript.
53 static v8::Handle<v8::Value> GetOrCreateChromeHidden( 58 static v8::Handle<v8::Value> GetOrCreateChromeHidden(
54 v8::Handle<v8::Context> context); 59 v8::Handle<v8::Context> context);
55 60
56 // Return the chromeHidden object associated with this context, or an empty 61 // Return the chromeHidden object associated with this context, or an empty
57 // handle if no chrome hidden has been created (by GetOrCreateChromeHidden) 62 // handle if no chrome hidden has been created (by GetOrCreateChromeHidden)
58 // yet for this context. 63 // yet for this context.
(...skipping 30 matching lines...) Expand all
89 // distinguish the two cases. 94 // distinguish the two cases.
90 v8::Persistent<v8::Context> v8_context_; 95 v8::Persistent<v8::Context> v8_context_;
91 96
92 // The WebFrame associated with this context. This can be NULL because this 97 // The WebFrame associated with this context. This can be NULL because this
93 // object can outlive is destroyed asynchronously. 98 // object can outlive is destroyed asynchronously.
94 WebKit::WebFrame* web_frame_; 99 WebKit::WebFrame* web_frame_;
95 100
96 // The extension ID this context is associated with. 101 // The extension ID this context is associated with.
97 std::string extension_id_; 102 std::string extension_id_;
98 103
104 // Whether the context is for a content script.
105 bool is_content_script_;
106
99 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); 107 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context);
100 }; 108 };
101 109
102 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ 110 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698