1 // Copyright 2020 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_BASE_DATA_TRANSFER_POLICY_DATA_TRANSFER_POLICY_CONTROLLER_H_ 6 #define UI_BASE_DATA_TRANSFER_POLICY_DATA_TRANSFER_POLICY_CONTROLLER_H_ 7 8 #include "base/component_export.h" 9 #include "ui/base/data_transfer_policy/data_transfer_endpoint.h" 10 11 namespace ui { 12 13 // The DataTransfer filter controls transferring data via drag-and-drop and 14 // clipboard read operations. It allows/disallows transferring the data given 15 // the source of the data and the destination trying to access the data and a 16 // set of rules controlling these source and destination. COMPONENT_EXPORT(UI_BASE_DATA_TRANSFER_POLICY)17class COMPONENT_EXPORT(UI_BASE_DATA_TRANSFER_POLICY) 18 DataTransferPolicyController { 19 public: 20 // Returns a pointer to the existing instance of the class. 21 static DataTransferPolicyController* Get(); 22 23 // Returns true if an instance exists, without forcing an initialization. 24 static bool HasInstance(); 25 26 // Deletes the existing instance of the class if it's already created. 27 // Indicates that restricting data transfer is no longer required. 28 static void DeleteInstance(); 29 30 virtual bool IsDataReadAllowed( 31 const DataTransferEndpoint* const data_src, 32 const DataTransferEndpoint* const data_dst) const = 0; 33 34 protected: 35 DataTransferPolicyController(); 36 virtual ~DataTransferPolicyController(); 37 38 private: 39 // A singleton of DataTransferPolicyController. Equals nullptr when there's 40 // not any data transfer restrictions required. 41 static DataTransferPolicyController* g_data_transfer_policy_controller_; 42 }; 43 44 } // namespace ui 45 46 #endif // UI_BASE_DATA_TRANSFER_POLICY_DATA_TRANSFER_POLICY_CONTROLLER_H_ 47