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

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: fady's comment addressed Created 7 years, 3 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 "chrome/renderer/extensions/chrome_v8_context.h"
10 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
Fady Samuel 2013/09/12 22:46:46 This probably not necessary.
guohui 2013/09/13 00:04:02 Thanks for spotting this! Done.
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"
Fady Samuel 2013/09/12 22:46:46 This line might not be necessary.
guohui 2013/09/13 00:04:02 Done.
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)
20 : ChromeV8Extension(dispatcher, context) { 21 : ChromeV8Extension(dispatcher, context) {
21 RouteFunction("RegisterElement", 22 RouteFunction("RegisterElement",
22 base::Bind(&DocumentCustomBindings::RegisterElement, 23 base::Bind(&DocumentCustomBindings::RegisterElement,
23 base::Unretained(this))); 24 base::Unretained(this)));
24 } 25 }
25 26
26 // Attach an event name to an object. 27 // Attach an event name to an object.
27 void DocumentCustomBindings::RegisterElement( 28 void DocumentCustomBindings::RegisterElement(
28 const v8::FunctionCallbackInfo<v8::Value>& args) { 29 const v8::FunctionCallbackInfo<v8::Value>& args) {
29 content::RenderView* render_view = GetRenderView(); 30 content::RenderView* render_view = GetRenderView();
Fady Samuel 2013/09/12 22:46:46 These three lines are no longer necessary.
guohui 2013/09/13 00:04:02 On 2013/09/12 22:46:46, Fady Samuel wrote: > These
30 if (!render_view) { 31 if (!render_view) {
31 return; 32 return;
32 } 33 }
33 34
34 WebKit::WebView* web_view = render_view->GetWebView(); 35 WebKit::WebView* web_view = render_view->GetWebView();
Fady Samuel 2013/09/12 22:46:46 These 4 lines are no longer necessary. All the ch
guohui 2013/09/13 00:04:02 Changes in this file are an integral part of the w
35 if (!web_view) { 36 if (!web_view) {
36 return; 37 return;
37 } 38 }
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698