OLD | NEW |
| (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 "webkit/glue/web_intent_data.h" | |
6 | |
7 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | |
8 #include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h" | |
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" | |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h" | |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMessagePortChannel
.h" | |
12 | |
13 using WebKit::WebString; | |
14 using WebKit::WebURL; | |
15 using WebKit::WebVector; | |
16 | |
17 namespace webkit_glue { | |
18 | |
19 WebIntentData::WebIntentData() | |
20 : blob_length(0), | |
21 data_type(SERIALIZED) { | |
22 } | |
23 | |
24 WebIntentData::~WebIntentData() { | |
25 } | |
26 | |
27 WebIntentData::WebIntentData(const WebKit::WebIntent& intent) | |
28 : action(intent.action()), | |
29 type(intent.type()), | |
30 data(intent.data()), | |
31 service(intent.service()), | |
32 blob_length(0), | |
33 data_type(SERIALIZED) { | |
34 const WebVector<WebString>& names = intent.extrasNames(); | |
35 for (size_t i = 0; i < names.size(); ++i) { | |
36 extra_data[names[i]] = intent.extrasValue(names[i]); | |
37 } | |
38 | |
39 const WebVector<WebURL>& clientSuggestions = intent.suggestions(); | |
40 for (size_t i = 0; i < clientSuggestions.size(); ++i) | |
41 suggestions.push_back(clientSuggestions[i]); | |
42 } | |
43 | |
44 WebIntentData::WebIntentData(const string16& action_in, | |
45 const string16& type_in) | |
46 : action(action_in), | |
47 type(type_in), | |
48 blob_length(0), | |
49 data_type(MIME_TYPE) { | |
50 } | |
51 | |
52 WebIntentData::WebIntentData(const string16& action_in, | |
53 const string16& type_in, | |
54 const string16& unserialized_data_in) | |
55 : action(action_in), | |
56 type(type_in), | |
57 unserialized_data(unserialized_data_in), | |
58 blob_length(0), | |
59 data_type(UNSERIALIZED) { | |
60 } | |
61 | |
62 WebIntentData::WebIntentData(const string16& action_in, | |
63 const string16& type_in, | |
64 const base::FilePath& blob_file_in, | |
65 int64 blob_length_in) | |
66 : action(action_in), | |
67 type(type_in), | |
68 blob_file(blob_file_in), | |
69 blob_length(blob_length_in), | |
70 data_type(BLOB) { | |
71 } | |
72 | |
73 WebIntentData::WebIntentData(const string16& action_in, | |
74 const string16& type_in, | |
75 const std::string& root_name_in, | |
76 const std::string& filesystem_id_in) | |
77 : action(action_in), | |
78 type(type_in), | |
79 blob_length(0), | |
80 root_name(root_name_in), | |
81 filesystem_id(filesystem_id_in), | |
82 data_type(FILESYSTEM) { | |
83 } | |
84 | |
85 WebIntentData::WebIntentData(const WebIntentData& intent_data) | |
86 : action(intent_data.action), | |
87 type(intent_data.type), | |
88 data(intent_data.data), | |
89 extra_data(intent_data.extra_data), | |
90 service(intent_data.service), | |
91 suggestions(intent_data.suggestions), | |
92 unserialized_data(intent_data.unserialized_data), | |
93 message_port_ids(intent_data.message_port_ids), | |
94 blob_file(intent_data.blob_file), | |
95 blob_length(intent_data.blob_length), | |
96 root_name(intent_data.root_name), | |
97 filesystem_id(intent_data.filesystem_id), | |
98 data_type(intent_data.data_type) { | |
99 for (size_t i = 0; i < intent_data.mime_data.GetSize(); ++i) { | |
100 const DictionaryValue* dict = NULL; | |
101 if (!intent_data.mime_data.GetDictionary(i, &dict)) continue; | |
102 mime_data.Append(dict->DeepCopy()); | |
103 } | |
104 } | |
105 | |
106 } // namespace webkit_glue | |
OLD | NEW |