| Index: content/renderer/web_intents_host.cc
|
| diff --git a/content/renderer/web_intents_host.cc b/content/renderer/web_intents_host.cc
|
| index 6f2e05abd5e132e160377bdfd753603610d56a83..1bba7815965e89e1be6eb6098aa29fc0f8aca5fb 100644
|
| --- a/content/renderer/web_intents_host.cc
|
| +++ b/content/renderer/web_intents_host.cc
|
| @@ -10,6 +10,7 @@
|
| #include "content/renderer/render_view_impl.h"
|
| #include "ipc/ipc_message.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebBlob.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
| @@ -19,6 +20,7 @@
|
| #include "webkit/glue/cpp_bound_class.h"
|
|
|
| using WebKit::WebBindings;
|
| +using WebKit::WebBlob;
|
| using WebKit::WebCString;
|
| using WebKit::WebFrame;
|
| using WebKit::WebIntentRequest;
|
| @@ -31,26 +33,35 @@ using WebKit::WebSerializedScriptValue;
|
| // browser-provided Javascript API objects on |window|.
|
| class WebIntentsHost::BoundDeliveredIntent : public CppBoundClass {
|
| public:
|
| - BoundDeliveredIntent(const string16& action,
|
| - const string16& type,
|
| - const string16& data,
|
| + BoundDeliveredIntent(const webkit_glue::WebIntentData& intent,
|
| WebIntentsHost* parent,
|
| WebFrame* frame) {
|
| - action_ = WebString(action).utf8();
|
| - type_ = WebString(type).utf8();
|
| + action_ = WebString(intent.action).utf8();
|
| + type_ = WebString(intent.type).utf8();
|
| parent_ = parent;
|
|
|
| v8::HandleScope scope;
|
| v8::Local<v8::Context> ctx = frame->mainWorldScriptContext();
|
| v8::Context::Scope cscope(ctx);
|
| - WebSerializedScriptValue ssv =
|
| - WebSerializedScriptValue::fromString(WebString(data));
|
| - // TODO(gbillock): use an exception handler instead? Need to
|
| - // pass back error state to caller? This is a pretty unexpected
|
| - // internal error...
|
| - CHECK(!ssv.isNull());
|
| - v8::Local<v8::Value> data_obj =
|
| - v8::Local<v8::Value>::New(ssv.deserialize());
|
| + v8::Local<v8::Value> data_obj;
|
| +
|
| + if (intent.data_type == webkit_glue::WebIntentData::SERIALIZED) {
|
| + WebSerializedScriptValue ssv =
|
| + WebSerializedScriptValue::fromString(WebString(intent.data));
|
| + // TODO(gbillock): use an exception handler instead? Need to
|
| + // pass back error state to caller? This is a pretty unexpected
|
| + // internal error...
|
| + CHECK(!ssv.isNull());
|
| + data_obj = v8::Local<v8::Value>::New(ssv.deserialize());
|
| + } else if (intent.data_type == webkit_glue::WebIntentData::UNSERIALIZED) {
|
| + data_obj = v8::String::New(intent.unserialized_data.data(),
|
| + intent.unserialized_data.length());
|
| + } else {
|
| + CHECK(intent.data_type == webkit_glue::WebIntentData::BLOB);
|
| + WebBlob web_blob = WebBlob::createFromFile(
|
| + WebString::fromUTF8(intent.blob_file), intent.blob_length);
|
| + data_obj = v8::Local<v8::Value>::New(web_blob.toV8Value());
|
| + }
|
|
|
| data_val_.reset(new CppVariant);
|
| WebBindings::toNPVariant(data_obj, frame->windowObject(), data_val_.get());
|
| @@ -195,7 +206,7 @@ void WebIntentsHost::DidClearWindowObject(WebFrame* frame) {
|
| if (intent_.get() == NULL || frame->top() != frame)
|
| return;
|
|
|
| - delivered_intent_.reset(new BoundDeliveredIntent(
|
| - intent_->action, intent_->type, intent_->data, this, frame));
|
| + delivered_intent_.reset(
|
| + new BoundDeliveredIntent(*(intent_.get()), this, frame));
|
| delivered_intent_->BindToJavascript(frame, "intent");
|
| }
|
|
|