| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/renderer/extensions/bindings_utils.h" | 5 #include "chrome/renderer/extensions/bindings_utils.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/string_split.h" | 8 #include "base/string_split.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "content/renderer/render_view.h" | 10 #include "content/renderer/render_view.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 const std::string& extension_id, | 31 const std::string& extension_id, |
| 32 WebFrame* frame) | 32 WebFrame* frame) |
| 33 : context(context), | 33 : context(context), |
| 34 extension_id(extension_id), | 34 extension_id(extension_id), |
| 35 unsafe_frame(frame), | 35 unsafe_frame(frame), |
| 36 num_connected_events(0) { | 36 num_connected_events(0) { |
| 37 } | 37 } |
| 38 | 38 |
| 39 ContextInfo::~ContextInfo() {} | 39 ContextInfo::~ContextInfo() {} |
| 40 | 40 |
| 41 WebFrame* ContextInfo::GetWebFrame() const { |
| 42 return WebFrame::frameForContext(context); |
| 43 } |
| 44 |
| 45 RenderView* ContextInfo::GetRenderView() const { |
| 46 WebFrame* frame = GetWebFrame(); |
| 47 if (!frame || !frame->view()) |
| 48 return NULL; |
| 49 |
| 50 return RenderView::FromWebView(frame->view()); |
| 51 } |
| 52 |
| 41 ContextList& GetContexts() { | 53 ContextList& GetContexts() { |
| 42 return g_singleton_data.Get().contexts; | 54 return g_singleton_data.Get().contexts; |
| 43 } | 55 } |
| 44 | 56 |
| 45 ContextInfo* GetInfoForCurrentContext() { | 57 ContextInfo* GetInfoForCurrentContext() { |
| 46 // This can happen in testing scenarios and v8::Context::GetCurrent() crashes | 58 // This can happen in testing scenarios and v8::Context::GetCurrent() crashes |
| 47 // if there is no JavaScript currently running. | 59 // if there is no JavaScript currently running. |
| 48 if (!v8::Context::InContext()) | 60 if (!v8::Context::InContext()) |
| 49 return NULL; | 61 return NULL; |
| 50 | 62 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 134 } |
| 123 | 135 |
| 124 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); | 136 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); |
| 125 if (!function.IsEmpty()) | 137 if (!function.IsEmpty()) |
| 126 return function->Call(v8::Object::New(), argc, argv); | 138 return function->Call(v8::Object::New(), argc, argv); |
| 127 | 139 |
| 128 return v8::Undefined(); | 140 return v8::Undefined(); |
| 129 } | 141 } |
| 130 | 142 |
| 131 } // namespace bindings_utils | 143 } // namespace bindings_utils |
| OLD | NEW |