IndexedDB: fsync after transactions.
[chromium-blink-merge.git] / chrome / renderer / extensions / document_custom_bindings.cc
blobb8471a4802ec360c81da7a22fa3ad49612ad9a34
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
3 // found in the LICENSE file.
5 #include "chrome/renderer/extensions/document_custom_bindings.h"
7 #include <string>
9 #include "base/bind.h"
10 #include "chrome/renderer/extensions/chrome_v8_context.h"
11 #include "third_party/WebKit/public/web/WebDocument.h"
12 #include "third_party/WebKit/public/web/WebFrame.h"
13 #include "v8/include/v8.h"
15 namespace extensions {
17 DocumentCustomBindings::DocumentCustomBindings(
18 Dispatcher* dispatcher, ChromeV8Context* context)
19 : ChromeV8Extension(dispatcher, context) {
20 RouteFunction("RegisterElement",
21 base::Bind(&DocumentCustomBindings::RegisterElement,
22 base::Unretained(this)));
25 // Attach an event name to an object.
26 void DocumentCustomBindings::RegisterElement(
27 const v8::FunctionCallbackInfo<v8::Value>& args) {
28 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsObject()) {
29 NOTREACHED();
30 return;
33 std::string element_name(*v8::String::Utf8Value(args[0]));
34 v8::Local<v8::Object> options = args[1]->ToObject();
36 blink::WebExceptionCode ec = 0;
37 blink::WebDocument document = context()->web_frame()->document();
38 v8::Handle<v8::Value> constructor =
39 document.registerEmbedderCustomElement(
40 blink::WebString::fromUTF8(element_name), options, ec);
41 args.GetReturnValue().Set(constructor);
44 } // namespace extensions