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

Side by Side Diff: extensions/renderer/script_context.h

Issue 983793003: Replace extensions::ScopedPersistent with v8::UniquePersistent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « extensions/renderer/scoped_persistent.h ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 6 #define EXTENSIONS_RENDERER_SCRIPT_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 "base/compiler_specific.h"
12 #include "extensions/common/features/feature.h" 12 #include "extensions/common/features/feature.h"
13 #include "extensions/common/permissions/api_permission_set.h" 13 #include "extensions/common/permissions/api_permission_set.h"
14 #include "extensions/renderer/module_system.h" 14 #include "extensions/renderer/module_system.h"
15 #include "extensions/renderer/request_sender.h" 15 #include "extensions/renderer/request_sender.h"
16 #include "extensions/renderer/safe_builtins.h" 16 #include "extensions/renderer/safe_builtins.h"
17 #include "extensions/renderer/scoped_persistent.h"
18 #include "gin/runner.h" 17 #include "gin/runner.h"
19 #include "url/gurl.h" 18 #include "url/gurl.h"
20 #include "v8/include/v8.h" 19 #include "v8/include/v8.h"
21 20
22 namespace blink { 21 namespace blink {
23 class WebFrame; 22 class WebFrame;
24 } 23 }
25 24
26 namespace content { 25 namespace content {
27 class RenderFrame; 26 class RenderFrame;
(...skipping 16 matching lines...) Expand all
44 43
45 // Clears the WebFrame for this contexts and invalidates the associated 44 // Clears the WebFrame for this contexts and invalidates the associated
46 // ModuleSystem. 45 // ModuleSystem.
47 void Invalidate(); 46 void Invalidate();
48 47
49 // Returns true if this context is still valid, false if it isn't. 48 // Returns true if this context is still valid, false if it isn't.
50 // A context becomes invalid via Invalidate(). 49 // A context becomes invalid via Invalidate().
51 bool is_valid() const { return !v8_context_.IsEmpty(); } 50 bool is_valid() const { return !v8_context_.IsEmpty(); }
52 51
53 v8::Handle<v8::Context> v8_context() const { 52 v8::Handle<v8::Context> v8_context() const {
54 return v8_context_.NewHandle(isolate()); 53 return v8::Local<v8::Context>::New(isolate_, v8_context_);
55 } 54 }
56 55
57 const Extension* extension() const { return extension_.get(); } 56 const Extension* extension() const { return extension_.get(); }
58 57
59 const Extension* effective_extension() const { 58 const Extension* effective_extension() const {
60 return effective_extension_.get(); 59 return effective_extension_.get();
61 } 60 }
62 61
63 blink::WebFrame* web_frame() const { return web_frame_; } 62 blink::WebFrame* web_frame() const { return web_frame_; }
64 63
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 void SetContentCapabilities(const APIPermissionSet& permissions); 145 void SetContentCapabilities(const APIPermissionSet& permissions);
147 146
148 // Indicates if this context has an effective API permission either by being 147 // Indicates if this context has an effective API permission either by being
149 // a context for an extension which has that permission, or by being a web 148 // a context for an extension which has that permission, or by being a web
150 // context which has been granted the corresponding capability by an 149 // context which has been granted the corresponding capability by an
151 // extension. 150 // extension.
152 bool HasAPIPermission(APIPermission::ID permission) const; 151 bool HasAPIPermission(APIPermission::ID permission) const;
153 152
154 protected: 153 protected:
155 // The v8 context the bindings are accessible to. 154 // The v8 context the bindings are accessible to.
156 ScopedPersistent<v8::Context> v8_context_; 155 v8::UniquePersistent<v8::Context> v8_context_;
157 156
158 private: 157 private:
159 class Runner; 158 class Runner;
160 159
161 // The WebFrame associated with this context. This can be NULL because this 160 // The WebFrame associated with this context. This can be NULL because this
162 // object can outlive is destroyed asynchronously. 161 // object can outlive is destroyed asynchronously.
163 blink::WebFrame* web_frame_; 162 blink::WebFrame* web_frame_;
164 163
165 // The extension associated with this context, or NULL if there is none. This 164 // The extension associated with this context, or NULL if there is none. This
166 // might be a hosted app in the case that this context is hosting a web URL. 165 // might be a hosted app in the case that this context is hosting a web URL.
(...skipping 24 matching lines...) Expand all
191 GURL url_; 190 GURL url_;
192 191
193 scoped_ptr<Runner> runner_; 192 scoped_ptr<Runner> runner_;
194 193
195 DISALLOW_COPY_AND_ASSIGN(ScriptContext); 194 DISALLOW_COPY_AND_ASSIGN(ScriptContext);
196 }; 195 };
197 196
198 } // namespace extensions 197 } // namespace extensions
199 198
200 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 199 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
OLDNEW
« no previous file with comments | « extensions/renderer/scoped_persistent.h ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698