summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webdropdata.h
blob: 0f36d998f1e95e4b94d2e6c188065b70d178ef8b (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
// 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.
//
// A struct for managing data being dropped on a webview.  This represents a
// union of all the types of data that can be dropped in a platform neutral
// way.

#ifndef WEBKIT_GLUE_WEBDROPDATA_H_
#define WEBKIT_GLUE_WEBDROPDATA_H_

#include <map>
#include <string>
#include <vector>

#include "base/nullable_string16.h"
#include "base/string16.h"
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebReferrerPolicy.h"
#include "webkit/glue/webkit_glue_export.h"

struct IDataObject;

namespace WebKit {
class WebDragData;
}

struct WEBKIT_GLUE_EXPORT WebDropData {
  // The struct is used to represent a file in the drop data.
  struct WEBKIT_GLUE_EXPORT FileInfo {
    FileInfo();
    FileInfo(const string16& path, const string16& display_name);

    // The path of the file.
    string16 path;
    // The display name of the file. This field is optional.
    string16 display_name;
  };

  // Construct from a WebDragData object.
  explicit WebDropData(const WebKit::WebDragData&);

  WebDropData();

  ~WebDropData();

  // User is dragging a link into the webview.
  GURL url;
  string16 url_title;  // The title associated with |url|.

  // User is dragging a link out-of the webview.
  string16 download_metadata;

  // Referrer policy to use when dragging a link out of the webview results in
  // a download.
  WebKit::WebReferrerPolicy referrer_policy;

  // User is dropping one or more files on the webview.
  std::vector<FileInfo> filenames;

  // Isolated filesystem ID for the files being dragged on the webview.
  string16 filesystem_id;

  // User is dragging plain text into the webview.
  NullableString16 text;

  // User is dragging text/html into the webview (e.g., out of Firefox).
  // |html_base_url| is the URL that the html fragment is taken from (used to
  // resolve relative links).  It's ok for |html_base_url| to be empty.
  NullableString16 html;
  GURL html_base_url;

  // User is dragging data from the webview (e.g., an image).
  string16 file_description_filename;
  std::string file_contents;

  std::map<string16, string16> custom_data;

  // Convert to a WebDragData object.
  WebKit::WebDragData ToDragData() const;

  // Helper method for converting Window's specific IDataObject to a WebDropData
  // object.  TODO(tc): Move this to the browser side since it's Windows
  // specific and no longer used in webkit.
  static void PopulateWebDropData(IDataObject* data_object,
                                  WebDropData* drop_data);
};

#endif  // WEBKIT_GLUE_WEBDROPDATA_H_