OLD | NEW |
---|---|
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 #include "extensions/renderer/script_context.h" | 5 #include "extensions/renderer/script_context.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "content/public/common/url_constants.h" | 12 #include "content/public/common/url_constants.h" |
13 #include "content/public/renderer/render_frame.h" | 13 #include "content/public/renderer/render_frame.h" |
14 #include "content/public/renderer/render_view.h" | 14 #include "content/public/renderer/render_view.h" |
15 #include "content/public/renderer/v8_value_converter.h" | 15 #include "content/public/renderer/v8_value_converter.h" |
16 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
17 #include "extensions/common/extension_api.h" | 17 #include "extensions/common/extension_api.h" |
18 #include "extensions/common/extension_urls.h" | 18 #include "extensions/common/extension_urls.h" |
19 #include "extensions/common/features/base_feature_provider.h" | 19 #include "extensions/common/features/base_feature_provider.h" |
20 #include "extensions/common/permissions/permissions_data.h" | |
20 #include "gin/per_context_data.h" | 21 #include "gin/per_context_data.h" |
21 #include "third_party/WebKit/public/web/WebDataSource.h" | 22 #include "third_party/WebKit/public/web/WebDataSource.h" |
22 #include "third_party/WebKit/public/web/WebDocument.h" | 23 #include "third_party/WebKit/public/web/WebDocument.h" |
23 #include "third_party/WebKit/public/web/WebFrame.h" | 24 #include "third_party/WebKit/public/web/WebFrame.h" |
24 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" | 25 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
25 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 26 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
26 #include "third_party/WebKit/public/web/WebView.h" | 27 #include "third_party/WebKit/public/web/WebView.h" |
27 #include "v8/include/v8.h" | 28 #include "v8/include/v8.h" |
28 | 29 |
29 using content::V8ValueConverter; | 30 using content::V8ValueConverter; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 int argc, | 267 int argc, |
267 v8::Handle<v8::Value> argv[]) { | 268 v8::Handle<v8::Value> argv[]) { |
268 return CallFunction(function, argc, argv); | 269 return CallFunction(function, argc, argv); |
269 } | 270 } |
270 | 271 |
271 gin::ContextHolder* ScriptContext::GetContextHolder() { | 272 gin::ContextHolder* ScriptContext::GetContextHolder() { |
272 v8::HandleScope handle_scope(isolate()); | 273 v8::HandleScope handle_scope(isolate()); |
273 return gin::PerContextData::From(v8_context())->context_holder(); | 274 return gin::PerContextData::From(v8_context())->context_holder(); |
274 } | 275 } |
275 | 276 |
277 void ScriptContext::SetContentCapabilities( | |
278 const APIPermissionSet& permissions) { | |
279 content_capabilities_ = permissions; | |
not at google - send to devlin
2014/12/10 17:33:54
Can you just make ScriptContext (lazily, I suppose
Ken Rockot(use gerrit already)
2014/12/10 18:31:41
What about handling the case where an extension (w
| |
280 } | |
281 | |
282 bool ScriptContext::HasEffectiveAPIPermission( | |
283 APIPermission::ID permission) const { | |
284 if (content_capabilities_.find(permission) != content_capabilities_.end()) | |
285 return true; | |
not at google - send to devlin
2014/12/10 17:33:54
Consider being a little conservative here, and che
| |
286 if (effective_extension_.get()) { | |
287 return effective_extension_->permissions_data()->HasAPIPermission( | |
288 permission); | |
289 } | |
290 return false; | |
291 } | |
292 | |
276 } // namespace extensions | 293 } // namespace extensions |
OLD | NEW |