OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
12 #if defined(TOOLKIT_VIEWS) | 12 #if defined(TOOLKIT_VIEWS) |
13 #include "ui/base/dragdrop/os_exchange_data.h" | 13 #include "ui/base/dragdrop/os_exchange_data.h" |
14 #endif | 14 #endif |
15 | 15 |
16 class Pickle; | 16 class Pickle; |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 class BrowserActionDragData { | 19 class BrowserActionDragData { |
20 public: | 20 public: |
21 BrowserActionDragData(); | 21 BrowserActionDragData(); |
22 BrowserActionDragData(const std::string& id, int index); | 22 BrowserActionDragData(const std::string& id, int index); |
23 | 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 |
24 const std::string& id() const { return id_; } | 32 const std::string& id() const { return id_; } |
25 | 33 |
26 size_t index() const { return index_; } | 34 size_t index() const { return index_; } |
27 | 35 |
28 // Returns true if this data is from the specified profile. | 36 // Returns true if this data is from the specified profile. |
29 bool IsFromProfile(Profile* profile) const; | 37 bool IsFromProfile(const Profile* profile) const; |
30 | 38 |
31 #if defined(TOOLKIT_VIEWS) | 39 #if defined(TOOLKIT_VIEWS) |
32 void Write(Profile* profile, ui::OSExchangeData* data) const; | 40 void Write(Profile* profile, ui::OSExchangeData* data) const; |
33 | 41 |
34 // Restores this data from the clipboard, returning true on success. | 42 // Restores this data from the clipboard, returning true on success. |
35 bool Read(const ui::OSExchangeData& data); | 43 bool Read(const ui::OSExchangeData& data); |
36 | 44 |
37 // Returns the Custom Format this class supports (for Browser Actions). | 45 // Returns the Custom Format this class supports (for Browser Actions). |
38 static const ui::OSExchangeData::CustomFormat& GetBrowserActionCustomFormat(); | 46 static const ui::OSExchangeData::CustomFormat& GetBrowserActionCustomFormat(); |
39 #endif | 47 #endif |
40 | 48 |
41 private: | 49 private: |
42 void WriteToPickle(Profile* profile, Pickle* pickle) const; | 50 void WriteToPickle(Profile* profile, Pickle* pickle) const; |
43 bool ReadFromPickle(Pickle* pickle); | 51 bool ReadFromPickle(Pickle* pickle); |
44 | 52 |
45 // The profile we originated from. | 53 // The profile we originated from. |
46 void* profile_; | 54 void* profile_; |
47 | 55 |
48 // The id of the view being dragged. | 56 // The id of the view being dragged. |
49 std::string id_; | 57 std::string id_; |
50 | 58 |
51 // The index of the view being dragged. | 59 // The index of the view being dragged. |
52 size_t index_; | 60 size_t index_; |
53 | 61 |
54 // The MIME type for the clipboard format for BrowserActionDragData. | |
55 static const char* kClipboardFormatString; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(BrowserActionDragData); | 62 DISALLOW_COPY_AND_ASSIGN(BrowserActionDragData); |
58 }; | 63 }; |
59 | 64 |
60 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_ | 65 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_DRAG_DATA_H_ |
OLD | NEW |