Index: content/renderer/web_intents_host.cc |
diff --git a/content/renderer/web_intents_host.cc b/content/renderer/web_intents_host.cc |
index 7d96f3d93f81e216c5a585af1757404ca9a8e345..2329e3350a0b9fc13fb527d782845bd93640e0ed 100644 |
--- a/content/renderer/web_intents_host.cc |
+++ b/content/renderer/web_intents_host.cc |
@@ -10,10 +10,11 @@ |
#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/platform/WebCString.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerializedScriptValue.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerializedScriptValue.h" |
#include "v8/include/v8.h" |
#include "webkit/glue/cpp_bound_class.h" |
@@ -128,10 +129,19 @@ class WebIntentsHost::BoundDeliveredIntent : public CppBoundClass { |
}; |
WebIntentsHost::WebIntentsHost(RenderViewImpl* render_view) |
- : content::RenderViewObserver(render_view) { |
+ : content::RenderViewObserver(render_view), |
+ id_counter_(0) { |
} |
-WebIntentsHost::~WebIntentsHost() {} |
+WebIntentsHost::~WebIntentsHost() { |
+} |
+ |
+int WebIntentsHost::RegisterWebIntent( |
+ const WebKit::WebIntentRequest& request) { |
+ int id = id_counter_++; |
+ intent_requests_[id] = request; |
+ return id; |
+} |
bool WebIntentsHost::OnMessageReceived(const IPC::Message& message) { |
bool handled = true; |
@@ -151,13 +161,19 @@ void WebIntentsHost::OnWebIntentReply( |
webkit_glue::WebIntentReplyType reply_type, |
const WebKit::WebString& data, |
int intent_id) { |
+ std::map<int, WebKit::WebIntentRequest>::iterator request = |
+ intent_requests_.find(intent_id); |
+ if (request == intent_requests_.end()) |
+ return; |
+ WebKit::WebIntentRequest intent_request = request->second; |
+ intent_requests_.erase(request); |
+ WebKit::WebSerializedScriptValue value = |
+ WebKit::WebSerializedScriptValue::fromString(data); |
if (reply_type == webkit_glue::WEB_INTENT_REPLY_SUCCESS) { |
- render_view()->GetWebView()->mainFrame()->handleIntentResult( |
- intent_id, data); |
+ intent_request.postResult(value); |
} else { |
- render_view()->GetWebView()->mainFrame()->handleIntentFailure( |
- intent_id, data); |
+ intent_request.postFailure(value); |
} |
} |