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

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

Issue 14736007: Expose os_exchange_data_provider_chromeos to aura builds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix extraneous gyp line Created 7 years, 7 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
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_chromeos.h" 5 #include "ui/base/dragdrop/os_exchange_data_provider_aura.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 OSExchangeDataProviderChromeos::OSExchangeDataProviderChromeos() 15 OSExchangeDataProviderAura::OSExchangeDataProviderAura()
16 : formats_(0) { 16 : formats_(0) {
17 } 17 }
18 18
19 OSExchangeDataProviderChromeos::~OSExchangeDataProviderChromeos() {} 19 OSExchangeDataProviderAura::~OSExchangeDataProviderAura() {}
20 20
21 void OSExchangeDataProviderChromeos::SetString(const string16& data) { 21 void OSExchangeDataProviderAura::SetString(const string16& data) {
22 string_ = data; 22 string_ = data;
23 formats_ |= OSExchangeData::STRING; 23 formats_ |= OSExchangeData::STRING;
24 } 24 }
25 25
26 void OSExchangeDataProviderChromeos::SetURL(const GURL& url, 26 void OSExchangeDataProviderAura::SetURL(const GURL& url,
27 const string16& title) { 27 const string16& title) {
28 url_ = url; 28 url_ = url;
29 title_ = title; 29 title_ = title;
30 formats_ |= OSExchangeData::URL; 30 formats_ |= OSExchangeData::URL;
31 } 31 }
32 32
33 void OSExchangeDataProviderChromeos::SetFilename(const base::FilePath& path) { 33 void OSExchangeDataProviderAura::SetFilename(const base::FilePath& path) {
34 filenames_.clear(); 34 filenames_.clear();
35 filenames_.push_back(OSExchangeData::FileInfo(path, base::FilePath())); 35 filenames_.push_back(OSExchangeData::FileInfo(path, base::FilePath()));
36 formats_ |= OSExchangeData::FILE_NAME; 36 formats_ |= OSExchangeData::FILE_NAME;
37 } 37 }
38 38
39 void OSExchangeDataProviderChromeos::SetFilenames( 39 void OSExchangeDataProviderAura::SetFilenames(
40 const std::vector<OSExchangeData::FileInfo>& filenames) { 40 const std::vector<OSExchangeData::FileInfo>& filenames) {
41 filenames_ = filenames; 41 filenames_ = filenames;
42 formats_ |= OSExchangeData::FILE_NAME; 42 formats_ |= OSExchangeData::FILE_NAME;
43 } 43 }
44 44
45 void OSExchangeDataProviderChromeos::SetPickledData( 45 void OSExchangeDataProviderAura::SetPickledData(
46 OSExchangeData::CustomFormat format, 46 OSExchangeData::CustomFormat format,
47 const Pickle& data) { 47 const Pickle& data) {
48 pickle_data_[format] = data; 48 pickle_data_[format] = data;
49 formats_ |= OSExchangeData::PICKLED_DATA; 49 formats_ |= OSExchangeData::PICKLED_DATA;
50 } 50 }
51 51
52 bool OSExchangeDataProviderChromeos::GetString(string16* data) const { 52 bool OSExchangeDataProviderAura::GetString(string16* data) const {
53 if ((formats_ & OSExchangeData::STRING) == 0) 53 if ((formats_ & OSExchangeData::STRING) == 0)
54 return false; 54 return false;
55 *data = string_; 55 *data = string_;
56 return true; 56 return true;
57 } 57 }
58 58
59 bool OSExchangeDataProviderChromeos::GetURLAndTitle(GURL* url, 59 bool OSExchangeDataProviderAura::GetURLAndTitle(GURL* url,
60 string16* title) const { 60 string16* title) const {
61 if ((formats_ & OSExchangeData::URL) == 0) { 61 if ((formats_ & OSExchangeData::URL) == 0) {
62 title->clear(); 62 title->clear();
63 return GetPlainTextURL(url); 63 return GetPlainTextURL(url);
64 } 64 }
65 65
66 if (!url_.is_valid()) 66 if (!url_.is_valid())
67 return false; 67 return false;
68 68
69 *url = url_; 69 *url = url_;
70 *title = title_; 70 *title = title_;
71 return true; 71 return true;
72 } 72 }
73 73
74 bool OSExchangeDataProviderChromeos::GetFilename(base::FilePath* path) const { 74 bool OSExchangeDataProviderAura::GetFilename(base::FilePath* path) const {
75 if ((formats_ & OSExchangeData::FILE_NAME) == 0) 75 if ((formats_ & OSExchangeData::FILE_NAME) == 0)
76 return false; 76 return false;
77 DCHECK(!filenames_.empty()); 77 DCHECK(!filenames_.empty());
78 *path = filenames_[0].path; 78 *path = filenames_[0].path;
79 return true; 79 return true;
80 } 80 }
81 81
82 bool OSExchangeDataProviderChromeos::GetFilenames( 82 bool OSExchangeDataProviderAura::GetFilenames(
83 std::vector<OSExchangeData::FileInfo>* filenames) const { 83 std::vector<OSExchangeData::FileInfo>* filenames) const {
84 if ((formats_ & OSExchangeData::FILE_NAME) == 0) 84 if ((formats_ & OSExchangeData::FILE_NAME) == 0)
85 return false; 85 return false;
86 *filenames = filenames_; 86 *filenames = filenames_;
87 return true; 87 return true;
88 } 88 }
89 89
90 bool OSExchangeDataProviderChromeos::GetPickledData( 90 bool OSExchangeDataProviderAura::GetPickledData(
91 OSExchangeData::CustomFormat format, 91 OSExchangeData::CustomFormat format,
92 Pickle* data) const { 92 Pickle* data) const {
93 PickleData::const_iterator i = pickle_data_.find(format); 93 PickleData::const_iterator i = pickle_data_.find(format);
94 if (i == pickle_data_.end()) 94 if (i == pickle_data_.end())
95 return false; 95 return false;
96 96
97 *data = i->second; 97 *data = i->second;
98 return true; 98 return true;
99 } 99 }
100 100
101 bool OSExchangeDataProviderChromeos::HasString() const { 101 bool OSExchangeDataProviderAura::HasString() const {
102 return (formats_ & OSExchangeData::STRING) != 0; 102 return (formats_ & OSExchangeData::STRING) != 0;
103 } 103 }
104 104
105 bool OSExchangeDataProviderChromeos::HasURL() const { 105 bool OSExchangeDataProviderAura::HasURL() const {
106 if ((formats_ & OSExchangeData::URL) != 0) { 106 if ((formats_ & OSExchangeData::URL) != 0) {
107 return true; 107 return true;
108 } 108 }
109 // 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.
110 return GetPlainTextURL(NULL); 110 return GetPlainTextURL(NULL);
111 } 111 }
112 112
113 bool OSExchangeDataProviderChromeos::HasFile() const { 113 bool OSExchangeDataProviderAura::HasFile() const {
114 return (formats_ & OSExchangeData::FILE_NAME) != 0; 114 return (formats_ & OSExchangeData::FILE_NAME) != 0;
115 } 115 }
116 116
117 bool OSExchangeDataProviderChromeos::HasCustomFormat( 117 bool OSExchangeDataProviderAura::HasCustomFormat(
118 OSExchangeData::CustomFormat format) const { 118 OSExchangeData::CustomFormat format) const {
119 return pickle_data_.find(format) != pickle_data_.end(); 119 return pickle_data_.find(format) != pickle_data_.end();
120 } 120 }
121 121
122 void OSExchangeDataProviderChromeos::SetHtml(const string16& html, 122 void OSExchangeDataProviderAura::SetHtml(const string16& html,
123 const GURL& base_url) { 123 const GURL& base_url) {
124 formats_ |= OSExchangeData::HTML; 124 formats_ |= OSExchangeData::HTML;
125 html_ = html; 125 html_ = html;
126 base_url_ = base_url; 126 base_url_ = base_url;
127 } 127 }
128 128
129 bool OSExchangeDataProviderChromeos::GetHtml(string16* html, 129 bool OSExchangeDataProviderAura::GetHtml(string16* html,
130 GURL* base_url) const { 130 GURL* base_url) const {
131 if ((formats_ & OSExchangeData::HTML) == 0) 131 if ((formats_ & OSExchangeData::HTML) == 0)
132 return false; 132 return false;
133 *html = html_; 133 *html = html_;
134 *base_url = base_url_; 134 *base_url = base_url_;
135 return true; 135 return true;
136 } 136 }
137 137
138 bool OSExchangeDataProviderChromeos::HasHtml() const { 138 bool OSExchangeDataProviderAura::HasHtml() const {
139 return ((formats_ & OSExchangeData::HTML) != 0); 139 return ((formats_ & OSExchangeData::HTML) != 0);
140 } 140 }
141 141
142 void OSExchangeDataProviderChromeos::SetDragImage( 142 void OSExchangeDataProviderAura::SetDragImage(
143 const gfx::ImageSkia& image, 143 const gfx::ImageSkia& image,
144 const gfx::Vector2d& cursor_offset) { 144 const gfx::Vector2d& cursor_offset) {
145 drag_image_ = image; 145 drag_image_ = image;
146 drag_image_offset_ = cursor_offset; 146 drag_image_offset_ = cursor_offset;
147 } 147 }
148 148
149 const gfx::ImageSkia& OSExchangeDataProviderChromeos::GetDragImage() const { 149 const gfx::ImageSkia& OSExchangeDataProviderAura::GetDragImage() const {
150 return drag_image_; 150 return drag_image_;
151 } 151 }
152 152
153 const gfx::Vector2d& 153 const gfx::Vector2d&
154 OSExchangeDataProviderChromeos::GetDragImageOffset() const { 154 OSExchangeDataProviderAura::GetDragImageOffset() const {
155 return drag_image_offset_; 155 return drag_image_offset_;
156 } 156 }
157 157
158 bool OSExchangeDataProviderChromeos::GetPlainTextURL(GURL* url) const { 158 bool OSExchangeDataProviderAura::GetPlainTextURL(GURL* url) const {
159 if ((formats_ & OSExchangeData::STRING) == 0) 159 if ((formats_ & OSExchangeData::STRING) == 0)
160 return false; 160 return false;
161 161
162 GURL test_url(string_); 162 GURL test_url(string_);
163 if (!test_url.is_valid()) 163 if (!test_url.is_valid())
164 return false; 164 return false;
165 165
166 if (url) 166 if (url)
167 *url = test_url; 167 *url = test_url;
168 return true; 168 return true;
169 } 169 }
170 170
171 /////////////////////////////////////////////////////////////////////////////// 171 ///////////////////////////////////////////////////////////////////////////////
172 // OSExchangeData, public: 172 // OSExchangeData, public:
173 173
174 // static 174 // static
175 OSExchangeData::Provider* OSExchangeData::CreateProvider() { 175 OSExchangeData::Provider* OSExchangeData::CreateProvider() {
176 return new OSExchangeDataProviderChromeos(); 176 return new OSExchangeDataProviderAura();
177 } 177 }
178 178
179 // static 179 // static
180 OSExchangeData::CustomFormat 180 OSExchangeData::CustomFormat
181 OSExchangeData::RegisterCustomFormat(const std::string& type) { 181 OSExchangeData::RegisterCustomFormat(const std::string& type) {
182 // 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
183 // instead. But we can also dynamically generate new CustomFormat objects 183 // instead. But we can also dynamically generate new CustomFormat objects
184 // here too if really necessary. 184 // here too if really necessary.
185 return Clipboard::FormatType::Deserialize(type); 185 return Clipboard::FormatType::Deserialize(type);
186 } 186 }
187 187
188 188
189 } // namespace ui 189 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/dragdrop/os_exchange_data_provider_aura.h ('k') | ui/base/dragdrop/os_exchange_data_provider_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698