OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/intents/internal_web_intents_dispatcher.h" |
| 6 |
| 7 #include "content/browser/intents/intent_injector.h" |
| 8 #include "webkit/glue/web_intent_data.h" |
| 9 #include "webkit/glue/web_intent_reply_data.h" |
| 10 |
| 11 using content::WebContents; |
| 12 |
| 13 InternalWebIntentsDispatcher::InternalWebIntentsDispatcher( |
| 14 const webkit_glue::WebIntentData& intent) |
| 15 : intent_(intent), |
| 16 intent_injector_(NULL) {} |
| 17 |
| 18 InternalWebIntentsDispatcher::~InternalWebIntentsDispatcher() {} |
| 19 |
| 20 const webkit_glue::WebIntentData& InternalWebIntentsDispatcher::GetIntent() { |
| 21 return intent_; |
| 22 } |
| 23 |
| 24 void InternalWebIntentsDispatcher::DispatchIntent( |
| 25 WebContents* destination_tab) { |
| 26 DCHECK(!intent_injector_); |
| 27 intent_injector_ = new IntentInjector(destination_tab); |
| 28 intent_injector_->SetIntent(this, intent_); |
| 29 } |
| 30 |
| 31 void InternalWebIntentsDispatcher::SendReplyMessage( |
| 32 webkit_glue::WebIntentReplyType reply_type, |
| 33 const string16& data) { |
| 34 intent_injector_ = NULL; |
| 35 |
| 36 for (size_t i = 0; i < reply_notifiers_.size(); ++i) { |
| 37 if (!reply_notifiers_[i].is_null()) |
| 38 reply_notifiers_[i].Run(reply_type); |
| 39 } |
| 40 |
| 41 // TODO(gbillock): notify a delegate of the reply. |
| 42 |
| 43 delete this; |
| 44 } |
| 45 |
| 46 void InternalWebIntentsDispatcher::RegisterReplyNotification( |
| 47 const base::Callback<void(webkit_glue::WebIntentReplyType)>& closure) { |
| 48 reply_notifiers_.push_back(closure); |
| 49 } |
OLD | NEW |