Index: content/browser/intents/internal_web_intents_dispatcher.cc |
diff --git a/content/browser/intents/internal_web_intents_dispatcher.cc b/content/browser/intents/internal_web_intents_dispatcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f01f459c048cfcfbd6e619a3c0cefe4e1ebd75b5 |
--- /dev/null |
+++ b/content/browser/intents/internal_web_intents_dispatcher.cc |
@@ -0,0 +1,49 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/intents/internal_web_intents_dispatcher.h" |
+ |
+#include "content/browser/intents/intent_injector.h" |
+#include "webkit/glue/web_intent_data.h" |
+#include "webkit/glue/web_intent_reply_data.h" |
+ |
+using content::WebContents; |
+ |
+InternalWebIntentsDispatcher::InternalWebIntentsDispatcher( |
+ const webkit_glue::WebIntentData& intent) |
+ : intent_(intent), |
+ intent_injector_(NULL) {} |
+ |
+InternalWebIntentsDispatcher::~InternalWebIntentsDispatcher() {} |
+ |
+const webkit_glue::WebIntentData& InternalWebIntentsDispatcher::GetIntent() { |
+ return intent_; |
+} |
+ |
+void InternalWebIntentsDispatcher::DispatchIntent( |
+ WebContents* destination_tab) { |
+ DCHECK(!intent_injector_); |
+ intent_injector_ = new IntentInjector(destination_tab); |
+ intent_injector_->SetIntent(this, intent_); |
+} |
+ |
+void InternalWebIntentsDispatcher::SendReplyMessage( |
+ webkit_glue::WebIntentReplyType reply_type, |
+ const string16& data) { |
+ intent_injector_ = NULL; |
+ |
+ for (size_t i = 0; i < reply_notifiers_.size(); ++i) { |
+ if (!reply_notifiers_[i].is_null()) |
+ reply_notifiers_[i].Run(reply_type); |
+ } |
+ |
+ // TODO(gbillock): notify a delegate of the reply. |
+ |
+ delete this; |
+} |
+ |
+void InternalWebIntentsDispatcher::RegisterReplyNotification( |
+ const base::Callback<void(webkit_glue::WebIntentReplyType)>& closure) { |
+ reply_notifiers_.push_back(closure); |
+} |