Chromium Code Reviews| 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 source_tab_(source_tab), | |
| 17 intent_(intent), | |
| 18 intent_id_(intent_id), | |
| 19 intent_injector_(NULL) {} | |
| 20 | |
| 21 IntentsHostImpl::~IntentsHostImpl() {} | |
| 22 | |
| 23 const webkit_glue::WebIntentData& IntentsHostImpl::GetIntent() { | |
| 24 return intent_; | |
| 25 } | |
| 26 | |
| 27 void IntentsHostImpl::DispatchIntent(TabContents* tab_contents) { | |
| 28 DCHECK(intent_injector_ == NULL); | |
| 29 intent_injector_ = new IntentInjector(tab_contents); | |
| 30 intent_injector_->SetIntent(this, intent_, intent_id_); | |
| 31 } | |
| 32 | |
| 33 void IntentsHostImpl::SendReplyMessage( | |
| 34 webkit_glue::WebIntentReplyType reply_type, | |
| 35 const string16& data) { | |
| 36 intent_injector_ = NULL; | |
| 37 | |
| 38 if (!source_tab_) | |
| 39 return; | |
| 40 | |
| 41 Send(new IntentsMsg_WebIntentReply(0, 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 source_tab_ = NULL; | |
| 52 | |
| 53 if (intent_injector_) | |
| 54 intent_injector_->SourceTabContentsDestroyed(tab); | |
|
binji
2011/11/28 22:50:14
You might want to mention here that the intent_inj
Greg Billock
2011/11/29 00:19:55
Good catch. I'd forgotten to update the IntentInje
| |
| 55 | |
| 56 intent_injector_ = NULL; | |
| 57 } | |
| OLD | NEW |