| 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 | |
| 53 ContextList& GetContexts() { | 41 ContextList& GetContexts() { |
| 54 return g_singleton_data.Get().contexts; | 42 return g_singleton_data.Get().contexts; |
| 55 } | 43 } |
| 56 | 44 |
| 57 ContextInfo* GetInfoForCurrentContext() { | 45 ContextInfo* GetInfoForCurrentContext() { |
| 58 // This can happen in testing scenarios and v8::Context::GetCurrent() crashes | 46 // This can happen in testing scenarios and v8::Context::GetCurrent() crashes |
| 59 // if there is no JavaScript currently running. | 47 // if there is no JavaScript currently running. |
| 60 if (!v8::Context::InContext()) | 48 if (!v8::Context::InContext()) |
| 61 return NULL; | 49 return NULL; |
| 62 | 50 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 122 } |
| 135 | 123 |
| 136 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); | 124 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); |
| 137 if (!function.IsEmpty()) | 125 if (!function.IsEmpty()) |
| 138 return function->Call(v8::Object::New(), argc, argv); | 126 return function->Call(v8::Object::New(), argc, argv); |
| 139 | 127 |
| 140 return v8::Undefined(); | 128 return v8::Undefined(); |
| 141 } | 129 } |
| 142 | 130 |
| 143 } // namespace bindings_utils | 131 } // namespace bindings_utils |
| OLD | NEW |