summaryrefslogtreecommitdiffstats
path: root/webkit/glue/web_intent_data.cc
blob: 9df14228ab303a7a1b7def7649c8bb1719b3359e (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
97
98
99
100
101
102
103
104
105
106
// 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 "webkit/glue/web_intent_data.h"

#include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMessagePortChannel.h"

using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebVector;

namespace webkit_glue {

WebIntentData::WebIntentData()
    : blob_length(0),
      data_type(SERIALIZED) {
}

WebIntentData::~WebIntentData() {
}

WebIntentData::WebIntentData(const WebKit::WebIntent& intent)
    : action(intent.action()),
      type(intent.type()),
      data(intent.data()),
      service(intent.service()),
      blob_length(0),
      data_type(SERIALIZED) {
  const WebVector<WebString>& names = intent.extrasNames();
  for (size_t i = 0; i < names.size(); ++i) {
    extra_data[names[i]] = intent.extrasValue(names[i]);
  }

  const WebVector<WebURL>& clientSuggestions = intent.suggestions();
  for (size_t i = 0; i < clientSuggestions.size(); ++i)
    suggestions.push_back(clientSuggestions[i]);
}

WebIntentData::WebIntentData(const string16& action_in,
                             const string16& type_in)
    : action(action_in),
      type(type_in),
      blob_length(0),
      data_type(MIME_TYPE) {
}

WebIntentData::WebIntentData(const string16& action_in,
                             const string16& type_in,
                             const string16& unserialized_data_in)
    : action(action_in),
      type(type_in),
      unserialized_data(unserialized_data_in),
      blob_length(0),
      data_type(UNSERIALIZED) {
}

WebIntentData::WebIntentData(const string16& action_in,
                             const string16& type_in,
                             const base::FilePath& blob_file_in,
                             int64 blob_length_in)
    : action(action_in),
      type(type_in),
      blob_file(blob_file_in),
      blob_length(blob_length_in),
      data_type(BLOB) {
}

WebIntentData::WebIntentData(const string16& action_in,
                             const string16& type_in,
                             const std::string& root_name_in,
                             const std::string& filesystem_id_in)
    : action(action_in),
      type(type_in),
      blob_length(0),
      root_name(root_name_in),
      filesystem_id(filesystem_id_in),
      data_type(FILESYSTEM) {
}

WebIntentData::WebIntentData(const WebIntentData& intent_data)
    : action(intent_data.action),
      type(intent_data.type),
      data(intent_data.data),
      extra_data(intent_data.extra_data),
      service(intent_data.service),
      suggestions(intent_data.suggestions),
      unserialized_data(intent_data.unserialized_data),
      message_port_ids(intent_data.message_port_ids),
      blob_file(intent_data.blob_file),
      blob_length(intent_data.blob_length),
      root_name(intent_data.root_name),
      filesystem_id(intent_data.filesystem_id),
      data_type(intent_data.data_type) {
  for (size_t i = 0; i < intent_data.mime_data.GetSize(); ++i) {
    const DictionaryValue* dict = NULL;
    if (!intent_data.mime_data.GetDictionary(i, &dict)) continue;
    mime_data.Append(dict->DeepCopy());
  }
}

}  // namespace webkit_glue