| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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/intents_host_impl.h" | |
| 6 | |
| 7 #include "content/browser/intents/intent_injector.h" | |
| 8 #include "content/common/intents_messages.h" | |
| 9 #include "webkit/glue/web_intent_data.h" | |
| 10 #include "webkit/glue/web_intent_reply_data.h" | |
| 11 | |
| 12 IntentsHostImpl::IntentsHostImpl(TabContents* source_tab, | |
| 13 const webkit_glue::WebIntentData& intent, | |
| 14 int intent_id) | |
| 15 : TabContentsObserver(source_tab), | |
| 16 intent_(intent), | |
| 17 intent_id_(intent_id), | |
| 18 intent_injector_(NULL) {} | |
| 19 | |
| 20 IntentsHostImpl::~IntentsHostImpl() {} | |
| 21 | |
| 22 const webkit_glue::WebIntentData& IntentsHostImpl::GetIntent() { | |
| 23 return intent_; | |
| 24 } | |
| 25 | |
| 26 void IntentsHostImpl::DispatchIntent(TabContents* destination_tab) { | |
| 27 DCHECK(!intent_injector_); | |
| 28 intent_injector_ = new IntentInjector(destination_tab); | |
| 29 intent_injector_->SetIntent(this, intent_); | |
| 30 } | |
| 31 | |
| 32 void IntentsHostImpl::SendReplyMessage( | |
| 33 webkit_glue::WebIntentReplyType reply_type, | |
| 34 const string16& data) { | |
| 35 intent_injector_ = NULL; | |
| 36 | |
| 37 if (!tab_contents()) | |
| 38 return; | |
| 39 | |
| 40 Send(new IntentsMsg_WebIntentReply( | |
| 41 routing_id(), reply_type, data, intent_id_)); | |
| 42 if (!reply_notifier_.is_null()) | |
| 43 reply_notifier_.Run(); | |
| 44 } | |
| 45 | |
| 46 void IntentsHostImpl::RegisterReplyNotification(const base::Closure& closure) { | |
| 47 reply_notifier_ = closure; | |
| 48 } | |
| 49 | |
| 50 void IntentsHostImpl::TabContentsDestroyed(TabContents* tab) { | |
| 51 if (intent_injector_) | |
| 52 intent_injector_->SourceTabContentsDestroyed(tab); | |
| 53 | |
| 54 intent_injector_ = NULL; | |
| 55 } | |
| OLD | NEW |