Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: ui/base/dragdrop/os_exchange_data_provider_chromeos.cc

Issue 14189002: linux_aura: Implement dropping in chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_chromeos.h ('k') | ui/base/x/selection_requestor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h" 5 #include "ui/base/dragdrop/os_exchange_data_provider_chromeos.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "net/base/net_util.h" 9 #include "net/base/net_util.h"
10 #include "ui/base/clipboard/clipboard.h" 10 #include "ui/base/clipboard/clipboard.h"
11 #include "ui/base/clipboard/scoped_clipboard_writer.h" 11 #include "ui/base/clipboard/scoped_clipboard_writer.h"
12 12
13 namespace ui { 13 namespace ui {
14 14
15 OSExchangeDataProviderAura::OSExchangeDataProviderAura() : formats_(0) {} 15 OSExchangeDataProviderChromeos::OSExchangeDataProviderChromeos()
16 : formats_(0) {
17 }
16 18
17 OSExchangeDataProviderAura::~OSExchangeDataProviderAura() {} 19 OSExchangeDataProviderChromeos::~OSExchangeDataProviderChromeos() {}
18 20
19 void OSExchangeDataProviderAura::SetString(const string16& data) { 21 void OSExchangeDataProviderChromeos::SetString(const string16& data) {
20 string_ = data; 22 string_ = data;
21 formats_ |= OSExchangeData::STRING; 23 formats_ |= OSExchangeData::STRING;
22 } 24 }
23 25
24 void OSExchangeDataProviderAura::SetURL(const GURL& url, 26 void OSExchangeDataProviderChromeos::SetURL(const GURL& url,
25 const string16& title) { 27 const string16& title) {
26 url_ = url; 28 url_ = url;
27 title_ = title; 29 title_ = title;
28 formats_ |= OSExchangeData::URL; 30 formats_ |= OSExchangeData::URL;
29 } 31 }
30 32
31 void OSExchangeDataProviderAura::SetFilename(const base::FilePath& path) { 33 void OSExchangeDataProviderChromeos::SetFilename(const base::FilePath& path) {
32 filenames_.clear(); 34 filenames_.clear();
33 filenames_.push_back(OSExchangeData::FileInfo(path, base::FilePath())); 35 filenames_.push_back(OSExchangeData::FileInfo(path, base::FilePath()));
34 formats_ |= OSExchangeData::FILE_NAME; 36 formats_ |= OSExchangeData::FILE_NAME;
35 } 37 }
36 38
37 void OSExchangeDataProviderAura::SetFilenames( 39 void OSExchangeDataProviderChromeos::SetFilenames(
38 const std::vector<OSExchangeData::FileInfo>& filenames) { 40 const std::vector<OSExchangeData::FileInfo>& filenames) {
39 filenames_ = filenames; 41 filenames_ = filenames;
40 formats_ |= OSExchangeData::FILE_NAME; 42 formats_ |= OSExchangeData::FILE_NAME;
41 } 43 }
42 44
43 void OSExchangeDataProviderAura::SetPickledData( 45 void OSExchangeDataProviderChromeos::SetPickledData(
44 OSExchangeData::CustomFormat format, 46 OSExchangeData::CustomFormat format,
45 const Pickle& data) { 47 const Pickle& data) {
46 pickle_data_[format] = data; 48 pickle_data_[format] = data;
47 formats_ |= OSExchangeData::PICKLED_DATA; 49 formats_ |= OSExchangeData::PICKLED_DATA;
48 } 50 }
49 51
50 bool OSExchangeDataProviderAura::GetString(string16* data) const { 52 bool OSExchangeDataProviderChromeos::GetString(string16* data) const {
51 if ((formats_ & OSExchangeData::STRING) == 0) 53 if ((formats_ & OSExchangeData::STRING) == 0)
52 return false; 54 return false;
53 *data = string_; 55 *data = string_;
54 return true; 56 return true;
55 } 57 }
56 58
57 bool OSExchangeDataProviderAura::GetURLAndTitle(GURL* url, 59 bool OSExchangeDataProviderChromeos::GetURLAndTitle(GURL* url,
58 string16* title) const { 60 string16* title) const {
59 if ((formats_ & OSExchangeData::URL) == 0) { 61 if ((formats_ & OSExchangeData::URL) == 0) {
60 title->clear(); 62 title->clear();
61 return GetPlainTextURL(url); 63 return GetPlainTextURL(url);
62 } 64 }
63 65
64 if (!url_.is_valid()) 66 if (!url_.is_valid())
65 return false; 67 return false;
66 68
67 *url = url_; 69 *url = url_;
68 *title = title_; 70 *title = title_;
69 return true; 71 return true;
70 } 72 }
71 73
72 bool OSExchangeDataProviderAura::GetFilename(base::FilePath* path) const { 74 bool OSExchangeDataProviderChromeos::GetFilename(base::FilePath* path) const {
73 if ((formats_ & OSExchangeData::FILE_NAME) == 0) 75 if ((formats_ & OSExchangeData::FILE_NAME) == 0)
74 return false; 76 return false;
75 DCHECK(!filenames_.empty()); 77 DCHECK(!filenames_.empty());
76 *path = filenames_[0].path; 78 *path = filenames_[0].path;
77 return true; 79 return true;
78 } 80 }
79 81
80 bool OSExchangeDataProviderAura::GetFilenames( 82 bool OSExchangeDataProviderChromeos::GetFilenames(
81 std::vector<OSExchangeData::FileInfo>* filenames) const { 83 std::vector<OSExchangeData::FileInfo>* filenames) const {
82 if ((formats_ & OSExchangeData::FILE_NAME) == 0) 84 if ((formats_ & OSExchangeData::FILE_NAME) == 0)
83 return false; 85 return false;
84 *filenames = filenames_; 86 *filenames = filenames_;
85 return true; 87 return true;
86 } 88 }
87 89
88 bool OSExchangeDataProviderAura::GetPickledData( 90 bool OSExchangeDataProviderChromeos::GetPickledData(
89 OSExchangeData::CustomFormat format, 91 OSExchangeData::CustomFormat format,
90 Pickle* data) const { 92 Pickle* data) const {
91 PickleData::const_iterator i = pickle_data_.find(format); 93 PickleData::const_iterator i = pickle_data_.find(format);
92 if (i == pickle_data_.end()) 94 if (i == pickle_data_.end())
93 return false; 95 return false;
94 96
95 *data = i->second; 97 *data = i->second;
96 return true; 98 return true;
97 } 99 }
98 100
99 bool OSExchangeDataProviderAura::HasString() const { 101 bool OSExchangeDataProviderChromeos::HasString() const {
100 return (formats_ & OSExchangeData::STRING) != 0; 102 return (formats_ & OSExchangeData::STRING) != 0;
101 } 103 }
102 104
103 bool OSExchangeDataProviderAura::HasURL() const { 105 bool OSExchangeDataProviderChromeos::HasURL() const {
104 if ((formats_ & OSExchangeData::URL) != 0) { 106 if ((formats_ & OSExchangeData::URL) != 0) {
105 return true; 107 return true;
106 } 108 }
107 // No URL, see if we have plain text that can be parsed as a URL. 109 // No URL, see if we have plain text that can be parsed as a URL.
108 return GetPlainTextURL(NULL); 110 return GetPlainTextURL(NULL);
109 } 111 }
110 112
111 bool OSExchangeDataProviderAura::HasFile() const { 113 bool OSExchangeDataProviderChromeos::HasFile() const {
112 return (formats_ & OSExchangeData::FILE_NAME) != 0; 114 return (formats_ & OSExchangeData::FILE_NAME) != 0;
113 } 115 }
114 116
115 bool OSExchangeDataProviderAura::HasCustomFormat( 117 bool OSExchangeDataProviderChromeos::HasCustomFormat(
116 OSExchangeData::CustomFormat format) const { 118 OSExchangeData::CustomFormat format) const {
117 return pickle_data_.find(format) != pickle_data_.end(); 119 return pickle_data_.find(format) != pickle_data_.end();
118 } 120 }
119 121
120 #if defined(OS_WIN) 122 void OSExchangeDataProviderChromeos::SetHtml(const string16& html,
121 void OSExchangeDataProviderAura::SetFileContents(
122 const base::FilePath& filename,
123 const std::string& file_contents) {
124 NOTIMPLEMENTED();
125 }
126
127 bool OSExchangeDataProviderAura::GetFileContents(
128 base::FilePath* filename,
129 std::string* file_contents) const {
130 NOTIMPLEMENTED();
131 return false;
132 }
133
134 bool OSExchangeDataProviderAura::HasFileContents() const {
135 NOTIMPLEMENTED();
136 return false;
137 }
138
139 void OSExchangeDataProviderAura::SetDownloadFileInfo(
140 const OSExchangeData::DownloadFileInfo& download) {
141 NOTIMPLEMENTED();
142 }
143 #endif
144
145 void OSExchangeDataProviderAura::SetHtml(const string16& html,
146 const GURL& base_url) { 123 const GURL& base_url) {
147 formats_ |= OSExchangeData::HTML; 124 formats_ |= OSExchangeData::HTML;
148 html_ = html; 125 html_ = html;
149 base_url_ = base_url; 126 base_url_ = base_url;
150 } 127 }
151 128
152 bool OSExchangeDataProviderAura::GetHtml(string16* html, 129 bool OSExchangeDataProviderChromeos::GetHtml(string16* html,
153 GURL* base_url) const { 130 GURL* base_url) const {
154 if ((formats_ & OSExchangeData::HTML) == 0) 131 if ((formats_ & OSExchangeData::HTML) == 0)
155 return false; 132 return false;
156 *html = html_; 133 *html = html_;
157 *base_url = base_url_; 134 *base_url = base_url_;
158 return true; 135 return true;
159 } 136 }
160 137
161 bool OSExchangeDataProviderAura::HasHtml() const { 138 bool OSExchangeDataProviderChromeos::HasHtml() const {
162 return ((formats_ & OSExchangeData::HTML) != 0); 139 return ((formats_ & OSExchangeData::HTML) != 0);
163 } 140 }
164 141
165 void OSExchangeDataProviderAura::SetDragImage( 142 void OSExchangeDataProviderChromeos::SetDragImage(
166 const gfx::ImageSkia& image, 143 const gfx::ImageSkia& image,
167 const gfx::Vector2d& cursor_offset) { 144 const gfx::Vector2d& cursor_offset) {
168 drag_image_ = image; 145 drag_image_ = image;
169 drag_image_offset_ = cursor_offset; 146 drag_image_offset_ = cursor_offset;
170 } 147 }
171 148
172 const gfx::ImageSkia& OSExchangeDataProviderAura::GetDragImage() const { 149 const gfx::ImageSkia& OSExchangeDataProviderChromeos::GetDragImage() const {
173 return drag_image_; 150 return drag_image_;
174 } 151 }
175 152
176 const gfx::Vector2d& OSExchangeDataProviderAura::GetDragImageOffset() const { 153 const gfx::Vector2d&
154 OSExchangeDataProviderChromeos::GetDragImageOffset() const {
177 return drag_image_offset_; 155 return drag_image_offset_;
178 } 156 }
179 157
180 bool OSExchangeDataProviderAura::GetPlainTextURL(GURL* url) const { 158 bool OSExchangeDataProviderChromeos::GetPlainTextURL(GURL* url) const {
181 if ((formats_ & OSExchangeData::STRING) == 0) 159 if ((formats_ & OSExchangeData::STRING) == 0)
182 return false; 160 return false;
183 161
184 GURL test_url(string_); 162 GURL test_url(string_);
185 if (!test_url.is_valid()) 163 if (!test_url.is_valid())
186 return false; 164 return false;
187 165
188 if (url) 166 if (url)
189 *url = test_url; 167 *url = test_url;
190 return true; 168 return true;
191 } 169 }
192 170
193 /////////////////////////////////////////////////////////////////////////////// 171 ///////////////////////////////////////////////////////////////////////////////
194 // OSExchangeData, public: 172 // OSExchangeData, public:
195 173
196 // static 174 // static
197 OSExchangeData::Provider* OSExchangeData::CreateProvider() { 175 OSExchangeData::Provider* OSExchangeData::CreateProvider() {
198 return new OSExchangeDataProviderAura(); 176 return new OSExchangeDataProviderChromeos();
199 } 177 }
200 178
201 // static 179 // static
202 OSExchangeData::CustomFormat 180 OSExchangeData::CustomFormat
203 OSExchangeData::RegisterCustomFormat(const std::string& type) { 181 OSExchangeData::RegisterCustomFormat(const std::string& type) {
204 // On Aura you probably want to just use the Clipboard::Get*FormatType APIs 182 // On Aura you probably want to just use the Clipboard::Get*FormatType APIs
205 // instead. But we can also dynamically generate new CustomFormat objects 183 // instead. But we can also dynamically generate new CustomFormat objects
206 // here too if really necessary. 184 // here too if really necessary.
207 return Clipboard::FormatType::Deserialize(type); 185 return Clipboard::FormatType::Deserialize(type);
208 } 186 }
209 187
210 188
211 } // namespace ui 189 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_chromeos.h ('k') | ui/base/x/selection_requestor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698