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_view.h" | 14 #include "content/public/renderer/render_view.h" |
14 #include "content/public/renderer/v8_value_converter.h" | 15 #include "content/public/renderer/v8_value_converter.h" |
15 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
16 #include "extensions/common/extension_api.h" | 17 #include "extensions/common/extension_api.h" |
17 #include "extensions/common/extension_urls.h" | 18 #include "extensions/common/extension_urls.h" |
18 #include "extensions/common/features/base_feature_provider.h" | 19 #include "extensions/common/features/base_feature_provider.h" |
19 #include "gin/per_context_data.h" | 20 #include "gin/per_context_data.h" |
20 #include "third_party/WebKit/public/web/WebDataSource.h" | 21 #include "third_party/WebKit/public/web/WebDataSource.h" |
21 #include "third_party/WebKit/public/web/WebDocument.h" | 22 #include "third_party/WebKit/public/web/WebDocument.h" |
22 #include "third_party/WebKit/public/web/WebFrame.h" | 23 #include "third_party/WebKit/public/web/WebFrame.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 v8_context_.reset(); | 63 v8_context_.reset(); |
63 } | 64 } |
64 | 65 |
65 const std::string& ScriptContext::GetExtensionID() const { | 66 const std::string& ScriptContext::GetExtensionID() const { |
66 return extension_.get() ? extension_->id() : base::EmptyString(); | 67 return extension_.get() ? extension_->id() : base::EmptyString(); |
67 } | 68 } |
68 | 69 |
69 content::RenderView* ScriptContext::GetRenderView() const { | 70 content::RenderView* ScriptContext::GetRenderView() const { |
70 if (web_frame_ && web_frame_->view()) | 71 if (web_frame_ && web_frame_->view()) |
71 return content::RenderView::FromWebView(web_frame_->view()); | 72 return content::RenderView::FromWebView(web_frame_->view()); |
72 else | 73 return NULL; |
73 return NULL; | 74 } |
| 75 |
| 76 content::RenderFrame* ScriptContext::GetRenderFrame() const { |
| 77 if (web_frame_) |
| 78 return content::RenderFrame::FromWebFrame(web_frame_); |
| 79 return NULL; |
74 } | 80 } |
75 | 81 |
76 v8::Local<v8::Value> ScriptContext::CallFunction( | 82 v8::Local<v8::Value> ScriptContext::CallFunction( |
77 v8::Handle<v8::Function> function, | 83 v8::Handle<v8::Function> function, |
78 int argc, | 84 int argc, |
79 v8::Handle<v8::Value> argv[]) const { | 85 v8::Handle<v8::Value> argv[]) const { |
80 v8::EscapableHandleScope handle_scope(isolate()); | 86 v8::EscapableHandleScope handle_scope(isolate()); |
81 v8::Context::Scope scope(v8_context()); | 87 v8::Context::Scope scope(v8_context()); |
82 | 88 |
83 blink::WebScopedMicrotaskSuppression suppression; | 89 blink::WebScopedMicrotaskSuppression suppression; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 v8::Handle<v8::Value> argv[]) { | 244 v8::Handle<v8::Value> argv[]) { |
239 return CallFunction(function, argc, argv); | 245 return CallFunction(function, argc, argv); |
240 } | 246 } |
241 | 247 |
242 gin::ContextHolder* ScriptContext::GetContextHolder() { | 248 gin::ContextHolder* ScriptContext::GetContextHolder() { |
243 v8::HandleScope handle_scope(isolate()); | 249 v8::HandleScope handle_scope(isolate()); |
244 return gin::PerContextData::From(v8_context())->context_holder(); | 250 return gin::PerContextData::From(v8_context())->context_holder(); |
245 } | 251 } |
246 | 252 |
247 } // namespace extensions | 253 } // namespace extensions |
OLD | NEW |