Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_intents_dispatcher_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/browser/intents/internal_web_intents_dispatcher.h" | 8 #include "content/browser/intents/internal_web_intents_dispatcher.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/common/intents_messages.h" | 10 #include "content/common/intents_messages.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 return intent_; | 38 return intent_; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void WebIntentsDispatcherImpl::DispatchIntent( | 41 void WebIntentsDispatcherImpl::DispatchIntent( |
| 42 WebContents* destination_contents) { | 42 WebContents* destination_contents) { |
| 43 DCHECK(!intent_injector_); | 43 DCHECK(!intent_injector_); |
| 44 intent_injector_ = new IntentInjector(destination_contents); | 44 intent_injector_ = new IntentInjector(destination_contents); |
| 45 intent_injector_->SetIntent(this, intent_); | 45 intent_injector_->SetIntent(this, intent_); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void WebIntentsDispatcherImpl::CancelDispatch() { | |
| 49 if (intent_injector_) { | |
| 50 intent_injector_->Abandon(); | |
|
Greg Billock
2012/04/25 14:26:52
An alternate way to do this is to clear reply_noti
groby-ooo-7-16
2012/04/25 16:40:10
The re-registering would happen in all sorts of di
| |
| 51 intent_injector_ = NULL; | |
| 52 } | |
| 53 } | |
| 54 | |
| 48 void WebIntentsDispatcherImpl::SendReplyMessage( | 55 void WebIntentsDispatcherImpl::SendReplyMessage( |
| 49 webkit_glue::WebIntentReplyType reply_type, | 56 webkit_glue::WebIntentReplyType reply_type, |
| 50 const string16& data) { | 57 const string16& data) { |
| 51 intent_injector_ = NULL; | 58 intent_injector_ = NULL; |
| 52 | 59 |
| 53 if (web_contents()) { | 60 if (web_contents()) { |
| 54 Send(new IntentsMsg_WebIntentReply( | 61 Send(new IntentsMsg_WebIntentReply( |
| 55 routing_id(), reply_type, data, intent_id_)); | 62 routing_id(), reply_type, data, intent_id_)); |
| 56 } | 63 } |
| 57 | 64 |
| 58 for (size_t i = 0; i < reply_notifiers_.size(); ++i) { | 65 for (size_t i = 0; i < reply_notifiers_.size(); ++i) { |
| 59 if (!reply_notifiers_[i].is_null()) | 66 if (!reply_notifiers_[i].is_null()) |
| 60 reply_notifiers_[i].Run(reply_type); | 67 reply_notifiers_[i].Run(reply_type); |
| 61 } | 68 } |
| 62 | 69 |
| 63 delete this; | 70 delete this; |
| 64 } | 71 } |
| 65 | 72 |
| 66 void WebIntentsDispatcherImpl::RegisterReplyNotification( | 73 void WebIntentsDispatcherImpl::RegisterReplyNotification( |
| 67 const content::WebIntentsDispatcher::ReplyNotification& closure) { | 74 const content::WebIntentsDispatcher::ReplyNotification& closure) { |
| 68 reply_notifiers_.push_back(closure); | 75 reply_notifiers_.push_back(closure); |
| 69 } | 76 } |
| 70 | 77 |
| 71 void WebIntentsDispatcherImpl::WebContentsDestroyed(WebContents* contents) { | 78 void WebIntentsDispatcherImpl::WebContentsDestroyed(WebContents* contents) { |
| 72 if (intent_injector_) | 79 if (intent_injector_) |
| 73 intent_injector_->SourceWebContentsDestroyed(contents); | 80 intent_injector_->SourceWebContentsDestroyed(contents); |
| 74 | 81 |
| 75 intent_injector_ = NULL; | 82 intent_injector_ = NULL; |
| 76 } | 83 } |
| OLD | NEW |