| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/renderer/render_view.h" | 8 #include "chrome/renderer/render_view.h" |
| 9 #include "webkit/api/public/WebFrame.h" | 9 #include "webkit/api/public/WebFrame.h" |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 RenderView* GetRenderViewForCurrentContext() { | 99 RenderView* GetRenderViewForCurrentContext() { |
| 100 WebFrame* webframe = WebFrame::frameForCurrentContext(); | 100 WebFrame* webframe = WebFrame::frameForCurrentContext(); |
| 101 DCHECK(webframe) << "RetrieveCurrentFrame called when not in a V8 context."; | 101 DCHECK(webframe) << "RetrieveCurrentFrame called when not in a V8 context."; |
| 102 if (!webframe) | 102 if (!webframe) |
| 103 return NULL; | 103 return NULL; |
| 104 | 104 |
| 105 WebView* webview = webframe->view(); | 105 WebView* webview = webframe->view(); |
| 106 if (!webview) | 106 if (!webview) |
| 107 return NULL; // can happen during closing | 107 return NULL; // can happen during closing |
| 108 | 108 |
| 109 RenderView* renderview = static_cast<RenderView*>(webview->GetDelegate()); | 109 RenderView* renderview = RenderView::FromWebView(webview); |
| 110 DCHECK(renderview) << "Encountered a WebView without a WebViewDelegate"; | 110 DCHECK(renderview) << "Encountered a WebView without a WebViewDelegate"; |
| 111 return renderview; | 111 return renderview; |
| 112 } | 112 } |
| 113 | 113 |
| 114 v8::Handle<v8::Value> CallFunctionInContext(v8::Handle<v8::Context> context, | 114 v8::Handle<v8::Value> CallFunctionInContext(v8::Handle<v8::Context> context, |
| 115 const std::string& function_name, int argc, | 115 const std::string& function_name, int argc, |
| 116 v8::Handle<v8::Value>* argv) { | 116 v8::Handle<v8::Value>* argv) { |
| 117 v8::Context::Scope context_scope(context); | 117 v8::Context::Scope context_scope(context); |
| 118 | 118 |
| 119 // Look up the function name, which may be a sub-property like | 119 // Look up the function name, which may be a sub-property like |
| (...skipping 12 matching lines...) Expand all Loading... |
| 132 } | 132 } |
| 133 | 133 |
| 134 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); | 134 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value); |
| 135 if (!function.IsEmpty()) | 135 if (!function.IsEmpty()) |
| 136 return function->Call(v8::Object::New(), argc, argv); | 136 return function->Call(v8::Object::New(), argc, argv); |
| 137 | 137 |
| 138 return v8::Undefined(); | 138 return v8::Undefined(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace bindings_utils | 141 } // namespace bindings_utils |
| OLD | NEW |