| OLD | NEW |
| 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_frame.h" | 9 #include "content/public/renderer/render_frame.h" |
| 10 #include "extensions/common/extension_messages.h" | 10 #include "extensions/common/extension_messages.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 RouteFunction("SendResponseAck", "pageCapture", | 22 RouteFunction("SendResponseAck", "pageCapture", |
| 23 base::Bind(&PageCaptureCustomBindings::SendResponseAck, | 23 base::Bind(&PageCaptureCustomBindings::SendResponseAck, |
| 24 base::Unretained(this))); | 24 base::Unretained(this))); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void PageCaptureCustomBindings::CreateBlob( | 27 void PageCaptureCustomBindings::CreateBlob( |
| 28 const v8::FunctionCallbackInfo<v8::Value>& args) { | 28 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 29 CHECK(args.Length() == 2); | 29 CHECK(args.Length() == 2); |
| 30 CHECK(args[0]->IsString()); | 30 CHECK(args[0]->IsString()); |
| 31 CHECK(args[1]->IsInt32()); | 31 CHECK(args[1]->IsInt32()); |
| 32 blink::WebString path(base::UTF8ToUTF16(*v8::String::Utf8Value(args[0]))); | 32 blink::WebString path( |
| 33 blink::WebString::fromUTF8(*v8::String::Utf8Value(args[0]))); |
| 33 blink::WebBlob blob = | 34 blink::WebBlob blob = |
| 34 blink::WebBlob::createFromFile(path, args[1]->Int32Value()); | 35 blink::WebBlob::createFromFile(path, args[1]->Int32Value()); |
| 35 args.GetReturnValue().Set( | 36 args.GetReturnValue().Set( |
| 36 blob.toV8Value(context()->v8_context()->Global(), args.GetIsolate())); | 37 blob.toV8Value(context()->v8_context()->Global(), args.GetIsolate())); |
| 37 } | 38 } |
| 38 | 39 |
| 39 void PageCaptureCustomBindings::SendResponseAck( | 40 void PageCaptureCustomBindings::SendResponseAck( |
| 40 const v8::FunctionCallbackInfo<v8::Value>& args) { | 41 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 41 CHECK(args.Length() == 1); | 42 CHECK(args.Length() == 1); |
| 42 CHECK(args[0]->IsInt32()); | 43 CHECK(args[0]->IsInt32()); |
| 43 | 44 |
| 44 content::RenderFrame* render_frame = context()->GetRenderFrame(); | 45 content::RenderFrame* render_frame = context()->GetRenderFrame(); |
| 45 if (render_frame) { | 46 if (render_frame) { |
| 46 render_frame->Send(new ExtensionHostMsg_ResponseAck( | 47 render_frame->Send(new ExtensionHostMsg_ResponseAck( |
| 47 render_frame->GetRoutingID(), args[0]->Int32Value())); | 48 render_frame->GetRoutingID(), args[0]->Int32Value())); |
| 48 } | 49 } |
| 49 } | 50 } |
| 50 | 51 |
| 51 } // namespace extensions | 52 } // namespace extensions |
| OLD | NEW |