1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
4eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
5eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// A struct for managing data being dropped on a WebContents.  This represents
6eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch// a union of all the types of data that can be dropped in a platform neutral
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// way.
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#ifndef CONTENT_PUBLIC_COMMON_DROP_DATA_H_
10eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#define CONTENT_PUBLIC_COMMON_DROP_DATA_H_
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <map>
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <string>
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
167d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/strings/nullable_string16.h"
17eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "content/common/content_export.h"
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
19effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "ui/base/dragdrop/file_info.h"
20eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "url/gurl.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
22eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochnamespace content {
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
24eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochstruct CONTENT_EXPORT DropData {
250529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  struct FileSystemFileInfo {
260529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    FileSystemFileInfo() : size(0) {}
270529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    ~FileSystemFileInfo() {}
280529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
290529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    GURL url;
300529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch    int64 size;
310529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  };
320529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
33eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  DropData();
34eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  ~DropData();
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
36effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // Whether this drag originated from a renderer.
37effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  bool did_originate_from_renderer;
38effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // User is dragging a link into the webview.
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL url;
41c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  base::string16 url_title;  // The title associated with |url|.
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // User is dragging a link out-of the webview.
44c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  base::string16 download_metadata;
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Referrer policy to use when dragging a link out of the webview results in
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // a download.
48f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  blink::WebReferrerPolicy referrer_policy;
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
50effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // User is dropping one or more files on the webview. This field is only
51effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // populated if the drag is not renderer tainted, as this allows File access
52effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  // from web content.
53effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch  std::vector<ui::FileInfo> filenames;
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Isolated filesystem ID for the files being dragged on the webview.
56c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  base::string16 filesystem_id;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
580529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  // User is dragging files specified with filesystem: URLs.
590529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  std::vector<FileSystemFileInfo> file_system_files;
600529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // User is dragging plain text into the webview.
627d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  base::NullableString16 text;
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // User is dragging text/html into the webview (e.g., out of Firefox).
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |html_base_url| is the URL that the html fragment is taken from (used to
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // resolve relative links).  It's ok for |html_base_url| to be empty.
677d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  base::NullableString16 html;
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL html_base_url;
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // User is dragging data from the webview (e.g., an image).
71c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  base::string16 file_description_filename;
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string file_contents;
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
74c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  std::map<base::string16, base::string16> custom_data;
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
77eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch}  // namespace content
78eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
79eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#endif  // CONTENT_PUBLIC_COMMON_DROP_DATA_H_
80