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

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

Issue 23530029: Support webview tag when the container extension is embedded in a webUI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged Created 7 years, 2 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
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 "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 "content/public/renderer/render_view.h" 10 #include "chrome/renderer/extensions/chrome_v8_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 "third_party/WebKit/public/web/WebView.h"
14 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
15 14
16 namespace extensions { 15 namespace extensions {
17 16
18 DocumentCustomBindings::DocumentCustomBindings( 17 DocumentCustomBindings::DocumentCustomBindings(
19 Dispatcher* dispatcher, ChromeV8Context* context) 18 Dispatcher* dispatcher, ChromeV8Context* context)
20 : ChromeV8Extension(dispatcher, context) { 19 : ChromeV8Extension(dispatcher, context) {
21 RouteFunction("RegisterElement", 20 RouteFunction("RegisterElement",
22 base::Bind(&DocumentCustomBindings::RegisterElement, 21 base::Bind(&DocumentCustomBindings::RegisterElement,
23 base::Unretained(this))); 22 base::Unretained(this)));
24 } 23 }
25 24
26 // Attach an event name to an object. 25 // Attach an event name to an object.
27 void DocumentCustomBindings::RegisterElement( 26 void DocumentCustomBindings::RegisterElement(
28 const v8::FunctionCallbackInfo<v8::Value>& args) { 27 const v8::FunctionCallbackInfo<v8::Value>& args) {
29 content::RenderView* render_view = GetRenderView();
30 if (!render_view) {
31 return;
32 }
33
34 WebKit::WebView* web_view = render_view->GetWebView();
35 if (!web_view) {
36 return;
37 }
38
39 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsObject()) { 28 if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsObject()) {
40 NOTREACHED(); 29 NOTREACHED();
41 return; 30 return;
42 } 31 }
43 32
44 std::string element_name(*v8::String::AsciiValue(args[0])); 33 std::string element_name(*v8::String::AsciiValue(args[0]));
45 v8::Local<v8::Object> options = args[1]->ToObject(); 34 v8::Local<v8::Object> options = args[1]->ToObject();
46 35
47 WebKit::WebExceptionCode ec = 0; 36 WebKit::WebExceptionCode ec = 0;
48 WebKit::WebDocument document = web_view->mainFrame()->document(); 37 WebKit::WebDocument document = context()->web_frame()->document();
49 v8::Handle<v8::Value> constructor = 38 v8::Handle<v8::Value> constructor =
50 document.registerEmbedderCustomElement( 39 document.registerEmbedderCustomElement(
51 WebKit::WebString::fromUTF8(element_name), options, ec); 40 WebKit::WebString::fromUTF8(element_name), options, ec);
52 args.GetReturnValue().Set(constructor); 41 args.GetReturnValue().Set(constructor);
53 } 42 }
54 43
55 } // namespace extensions 44 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | content/browser/browser_plugin/browser_plugin_embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698