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* tab_contents) { |
| 27 DCHECK(!intent_injector_); |
| 28 intent_injector_ = new IntentInjector(tab_contents); |
| 29 intent_injector_->SetIntent(this, intent_, intent_id_); |
| 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(0, reply_type, data, intent_id_)); |
| 41 if (!reply_notifier_.is_null()) |
| 42 reply_notifier_.Run(); |
| 43 } |
| 44 |
| 45 void IntentsHostImpl::RegisterReplyNotification(const base::Closure& closure) { |
| 46 reply_notifier_ = closure; |
| 47 } |
| 48 |
| 49 void IntentsHostImpl::TabContentsDestroyed(TabContents* tab) { |
| 50 if (intent_injector_) |
| 51 intent_injector_->SourceTabContentsDestroyed(tab); |
| 52 |
| 53 intent_injector_ = NULL; |
| 54 } |
OLD | NEW |