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

Unified Diff: content/renderer/web_intents_host.cc

Issue 9692017: An internal intents dispatcher useful for initiating an intent from the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 6f2e05abd5e132e160377bdfd753603610d56a83..4be81cf2561a7bd5eb20632f82dbc9e83368514e 100644
--- a/content/renderer/web_intents_host.cc
+++ b/content/renderer/web_intents_host.cc
@@ -31,26 +31,31 @@ 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());
James Hawkins 2012/03/12 23:19:11 These should likely be DCHECKs.
Greg Billock 2012/03/12 23:52:22 We're parsing something we ourselves serialized. I
James Hawkins 2012/03/13 00:59:02 DCHECK vs CHECK is not about severity. CHECK shou
Greg Billock 2012/03/13 17:42:38 DCHECK here will immediately mean a harder-to-diag
James Hawkins 2012/03/13 18:22:03 How is that? They're the exact same except DCHECK
Greg Billock 2012/03/13 19:26:50 If control continues when ssv.isNull, ssv.deserial
+ data_obj = v8::Local<v8::Value>::New(ssv.deserialize());
+ } else {
+ CHECK(intent.data_type == webkit_glue::WebIntentData::UNSERIALIZED);
+ data_obj = v8::String::New(intent.unserialized_data.data(),
+ intent.unserialized_data.length());
+ }
data_val_.reset(new CppVariant);
WebBindings::toNPVariant(data_obj, frame->windowObject(), data_val_.get());
@@ -195,7 +200,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");
}

Powered by Google App Engine
This is Rietveld 408576698