1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Copyright (c) 2014 Samsung Electronics. All rights reserved.
3 // Use of this source code is governed by a license that can be
4 // found in the LICENSE file.
6 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_EFL_H_
7 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_EFL_H_
9 #include <Elementary.h>
11 #include "base/files/file_path.h"
12 #include "base/strings/string16.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "third_party/WebKit/public/platform/WebDragOperation.h"
15 #include "ui/gfx/geometry/point.h"
16 #include "ui/gfx/geometry/vector2d.h"
22 class WebContentsImpl;
26 // WebDragSourceEfl takes care of managing the drag from a WebContents
28 class WebDragSourceEfl {
30 explicit WebDragSourceEfl(WebContents* web_contents);
31 virtual ~WebDragSourceEfl();
33 // Starts a drag for the WebContents this object was created for.
34 // Returns false if the drag could not be started.
35 bool StartDragging(const DropData& drop_data,
36 blink::WebDragOperationsMask allowed_ops,
37 const gfx::Point& root_location,
38 const SkBitmap& image,
39 const gfx::Vector2d& image_offset);
41 void Reset() { drag_started_ = false; }
42 void SetLastPoint(gfx::Point point) { last_point_ = point; }
43 void SetPageScaleFactor(float scale) { page_scale_factor_ = scale; }
44 bool IsDragging() { return drag_started_; }
47 Evas_Object* DragIconCreate(Evas_Object* win, Evas_Coord* xoff, Evas_Coord* yoff) const;
48 void DragPos(Evas_Coord x, Evas_Coord y, Elm_Xdnd_Action action);
52 Evas_Object* parent_view_;
54 // The tab we're manging the drag for.
55 WebContentsImpl* web_contents_;
57 // The drop data for the current drag (for drags that originate in the render
58 // view). Non-NULL iff there is a current drag.
59 std::unique_ptr<DropData> drop_data_;
61 // The image used for depicting the drag, and the offset between the cursor
62 // and the top left pixel.
64 gfx::Vector2d image_offset_;
66 // Whether the current drag has failed. Meaningless if we are not the source
67 // for a current drag.
70 // True set once drag starts. A false value indicates that there is
71 // no drag currently in progress.
74 // Last registered point from drag_pos_cb callback.
75 gfx::Point last_point_;
77 // Maks of all available drag actions linke copy, move or link
78 blink::WebDragOperationsMask drag_action_;
80 // The file mime type for a drag-out download.
81 base::string16 wide_download_mime_type_;
83 // The file name to be saved to for a drag-out download.
84 base::FilePath download_file_name_;
86 // The URL to download from for a drag-out download.
89 float device_scale_factor_;
90 float page_scale_factor_;
92 gfx::Point initial_position_;
93 gfx::Point last_pointer_pos_;
95 DISALLOW_COPY_AND_ASSIGN(WebDragSourceEfl);
98 } // namespace content
100 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_EFL_H_