Chromium Code Reviews| Index: content/browser/intents/intents_host_impl.cc |
| diff --git a/content/browser/intents/intents_host_impl.cc b/content/browser/intents/intents_host_impl.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3dc475cef3abfb799b2e0107897b61d303414d27 |
| --- /dev/null |
| +++ b/content/browser/intents/intents_host_impl.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/intents/intents_host_impl.h" |
| + |
| +#include "content/browser/intents/intent_injector.h" |
| +#include "content/common/intents_messages.h" |
| +#include "webkit/glue/web_intent_data.h" |
| +#include "webkit/glue/web_intent_reply_data.h" |
| + |
| +IntentsHostImpl::IntentsHostImpl(TabContents* source_tab, |
| + const webkit_glue::WebIntentData& intent, |
| + int intent_id) |
| + : TabContentsObserver(source_tab), |
| + source_tab_(source_tab), |
| + intent_(intent), |
| + intent_id_(intent_id), |
| + intent_injector_(NULL) {} |
| + |
| +IntentsHostImpl::~IntentsHostImpl() {} |
| + |
| +const webkit_glue::WebIntentData& IntentsHostImpl::GetIntent() { |
| + return intent_; |
| +} |
| + |
| +void IntentsHostImpl::DispatchIntent(TabContents* tab_contents) { |
| + DCHECK(intent_injector_ == NULL); |
| + intent_injector_ = new IntentInjector(tab_contents); |
| + intent_injector_->SetIntent(this, intent_, intent_id_); |
| +} |
| + |
| +void IntentsHostImpl::SendReplyMessage( |
| + webkit_glue::WebIntentReplyType reply_type, |
| + const string16& data) { |
| + intent_injector_ = NULL; |
| + |
| + if (!source_tab_) |
| + return; |
| + |
| + Send(new IntentsMsg_WebIntentReply(0, reply_type, data, intent_id_)); |
| + if (!reply_notifier_.is_null()) |
| + reply_notifier_.Run(); |
| +} |
| + |
| +void IntentsHostImpl::RegisterReplyNotification(const base::Closure& closure) { |
| + reply_notifier_ = closure; |
| +} |
| + |
| +void IntentsHostImpl::TabContentsDestroyed(TabContents* tab) { |
| + source_tab_ = NULL; |
| + |
| + if (intent_injector_) |
| + 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
|
| + |
| + intent_injector_ = NULL; |
| +} |