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

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

Issue 498513002: Respect the clipboardRead and clipboardWrite permissions in content scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address more comments Created 6 years, 3 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
« no previous file with comments | « extensions/renderer/module_system_test.cc ('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"
(...skipping 17 matching lines...) Expand all
28 28
29 namespace extensions { 29 namespace extensions {
30 class Extension; 30 class Extension;
31 31
32 // Extensions wrapper for a v8 context. 32 // Extensions wrapper for a v8 context.
33 class ScriptContext : public RequestSender::Source, public gin::Runner { 33 class ScriptContext : public RequestSender::Source, public gin::Runner {
34 public: 34 public:
35 ScriptContext(const v8::Handle<v8::Context>& context, 35 ScriptContext(const v8::Handle<v8::Context>& context,
36 blink::WebFrame* frame, 36 blink::WebFrame* frame,
37 const Extension* extension, 37 const Extension* extension,
38 Feature::Context context_type); 38 Feature::Context context_type,
39 const Extension* effective_extension,
40 Feature::Context effective_context_type);
39 virtual ~ScriptContext(); 41 virtual ~ScriptContext();
40 42
41 // Clears the WebFrame for this contexts and invalidates the associated 43 // Clears the WebFrame for this contexts and invalidates the associated
42 // ModuleSystem. 44 // ModuleSystem.
43 void Invalidate(); 45 void Invalidate();
44 46
45 // Returns true if this context is still valid, false if it isn't. 47 // Returns true if this context is still valid, false if it isn't.
46 // A context becomes invalid via Invalidate(). 48 // A context becomes invalid via Invalidate().
47 bool is_valid() const { return !v8_context_.IsEmpty(); } 49 bool is_valid() const { return !v8_context_.IsEmpty(); }
48 50
49 v8::Handle<v8::Context> v8_context() const { 51 v8::Handle<v8::Context> v8_context() const {
50 return v8_context_.NewHandle(isolate()); 52 return v8_context_.NewHandle(isolate());
51 } 53 }
52 54
53 const Extension* extension() const { return extension_.get(); } 55 const Extension* extension() const { return extension_.get(); }
54 56
57 const Extension* effective_extension() const {
58 return effective_extension_.get();
59 }
60
55 blink::WebFrame* web_frame() const { return web_frame_; } 61 blink::WebFrame* web_frame() const { return web_frame_; }
56 62
57 Feature::Context context_type() const { return context_type_; } 63 Feature::Context context_type() const { return context_type_; }
58 64
65 Feature::Context effective_context_type() const {
66 return effective_context_type_;
67 }
68
59 void set_module_system(scoped_ptr<ModuleSystem> module_system) { 69 void set_module_system(scoped_ptr<ModuleSystem> module_system) {
60 module_system_ = module_system.Pass(); 70 module_system_ = module_system.Pass();
61 } 71 }
62 72
63 ModuleSystem* module_system() { return module_system_.get(); } 73 ModuleSystem* module_system() { return module_system_.get(); }
64 74
65 SafeBuiltins* safe_builtins() { return &safe_builtins_; } 75 SafeBuiltins* safe_builtins() { return &safe_builtins_; }
66 76
67 const SafeBuiltins* safe_builtins() const { return &safe_builtins_; } 77 const SafeBuiltins* safe_builtins() const { return &safe_builtins_; }
68 78
(...skipping 21 matching lines...) Expand all
90 100
91 // Fires the onunload event on the unload_event module. 101 // Fires the onunload event on the unload_event module.
92 void DispatchOnUnloadEvent(); 102 void DispatchOnUnloadEvent();
93 103
94 // Returns the availability of the API |api_name|. 104 // Returns the availability of the API |api_name|.
95 Feature::Availability GetAvailability(const std::string& api_name); 105 Feature::Availability GetAvailability(const std::string& api_name);
96 106
97 // Returns a string description of the type of context this is. 107 // Returns a string description of the type of context this is.
98 std::string GetContextTypeDescription(); 108 std::string GetContextTypeDescription();
99 109
110 // Returns a string description of the effective type of context this is.
111 std::string GetEffectiveContextTypeDescription();
112
100 v8::Isolate* isolate() const { return isolate_; } 113 v8::Isolate* isolate() const { return isolate_; }
101 114
102 // Get the URL of this context's web frame. 115 // Get the URL of this context's web frame.
103 GURL GetURL() const; 116 GURL GetURL() const;
104 117
105 // Returns whether the API |api| or any part of the API could be 118 // Returns whether the API |api| or any part of the API could be
106 // available in this context without taking into account the context's 119 // available in this context without taking into account the context's
107 // extension. 120 // extension.
108 bool IsAnyFeatureAvailableToContext(const extensions::Feature& api); 121 bool IsAnyFeatureAvailableToContext(const extensions::Feature& api);
109 122
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // object can outlive is destroyed asynchronously. 158 // object can outlive is destroyed asynchronously.
146 blink::WebFrame* web_frame_; 159 blink::WebFrame* web_frame_;
147 160
148 // The extension associated with this context, or NULL if there is none. This 161 // The extension associated with this context, or NULL if there is none. This
149 // might be a hosted app in the case that this context is hosting a web URL. 162 // might be a hosted app in the case that this context is hosting a web URL.
150 scoped_refptr<const Extension> extension_; 163 scoped_refptr<const Extension> extension_;
151 164
152 // The type of context. 165 // The type of context.
153 Feature::Context context_type_; 166 Feature::Context context_type_;
154 167
168 // The effective extension associated with this context, or NULL if there is
169 // none. This is different from the above extension if this context is in an
170 // about:blank iframe for example.
171 scoped_refptr<const Extension> effective_extension_;
172
173 // The type of context.
174 Feature::Context effective_context_type_;
175
155 // Owns and structures the JS that is injected to set up extension bindings. 176 // Owns and structures the JS that is injected to set up extension bindings.
156 scoped_ptr<ModuleSystem> module_system_; 177 scoped_ptr<ModuleSystem> module_system_;
157 178
158 // Contains safe copies of builtin objects like Function.prototype. 179 // Contains safe copies of builtin objects like Function.prototype.
159 SafeBuiltins safe_builtins_; 180 SafeBuiltins safe_builtins_;
160 181
161 v8::Isolate* isolate_; 182 v8::Isolate* isolate_;
162 183
163 DISALLOW_COPY_AND_ASSIGN(ScriptContext); 184 DISALLOW_COPY_AND_ASSIGN(ScriptContext);
164 }; 185 };
165 186
166 } // namespace extensions 187 } // namespace extensions
167 188
168 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 189 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
OLDNEW
« no previous file with comments | « extensions/renderer/module_system_test.cc ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698