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

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

Issue 12567028: Apps V2 in Pepper: Host side implementation of ExntensionsCommon - Part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 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 "chrome/common/extensions/features/feature.h" 12 #include "chrome/common/extensions/features/feature.h"
12 #include "chrome/renderer/extensions/module_system.h" 13 #include "chrome/renderer/extensions/module_system.h"
14 #include "chrome/renderer/extensions/request_sender.h"
13 #include "chrome/renderer/extensions/scoped_persistent.h" 15 #include "chrome/renderer/extensions/scoped_persistent.h"
14 #include "v8/include/v8.h" 16 #include "v8/include/v8.h"
15 17
16 namespace WebKit { 18 namespace WebKit {
17 class WebFrame; 19 class WebFrame;
18 } 20 }
19 21
20 namespace content { 22 namespace content {
21 class RenderView; 23 class RenderView;
22 } 24 }
23 25
24 namespace extensions { 26 namespace extensions {
25 class Extension; 27 class Extension;
26 28
27 // Chrome's wrapper for a v8 context. 29 // Chrome's wrapper for a v8 context.
28 // 30 //
29 // TODO(aa): Consider converting this back to a set of bindings_utils. It would 31 // TODO(aa): Consider converting this back to a set of bindings_utils. It would
30 // require adding WebFrame::GetIsolatedWorldIdByV8Context() to WebCore, but then 32 // require adding WebFrame::GetIsolatedWorldIdByV8Context() to WebCore, but then
31 // we won't need this object and it's a bit less state to keep track of. 33 // we won't need this object and it's a bit less state to keep track of.
32 class ChromeV8Context { 34 class ChromeV8Context : public RequestSender::Source {
33 public: 35 public:
34 ChromeV8Context(v8::Handle<v8::Context> context, 36 ChromeV8Context(v8::Handle<v8::Context> context,
35 WebKit::WebFrame* frame, 37 WebKit::WebFrame* frame,
36 const Extension* extension, 38 const Extension* extension,
37 Feature::Context context_type); 39 Feature::Context context_type);
38 ~ChromeV8Context(); 40 virtual ~ChromeV8Context();
39 41
40 // Clears the WebFrame for this contexts and invalidates the associated 42 // Clears the WebFrame for this contexts and invalidates the associated
41 // ModuleSystem. 43 // ModuleSystem.
42 void Invalidate(); 44 void Invalidate();
43 45
44 v8::Handle<v8::Context> v8_context() const { 46 v8::Handle<v8::Context> v8_context() const {
45 return v8_context_.get(); 47 return v8_context_.get();
46 } 48 }
47 49
48 const Extension* extension() const { 50 const Extension* extension() const {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 int argc, 99 int argc,
98 v8::Handle<v8::Value>* argv, 100 v8::Handle<v8::Value>* argv,
99 v8::Handle<v8::Value>* result) const; 101 v8::Handle<v8::Value>* result) const;
100 102
101 // Returns the availability of the API |api_name|. 103 // Returns the availability of the API |api_name|.
102 Feature::Availability GetAvailability(const std::string& api_name); 104 Feature::Availability GetAvailability(const std::string& api_name);
103 105
104 // Returns a string description of the type of context this is. 106 // Returns a string description of the type of context this is.
105 std::string GetContextTypeDescription(); 107 std::string GetContextTypeDescription();
106 108
109 // RequestSender::Source implementation.
110 virtual ChromeV8Context* GetContext() OVERRIDE;
111 virtual void OnResponseReceived(const std::string& name,
112 int request_id,
113 bool success,
114 const base::ListValue& response,
115 const std::string& error) OVERRIDE;
116
107 private: 117 private:
108 // The v8 context the bindings are accessible to. 118 // The v8 context the bindings are accessible to.
109 ScopedPersistent<v8::Context> v8_context_; 119 ScopedPersistent<v8::Context> v8_context_;
110 120
111 // The WebFrame associated with this context. This can be NULL because this 121 // The WebFrame associated with this context. This can be NULL because this
112 // object can outlive is destroyed asynchronously. 122 // object can outlive is destroyed asynchronously.
113 WebKit::WebFrame* web_frame_; 123 WebKit::WebFrame* web_frame_;
114 124
115 // The extension associated with this context, or NULL if there is none. This 125 // The extension associated with this context, or NULL if there is none. This
116 // might be a hosted app in the case that this context is hosting a web URL. 126 // might be a hosted app in the case that this context is hosting a web URL.
117 scoped_refptr<const Extension> extension_; 127 scoped_refptr<const Extension> extension_;
118 128
119 // The type of context. 129 // The type of context.
120 Feature::Context context_type_; 130 Feature::Context context_type_;
121 131
122 // Owns and structures the JS that is injected to set up extension bindings. 132 // Owns and structures the JS that is injected to set up extension bindings.
123 scoped_ptr<ModuleSystem> module_system_; 133 scoped_ptr<ModuleSystem> module_system_;
124 134
125 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context); 135 DISALLOW_COPY_AND_ASSIGN(ChromeV8Context);
126 }; 136 };
127 137
128 } // namespace extensions 138 } // namespace extensions
129 139
130 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_ 140 #endif // CHROME_RENDERER_EXTENSIONS_CHROME_V8_CONTEXT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/extensions/chrome_v8_context.cc » ('j') | chrome/renderer/extensions/request_sender.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698