| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/document_custom_bindings.h" | 5 #include "chrome/renderer/extensions/document_custom_bindings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 10 #include "content/public/renderer/render_view.h" | 11 #include "content/public/renderer/render_view.h" |
| 11 #include "third_party/WebKit/public/web/WebDocument.h" | 12 #include "third_party/WebKit/public/web/WebDocument.h" |
| 12 #include "third_party/WebKit/public/web/WebFrame.h" | 13 #include "third_party/WebKit/public/web/WebFrame.h" |
| 13 #include "third_party/WebKit/public/web/WebView.h" | 14 #include "third_party/WebKit/public/web/WebView.h" |
| 14 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 | 18 |
| 18 DocumentCustomBindings::DocumentCustomBindings( | 19 DocumentCustomBindings::DocumentCustomBindings( |
| 19 Dispatcher* dispatcher, ChromeV8Context* context) | 20 Dispatcher* dispatcher, ChromeV8Context* context) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 38 | 39 |
| 39 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsObject()) { | 40 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsObject()) { |
| 40 NOTREACHED(); | 41 NOTREACHED(); |
| 41 return; | 42 return; |
| 42 } | 43 } |
| 43 | 44 |
| 44 std::string element_name(*v8::String::AsciiValue(args[0])); | 45 std::string element_name(*v8::String::AsciiValue(args[0])); |
| 45 v8::Local<v8::Object> options = args[1]->ToObject(); | 46 v8::Local<v8::Object> options = args[1]->ToObject(); |
| 46 | 47 |
| 47 WebKit::WebExceptionCode ec = 0; | 48 WebKit::WebExceptionCode ec = 0; |
| 48 WebKit::WebDocument document = web_view->mainFrame()->document(); | 49 WebKit::WebDocument document = context()->web_frame()->document(); |
| 49 v8::Handle<v8::Value> constructor = | 50 v8::Handle<v8::Value> constructor = |
| 50 document.registerEmbedderCustomElement( | 51 document.registerEmbedderCustomElement( |
| 51 WebKit::WebString::fromUTF8(element_name), options, ec); | 52 WebKit::WebString::fromUTF8(element_name), options, ec); |
| 52 args.GetReturnValue().Set(constructor); | 53 args.GetReturnValue().Set(constructor); |
| 53 } | 54 } |
| 54 | 55 |
| 55 } // namespace extensions | 56 } // namespace extensions |
| OLD | NEW |