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