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..1491b720981f5169c3c228cdf557f5cb097a22e3 100644 |
--- a/content/renderer/web_intents_host.cc |
+++ b/content/renderer/web_intents_host.cc |
@@ -6,14 +6,16 @@ |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
+#include "base/stl_util.h" |
#include "content/common/intents_messages.h" |
#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 +130,21 @@ 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() { |
+ STLDeleteContainerPairSecondPointers(intent_requests_.begin(), |
+ intent_requests_.end()); |
+} |
+ |
+int WebIntentsHost::RegisterWebIntent( |
+ 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 +164,17 @@ 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); |
if (reply_type == webkit_glue::WEB_INTENT_REPLY_SUCCESS) { |
- render_view()->GetWebView()->mainFrame()->handleIntentResult( |
- intent_id, data); |
+ intent_request->postResult(data); |
} else { |
- render_view()->GetWebView()->mainFrame()->handleIntentFailure( |
- intent_id, data); |
+ intent_request->postFailure(data); |
} |
} |