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/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "content/public/child/v8_value_converter.h" | 13 #include "content/public/child/v8_value_converter.h" |
14 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
15 #include "content/public/renderer/render_frame.h" | 15 #include "content/public/renderer/render_frame.h" |
16 #include "extensions/common/constants.h" | 16 #include "extensions/common/constants.h" |
17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
18 #include "extensions/common/extension_api.h" | 18 #include "extensions/common/extension_api.h" |
19 #include "extensions/common/extension_set.h" | |
20 #include "extensions/common/extension_urls.h" | 19 #include "extensions/common/extension_urls.h" |
21 #include "extensions/common/features/base_feature_provider.h" | 20 #include "extensions/common/features/base_feature_provider.h" |
22 #include "extensions/common/manifest_handlers/sandboxed_page_info.h" | 21 #include "extensions/common/manifest_handlers/sandboxed_page_info.h" |
23 #include "extensions/common/permissions/permissions_data.h" | 22 #include "extensions/common/permissions/permissions_data.h" |
| 23 #include "extensions/renderer/renderer_extension_registry.h" |
24 #include "gin/per_context_data.h" | 24 #include "gin/per_context_data.h" |
25 #include "third_party/WebKit/public/web/WebDataSource.h" | 25 #include "third_party/WebKit/public/web/WebDataSource.h" |
26 #include "third_party/WebKit/public/web/WebDocument.h" | 26 #include "third_party/WebKit/public/web/WebDocument.h" |
27 #include "third_party/WebKit/public/web/WebFrame.h" | 27 #include "third_party/WebKit/public/web/WebFrame.h" |
28 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 28 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
29 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" | 29 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
30 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 30 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
31 #include "third_party/WebKit/public/web/WebView.h" | 31 #include "third_party/WebKit/public/web/WebView.h" |
32 #include "v8/include/v8.h" | 32 #include "v8/include/v8.h" |
33 | 33 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 ScriptContext::~ScriptContext() { | 113 ScriptContext::~ScriptContext() { |
114 VLOG(1) << "Destroyed context for extension\n" | 114 VLOG(1) << "Destroyed context for extension\n" |
115 << " extension id: " << GetExtensionID() << "\n" | 115 << " extension id: " << GetExtensionID() << "\n" |
116 << " effective extension id: " | 116 << " effective extension id: " |
117 << (effective_extension_.get() ? effective_extension_->id() : ""); | 117 << (effective_extension_.get() ? effective_extension_->id() : ""); |
118 CHECK(!is_valid_) << "ScriptContexts must be invalidated before destruction"; | 118 CHECK(!is_valid_) << "ScriptContexts must be invalidated before destruction"; |
119 } | 119 } |
120 | 120 |
121 // static | 121 // static |
122 bool ScriptContext::IsSandboxedPage(const ExtensionSet& extensions, | 122 bool ScriptContext::IsSandboxedPage(const GURL& url) { |
123 const GURL& url) { | |
124 // TODO(kalman): This is checking the wrong thing. See comment in | 123 // TODO(kalman): This is checking the wrong thing. See comment in |
125 // HasAccessOrThrowError. | 124 // HasAccessOrThrowError. |
126 if (url.SchemeIs(kExtensionScheme)) { | 125 if (url.SchemeIs(kExtensionScheme)) { |
127 const Extension* extension = extensions.GetByID(url.host()); | 126 const Extension* extension = |
| 127 RendererExtensionRegistry::Get()->GetByID(url.host()); |
128 if (extension) { | 128 if (extension) { |
129 return SandboxedPageInfo::IsSandboxedPage(extension, url.path()); | 129 return SandboxedPageInfo::IsSandboxedPage(extension, url.path()); |
130 } | 130 } |
131 } | 131 } |
132 return false; | 132 return false; |
133 } | 133 } |
134 | 134 |
135 void ScriptContext::Invalidate() { | 135 void ScriptContext::Invalidate() { |
136 CHECK(is_valid_); | 136 CHECK(is_valid_); |
137 is_valid_ = false; | 137 is_valid_ = false; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 v8::Local<v8::Value> argv[]) { | 418 v8::Local<v8::Value> argv[]) { |
419 return context_->CallFunction(function, argc, argv); | 419 return context_->CallFunction(function, argc, argv); |
420 } | 420 } |
421 | 421 |
422 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { | 422 gin::ContextHolder* ScriptContext::Runner::GetContextHolder() { |
423 v8::HandleScope handle_scope(context_->isolate()); | 423 v8::HandleScope handle_scope(context_->isolate()); |
424 return gin::PerContextData::From(context_->v8_context())->context_holder(); | 424 return gin::PerContextData::From(context_->v8_context())->context_holder(); |
425 } | 425 } |
426 | 426 |
427 } // namespace extensions | 427 } // namespace extensions |
OLD | NEW |