1// Copyright (c) 2011 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 CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_ 6#define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_ 7 8#include <string> 9 10#include "base/basictypes.h" 11 12#if defined(TOOLKIT_VIEWS) 13#include "ui/base/dragdrop/os_exchange_data.h" 14#endif 15 16class Pickle; 17class Profile; 18 19class BrowserActionDragData { 20 public: 21 BrowserActionDragData(); 22 BrowserActionDragData(const std::string& id, int index); 23 24 // These mirror the views::View and views::MenuDelegate methods for dropping, 25 // and return the appropriate results for being able to drop an extension's 26 // BrowserAction view. 27 static bool GetDropFormats( 28 std::set<ui::OSExchangeData::CustomFormat>* custom_formats); 29 static bool AreDropTypesRequired(); 30 static bool CanDrop(const ui::OSExchangeData& data, const Profile* profile); 31 32 const std::string& id() const { return id_; } 33 34 size_t index() const { return index_; } 35 36 // Returns true if this data is from the specified profile. 37 bool IsFromProfile(const Profile* profile) const; 38 39#if defined(TOOLKIT_VIEWS) 40 void Write(Profile* profile, ui::OSExchangeData* data) const; 41 42 // Restores this data from the clipboard, returning true on success. 43 bool Read(const ui::OSExchangeData& data); 44 45 // Returns the Custom Format this class supports (for Browser Actions). 46 static const ui::OSExchangeData::CustomFormat& GetBrowserActionCustomFormat(); 47#endif 48 49 private: 50 void WriteToPickle(Profile* profile, Pickle* pickle) const; 51 bool ReadFromPickle(Pickle* pickle); 52 53 // The profile we originated from. 54 void* profile_; 55 56 // The id of the view being dragged. 57 std::string id_; 58 59 // The index of the view being dragged. 60 size_t index_; 61 62 DISALLOW_COPY_AND_ASSIGN(BrowserActionDragData); 63}; 64 65#endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_ 66