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

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

Issue 240603003: Remove ChromeV8Extension & most of ChromeV8Context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/page_capture_custom_bindings.h" 5 #include "chrome/renderer/extensions/page_capture_custom_bindings.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/renderer/render_view.h" 9 #include "content/public/renderer/render_view.h"
10 #include "extensions/common/extension_messages.h" 10 #include "extensions/common/extension_messages.h"
11 #include "grit/renderer_resources.h" 11 #include "extensions/renderer/script_context.h"
12 #include "third_party/WebKit/public/web/WebBlob.h" 12 #include "third_party/WebKit/public/web/WebBlob.h"
13 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 PageCaptureCustomBindings::PageCaptureCustomBindings( 17 PageCaptureCustomBindings::PageCaptureCustomBindings(ScriptContext* context)
18 Dispatcher* dispatcher, 18 : ObjectBackedNativeHandler(context) {
19 ChromeV8Context* context)
20 : ChromeV8Extension(dispatcher, context) {
21 RouteFunction("CreateBlob", 19 RouteFunction("CreateBlob",
22 base::Bind(&PageCaptureCustomBindings::CreateBlob, 20 base::Bind(&PageCaptureCustomBindings::CreateBlob,
23 base::Unretained(this))); 21 base::Unretained(this)));
24 RouteFunction("SendResponseAck", 22 RouteFunction("SendResponseAck",
25 base::Bind(&PageCaptureCustomBindings::SendResponseAck, 23 base::Bind(&PageCaptureCustomBindings::SendResponseAck,
26 base::Unretained(this))); 24 base::Unretained(this)));
27 } 25 }
28 26
29 void PageCaptureCustomBindings::CreateBlob( 27 void PageCaptureCustomBindings::CreateBlob(
30 const v8::FunctionCallbackInfo<v8::Value>& args) { 28 const v8::FunctionCallbackInfo<v8::Value>& args) {
31 CHECK(args.Length() == 2); 29 CHECK(args.Length() == 2);
32 CHECK(args[0]->IsString()); 30 CHECK(args[0]->IsString());
33 CHECK(args[1]->IsInt32()); 31 CHECK(args[1]->IsInt32());
34 blink::WebString path(base::UTF8ToUTF16(*v8::String::Utf8Value(args[0]))); 32 blink::WebString path(base::UTF8ToUTF16(*v8::String::Utf8Value(args[0])));
35 blink::WebBlob blob = 33 blink::WebBlob blob =
36 blink::WebBlob::createFromFile(path, args[1]->Int32Value()); 34 blink::WebBlob::createFromFile(path, args[1]->Int32Value());
37 args.GetReturnValue().Set(blob.toV8Value()); 35 args.GetReturnValue().Set(blob.toV8Value());
38 } 36 }
39 37
40 void PageCaptureCustomBindings::SendResponseAck( 38 void PageCaptureCustomBindings::SendResponseAck(
41 const v8::FunctionCallbackInfo<v8::Value>& args) { 39 const v8::FunctionCallbackInfo<v8::Value>& args) {
42 CHECK(args.Length() == 1); 40 CHECK(args.Length() == 1);
43 CHECK(args[0]->IsInt32()); 41 CHECK(args[0]->IsInt32());
44 42
45 content::RenderView* render_view = GetRenderView(); 43 content::RenderView* render_view = context()->GetRenderView();
46 if (render_view) { 44 if (render_view) {
47 render_view->Send(new ExtensionHostMsg_ResponseAck( 45 render_view->Send(new ExtensionHostMsg_ResponseAck(
48 render_view->GetRoutingID(), args[0]->Int32Value())); 46 render_view->GetRoutingID(), args[0]->Int32Value()));
49 } 47 }
50 } 48 }
51 49
52 } // namespace extensions 50 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698