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

Unified Diff: content/browser/intents/internal_web_intents_dispatcher.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/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..baac4a8b70c235aa1694702051e728626b0a9a60
--- /dev/null
+++ b/content/browser/intents/internal_web_intents_dispatcher.cc
@@ -0,0 +1,59 @@
+// 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& intent,
+ base::Callback<void(webkit_glue::WebIntentReplyType,
+ const string16&)> reply_callback)
+ : intent_(intent),
+ intent_injector_(NULL),
+ reply_callback_(reply_callback) {}
+
+InternalWebIntentsDispatcher::~InternalWebIntentsDispatcher() {}
+
+const webkit_glue::WebIntentData& InternalWebIntentsDispatcher::GetIntent() {
+ return intent_;
+}
+
+void InternalWebIntentsDispatcher::DispatchIntent(
+ WebContents* destination_tab) {
James Hawkins 2012/03/12 23:19:11 WebIntentsDispatcher doesn't document this, but mu
Greg Billock 2012/03/12 23:52:22 Done.
+ 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);
+ }
+
+ // Notify the callback of the reply.
+ if (!reply_callback_.is_null())
+ reply_callback_.Run(reply_type, data);
+
+ delete this;
James Hawkins 2012/03/12 23:19:11 What happens if SendReplyMessage is never called?
Greg Billock 2012/03/12 23:52:22 The dispatcher lasts as long as the intent is acti
+}
+
+void InternalWebIntentsDispatcher::RegisterReplyNotification(
+ const base::Callback<void(webkit_glue::WebIntentReplyType)>& closure) {
+ reply_notifiers_.push_back(closure);
+}

Powered by Google App Engine
This is Rietveld 408576698