blob: a6a2c28945024c96885fdeda1c21ab160b2394c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (c) 2012 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/web_intents_dispatcher_impl.h"
#include "content/browser/intents/intent_injector.h"
#include "content/browser/intents/internal_web_intents_dispatcher.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/intents_messages.h"
#include "webkit/glue/web_intent_data.h"
#include "webkit/glue/web_intent_reply_data.h"
namespace content {
WebIntentsDispatcher* WebIntentsDispatcher::Create(
const webkit_glue::WebIntentData& data) {
return new InternalWebIntentsDispatcher(data);
}
WebIntentsDispatcherImpl::WebIntentsDispatcherImpl(
WebContents* source_contents,
const webkit_glue::WebIntentData& intent,
int intent_id)
: WebContentsObserver(source_contents),
intent_(intent),
intent_id_(intent_id),
intent_injector_(NULL) {
// Ensure that WebIntentData sent from a renderer process
// carries the right payload type and no extraneous data.
intent_.blob_file = FilePath();
intent_.blob_length = 0;
intent_.root_name = "";
intent_.filesystem_id = "";
intent_.data_type = webkit_glue::WebIntentData::SERIALIZED;
}
WebIntentsDispatcherImpl::~WebIntentsDispatcherImpl() {}
const webkit_glue::WebIntentData& WebIntentsDispatcherImpl::GetIntent() {
return intent_;
}
void WebIntentsDispatcherImpl::DispatchIntent(
WebContents* destination_contents) {
DCHECK(!intent_injector_);
intent_injector_ = new IntentInjector(destination_contents);
intent_injector_->SetIntent(this, intent_);
}
void WebIntentsDispatcherImpl::ResetDispatch() {
if (intent_injector_) {
intent_injector_->Abandon();
intent_injector_ = NULL;
}
}
void WebIntentsDispatcherImpl::SendReplyMessage(
webkit_glue::WebIntentReplyType reply_type,
const string16& data) {
SendReply(webkit_glue::WebIntentReply(reply_type, data));
}
void WebIntentsDispatcherImpl::SendReply(
const webkit_glue::WebIntentReply& reply) {
intent_injector_ = NULL;
// If this intent is attached to a WebContents, we dispatch the request back
// to the renderer. Browser process initiated intents are not
// associated with a WebContents.
if (web_contents()) {
Send(new IntentsMsg_WebIntentReply(
routing_id(), reply, intent_id_));
}
for (size_t i = 0; i < reply_notifiers_.size(); ++i) {
if (!reply_notifiers_[i].is_null())
reply_notifiers_[i].Run(reply.type);
}
delete this;
}
void WebIntentsDispatcherImpl::RegisterReplyNotification(
const WebIntentsDispatcher::ReplyNotification& closure) {
reply_notifiers_.push_back(closure);
}
void WebIntentsDispatcherImpl::WebContentsDestroyed(WebContents* contents) {
if (intent_injector_)
intent_injector_->SourceWebContentsDestroyed(contents);
intent_injector_ = NULL;
}
} // namespace content
|