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

Unified Diff: content/renderer/web_intents_host.cc

Issue 11026070: Add API to construct new vector interchange MIME data type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/web_intents_host.cc
diff --git a/content/renderer/web_intents_host.cc b/content/renderer/web_intents_host.cc
index 9c60da3529fcf5f99ced41035fcc56b57fa0142a..f0425f2d0dcf5de2acf42ba655b2238c73986883 100644
--- a/content/renderer/web_intents_host.cc
+++ b/content/renderer/web_intents_host.cc
@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "base/utf_string_conversions.h"
#include "content/common/intents_messages.h"
+#include "content/public/renderer/v8_value_converter.h"
#include "content/renderer/render_view_impl.h"
#include "ipc/ipc_message.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
@@ -161,7 +162,6 @@ void WebIntentsHost::DidClearWindowObject(WebFrame* frame) {
serialized_data.toString(),
extras_keys, extras_values);
} else if (intent_->data_type == webkit_glue::WebIntentData::BLOB) {
- DCHECK(intent_->data_type == webkit_glue::WebIntentData::BLOB);
web_blob_ = WebBlob::createFromFile(
WebString::fromUTF8(intent_->blob_file.AsUTF8Unsafe()),
intent_->blob_length);
@@ -191,6 +191,36 @@ void WebIntentsHost::DidClearWindowObject(WebFrame* frame) {
web_intent = WebIntent::create(intent_->action, intent_->type,
serialized_data.toString(),
extras_keys, extras_values);
+ } else if (intent_->data_type == webkit_glue::WebIntentData::MIME_TYPE) {
+ // Do stuffs.
groby-ooo-7-16 2012/10/05 17:56:35 You're fixing that comment, right? ;)
Greg Billock 2012/10/05 22:03:26 :-) On 2012/10/05 17:56:35, groby wrote:
+ scoped_ptr<content::V8ValueConverter> converter(
+ content::V8ValueConverter::create());
+ v8::Handle<v8::Array> dataV8 = v8::Array::New(intent_->mime_data.GetSize());
+ size_t j;
+ for (j = 0; j < intent_->mime_data.GetSize(); ++j) {
+ const DictionaryValue* val;
+ if (!intent_->mime_data.GetDictionary(j, &val)) continue;
+ v8::Handle<v8::Value> data_point_value =
+ converter->ToV8Value(val, ctx);
+ if (!data_point_value->IsObject()) continue;
+ v8::Handle<v8::Object> data_point = data_point_value->ToObject();
+ if (j == 0 && !intent_->blob_file.empty()) {
groby-ooo-7-16 2012/10/05 17:56:35 This seems odd in here. Can we actually have blob
Greg Billock 2012/10/05 22:03:26 Yes. It's just a struct. I'm not sure how else to
+ // If we are carrying blob data, convert it to v8 format
+ // and set it to the "blob" property of |data_point|.
+ web_blob_ = WebBlob::createFromFile(
+ WebString::fromUTF8(intent_->blob_file.AsUTF8Unsafe()),
+ intent_->blob_length);
+ v8::Local<v8::String> blob_v8_key = v8::String::New("blob", 4);
+ data_point->Set(blob_v8_key, web_blob_.toV8Value());
+ }
+ dataV8->Set(j, data_point);
+ }
+
+ WebSerializedScriptValue serialized_data =
+ WebSerializedScriptValue::serialize(dataV8);
+ web_intent = WebIntent::create(intent_->action, intent_->type,
groby-ooo-7-16 2012/10/05 17:56:35 Can we take the last two lines out of all the sepa
Greg Billock 2012/10/05 22:03:26 Good point. Will do. On 2012/10/05 17:56:35, grob
+ serialized_data.toString(),
+ extras_keys, extras_values);
} else {
NOTREACHED();
}

Powered by Google App Engine
This is Rietveld 408576698