Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1044)

Side by Side Diff: content/browser/intents/internal_web_intents_dispatcher.cc

Issue 9692017: An internal intents dispatcher useful for initiating an intent from the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/intents/internal_web_intents_dispatcher.h"
6
7 #include "content/browser/intents/intent_injector.h"
8 #include "webkit/glue/web_intent_data.h"
9 #include "webkit/glue/web_intent_reply_data.h"
10
11 using content::WebContents;
12
13 InternalWebIntentsDispatcher::InternalWebIntentsDispatcher(
14 const webkit_glue::WebIntentData& intent)
15 : intent_(intent),
16 intent_injector_(NULL) {}
17
18 InternalWebIntentsDispatcher::InternalWebIntentsDispatcher(
19 const webkit_glue::WebIntentData& intent,
20 base::Callback<void(webkit_glue::WebIntentReplyType,
21 const string16&)> reply_callback)
22 : intent_(intent),
23 intent_injector_(NULL),
24 reply_callback_(reply_callback) {}
25
26 InternalWebIntentsDispatcher::~InternalWebIntentsDispatcher() {}
27
28 const webkit_glue::WebIntentData& InternalWebIntentsDispatcher::GetIntent() {
29 return intent_;
30 }
31
32 void InternalWebIntentsDispatcher::DispatchIntent(
33 WebContents* destination_tab) {
James Hawkins 2012/03/12 23:19:11 WebIntentsDispatcher doesn't document this, but mu
Greg Billock 2012/03/12 23:52:22 Done.
34 DCHECK(!intent_injector_);
35 intent_injector_ = new IntentInjector(destination_tab);
36 intent_injector_->SetIntent(this, intent_);
37 }
38
39 void InternalWebIntentsDispatcher::SendReplyMessage(
40 webkit_glue::WebIntentReplyType reply_type,
41 const string16& data) {
42 intent_injector_ = NULL;
43
44 for (size_t i = 0; i < reply_notifiers_.size(); ++i) {
45 if (!reply_notifiers_[i].is_null())
46 reply_notifiers_[i].Run(reply_type);
47 }
48
49 // Notify the callback of the reply.
50 if (!reply_callback_.is_null())
51 reply_callback_.Run(reply_type, data);
52
53 delete this;
James Hawkins 2012/03/12 23:19:11 What happens if SendReplyMessage is never called?
Greg Billock 2012/03/12 23:52:22 The dispatcher lasts as long as the intent is acti
54 }
55
56 void InternalWebIntentsDispatcher::RegisterReplyNotification(
57 const base::Callback<void(webkit_glue::WebIntentReplyType)>& closure) {
58 reply_notifiers_.push_back(closure);
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698