5f9d738b6919a1e11dd8f4e6485af99813ec7b1f
[platform/framework/web/crosswalk-tizen.git] /
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.
5
6 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_EFL_H_
7 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_EFL_H_
8
9 #include <Elementary.h>
10
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"
17 #include "url/gurl.h"
18
19 namespace content {
20
21 class WebContents;
22 class WebContentsImpl;
23
24 struct DropData;
25
26 // WebDragSourceEfl takes care of managing the drag from a WebContents
27 // with Efl.
28 class WebDragSourceEfl {
29  public:
30   explicit WebDragSourceEfl(WebContents* web_contents);
31   virtual ~WebDragSourceEfl();
32
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);
40
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_; }
45
46   // EFL callbacks
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);
49   void DragState();
50
51  private:
52   Evas_Object* parent_view_;
53
54   // The tab we're manging the drag for.
55   WebContentsImpl* web_contents_;
56
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_;
60
61   // The image used for depicting the drag, and the offset between the cursor
62   // and the top left pixel.
63   SkBitmap image_;
64   gfx::Vector2d image_offset_;
65
66   // Whether the current drag has failed. Meaningless if we are not the source
67   // for a current drag.
68   bool drag_failed_;
69
70   // True set once drag starts.  A false value indicates that there is
71   // no drag currently in progress.
72   bool drag_started_;
73
74   // Last registered point from drag_pos_cb callback.
75   gfx::Point last_point_;
76
77   // Maks of all available drag actions linke copy, move or link
78   blink::WebDragOperationsMask drag_action_;
79
80   // The file mime type for a drag-out download.
81   base::string16 wide_download_mime_type_;
82
83   // The file name to be saved to for a drag-out download.
84   base::FilePath download_file_name_;
85
86   // The URL to download from for a drag-out download.
87   GURL download_url_;
88
89   float device_scale_factor_;
90   float page_scale_factor_;
91
92   gfx::Point initial_position_;
93   gfx::Point last_pointer_pos_;
94
95   DISALLOW_COPY_AND_ASSIGN(WebDragSourceEfl);
96 };
97
98 }  // namespace content
99
100 #endif  // CONTENT_BROWSER_WEB_CONTENTS_WEB_DRAG_SOURCE_EFL_H_