Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: extensions/renderer/document_custom_bindings.cc

Issue 235943018: Move extensions bindings code out of //chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/renderer/document_custom_bindings.h ('k') | extensions/renderer/extension_groups.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "extensions/renderer/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 "extensions/renderer/script_context.h"
11 #include "third_party/WebKit/public/web/WebDocument.h" 11 #include "third_party/WebKit/public/web/WebDocument.h"
12 #include "third_party/WebKit/public/web/WebFrame.h" 12 #include "third_party/WebKit/public/web/WebFrame.h"
13 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 DocumentCustomBindings::DocumentCustomBindings( 17 DocumentCustomBindings::DocumentCustomBindings(ScriptContext* context)
18 Dispatcher* dispatcher, ChromeV8Context* context) 18 : ObjectBackedNativeHandler(context) {
19 : ChromeV8Extension(dispatcher, context) {
20 RouteFunction("RegisterElement", 19 RouteFunction("RegisterElement",
21 base::Bind(&DocumentCustomBindings::RegisterElement, 20 base::Bind(&DocumentCustomBindings::RegisterElement,
22 base::Unretained(this))); 21 base::Unretained(this)));
23 } 22 }
24 23
25 // Attach an event name to an object. 24 // Attach an event name to an object.
26 void DocumentCustomBindings::RegisterElement( 25 void DocumentCustomBindings::RegisterElement(
27 const v8::FunctionCallbackInfo<v8::Value>& args) { 26 const v8::FunctionCallbackInfo<v8::Value>& args) {
28 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsObject()) { 27 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsObject()) {
29 NOTREACHED(); 28 NOTREACHED();
30 return; 29 return;
31 } 30 }
32 31
33 std::string element_name(*v8::String::Utf8Value(args[0])); 32 std::string element_name(*v8::String::Utf8Value(args[0]));
34 v8::Local<v8::Object> options = args[1]->ToObject(); 33 v8::Local<v8::Object> options = args[1]->ToObject();
35 34
36 blink::WebExceptionCode ec = 0; 35 blink::WebExceptionCode ec = 0;
37 blink::WebDocument document = context()->web_frame()->document(); 36 blink::WebDocument document = context()->web_frame()->document();
38 v8::Handle<v8::Value> constructor = 37 v8::Handle<v8::Value> constructor = document.registerEmbedderCustomElement(
39 document.registerEmbedderCustomElement( 38 blink::WebString::fromUTF8(element_name), options, ec);
40 blink::WebString::fromUTF8(element_name), options, ec);
41 args.GetReturnValue().Set(constructor); 39 args.GetReturnValue().Set(constructor);
42 } 40 }
43 41
44 } // namespace extensions 42 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/document_custom_bindings.h ('k') | extensions/renderer/extension_groups.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698