| OLD | NEW |
| 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 { | 29 enum ContextType { |
| 30 // Blessed contexts such as normal chrome-extension:// URLs (including those |
| 31 // which are iframes holding web accessible resources). |
| 32 BLESSED, |
| 33 |
| 34 // All content scripts. |
| 30 CONTENT_SCRIPT, | 35 CONTENT_SCRIPT, |
| 31 | 36 |
| 32 // TODO(kalman): for now, have this as OTHER, since we only currently need | 37 // Unprivileged contexts, such as normal webpages. |
| 33 // know whether something is a content script or not. However, when | 38 UNPRIVILEGED |
| 34 // necessary this should enumerate the other types, such as FRAME. | |
| 35 OTHER | |
| 36 }; | 39 }; |
| 37 | 40 |
| 38 ChromeV8Context(v8::Handle<v8::Context> context, | 41 ChromeV8Context(v8::Handle<v8::Context> context, |
| 39 WebKit::WebFrame* frame, | 42 WebKit::WebFrame* frame, |
| 40 const std::string& extension_id, | 43 const std::string& extension_id, |
| 41 ContextType context_type); | 44 ContextType context_type); |
| 42 ~ChromeV8Context(); | 45 ~ChromeV8Context(); |
| 43 | 46 |
| 44 v8::Handle<v8::Context> v8_context() const { | 47 v8::Handle<v8::Context> v8_context() const { |
| 45 return v8_context_; | 48 return v8_context_; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // The extension ID this context is associated with. | 113 // The extension ID this context is associated with. |
| 111 std::string extension_id_; | 114 std::string extension_id_; |
| 112 | 115 |
| 113 // The type of context. | 116 // The type of context. |
| 114 ContextType context_type_; | 117 ContextType context_type_; |
| 115 | 118 |
| 116 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); | 119 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); |
| 117 }; | 120 }; |
| 118 | 121 |
| 119 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ | 122 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ |
| OLD | NEW |