1 // Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights 2 // reserved. Use of this source code is governed by a BSD-style license that 3 // can be found in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_COMMON_DRAG_DATA_IMPL_H_ 6 #define CEF_LIBCEF_COMMON_DRAG_DATA_IMPL_H_ 7 #pragma once 8 9 #include "include/cef_drag_data.h" 10 #include "include/cef_image.h" 11 12 #include <vector> 13 14 #include "base/synchronization/lock.h" 15 #include "content/public/common/drop_data.h" 16 17 // Implementation of CefDragData. 18 class CefDragDataImpl : public CefDragData { 19 public: 20 CefDragDataImpl(); 21 explicit CefDragDataImpl(const content::DropData& data); 22 CefDragDataImpl(const content::DropData& data, 23 CefRefPtr<CefImage> image, 24 const CefPoint& image_hotspot); 25 26 CefRefPtr<CefDragData> Clone() override; 27 bool IsReadOnly() override; 28 bool IsLink() override; 29 bool IsFragment() override; 30 bool IsFile() override; 31 CefString GetLinkURL() override; 32 CefString GetLinkTitle() override; 33 CefString GetLinkMetadata() override; 34 CefString GetFragmentText() override; 35 CefString GetFragmentHtml() override; 36 CefString GetFragmentBaseURL() override; 37 CefString GetFileName() override; 38 size_t GetFileContents(CefRefPtr<CefStreamWriter> writer) override; 39 bool GetFileNames(std::vector<CefString>& names) override; 40 void SetLinkURL(const CefString& url) override; 41 void SetLinkTitle(const CefString& title) override; 42 void SetLinkMetadata(const CefString& data) override; 43 void SetFragmentText(const CefString& text) override; 44 void SetFragmentHtml(const CefString& fragment) override; 45 void SetFragmentBaseURL(const CefString& fragment) override; 46 void ResetFileContents() override; 47 void AddFile(const CefString& path, const CefString& display_name) override; 48 CefRefPtr<CefImage> GetImage() override; 49 CefPoint GetImageHotspot() override; 50 bool HasImage() override; 51 52 // This method is not safe. Use Lock/Unlock to get mutually exclusive access. drop_data()53 content::DropData* drop_data() { return &data_; } 54 55 void SetReadOnly(bool read_only); 56 lock()57 base::Lock& lock() { return lock_; } 58 59 private: 60 content::DropData data_; 61 CefRefPtr<CefImage> image_; 62 CefPoint image_hotspot_; 63 64 // True if this object is read-only. 65 bool read_only_; 66 67 base::Lock lock_; 68 69 IMPLEMENT_REFCOUNTING(CefDragDataImpl); 70 }; 71 72 #endif // CEF_LIBCEF_COMMON_DRAG_DATA_IMPL_H_ 73