| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/os_exchange_data_provider_gtk.h" | 5 #include "app/os_exchange_data_provider_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 157 } |
| 158 | 158 |
| 159 void OSExchangeDataProviderGtk::SetHtml(const std::wstring& html, | 159 void OSExchangeDataProviderGtk::SetHtml(const std::wstring& html, |
| 160 const GURL& base_url) { | 160 const GURL& base_url) { |
| 161 html_ = WideToUTF16Hack(html); | 161 html_ = WideToUTF16Hack(html); |
| 162 base_url_ = base_url; | 162 base_url_ = base_url; |
| 163 formats_ |= OSExchangeData::HTML; | 163 formats_ |= OSExchangeData::HTML; |
| 164 } | 164 } |
| 165 | 165 |
| 166 bool OSExchangeDataProviderGtk::GetString(std::wstring* data) const { | 166 bool OSExchangeDataProviderGtk::GetString(std::wstring* data) const { |
| 167 if (formats_ & OSExchangeData::STRING == 0) | 167 if ((formats_ & OSExchangeData::STRING) == 0) |
| 168 return false; | 168 return false; |
| 169 *data = UTF16ToWideHack(string_); | 169 *data = UTF16ToWideHack(string_); |
| 170 return true; | 170 return true; |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool OSExchangeDataProviderGtk::GetURLAndTitle(GURL* url, | 173 bool OSExchangeDataProviderGtk::GetURLAndTitle(GURL* url, |
| 174 std::wstring* title) const { | 174 std::wstring* title) const { |
| 175 if (formats_ & OSExchangeData::URL == 0) | 175 if ((formats_ & OSExchangeData::URL) == 0) |
| 176 return false; | 176 return false; |
| 177 if (!url_.is_valid()) | 177 if (!url_.is_valid()) |
| 178 return false; | 178 return false; |
| 179 | 179 |
| 180 *url = url_; | 180 *url = url_; |
| 181 *title = UTF16ToWideHack(title_); | 181 *title = UTF16ToWideHack(title_); |
| 182 return true; | 182 return true; |
| 183 } | 183 } |
| 184 | 184 |
| 185 bool OSExchangeDataProviderGtk::GetFilename(std::wstring* full_path) const { | 185 bool OSExchangeDataProviderGtk::GetFilename(std::wstring* full_path) const { |
| 186 if (formats_ & OSExchangeData::FILE_NAME == 0) | 186 if ((formats_ & OSExchangeData::FILE_NAME) == 0) |
| 187 return false; | 187 return false; |
| 188 *full_path = UTF16ToWideHack(filename_); | 188 *full_path = UTF16ToWideHack(filename_); |
| 189 return true; | 189 return true; |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool OSExchangeDataProviderGtk::GetPickledData(GdkAtom format, | 192 bool OSExchangeDataProviderGtk::GetPickledData(GdkAtom format, |
| 193 Pickle* data) const { | 193 Pickle* data) const { |
| 194 PickleData::const_iterator i = pickle_data_.find(format); | 194 PickleData::const_iterator i = pickle_data_.find(format); |
| 195 if (i == pickle_data_.end()) | 195 if (i == pickle_data_.end()) |
| 196 return false; | 196 return false; |
| 197 | 197 |
| 198 *data = i->second; | 198 *data = i->second; |
| 199 return true; | 199 return true; |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool OSExchangeDataProviderGtk::GetFileContents( | 202 bool OSExchangeDataProviderGtk::GetFileContents( |
| 203 std::wstring* filename, | 203 std::wstring* filename, |
| 204 std::string* file_contents) const { | 204 std::string* file_contents) const { |
| 205 if (formats_ & OSExchangeData::FILE_CONTENTS == 0) | 205 if ((formats_ & OSExchangeData::FILE_CONTENTS) == 0) |
| 206 return false; | 206 return false; |
| 207 *filename = UTF16ToWideHack(filename_); | 207 *filename = UTF16ToWideHack(filename_); |
| 208 *file_contents = file_contents_; | 208 *file_contents = file_contents_; |
| 209 return true; | 209 return true; |
| 210 } | 210 } |
| 211 | 211 |
| 212 bool OSExchangeDataProviderGtk::GetHtml(std::wstring* html, | 212 bool OSExchangeDataProviderGtk::GetHtml(std::wstring* html, |
| 213 GURL* base_url) const { | 213 GURL* base_url) const { |
| 214 if (formats_ & OSExchangeData::HTML == 0) | 214 if ((formats_ & OSExchangeData::HTML) == 0) |
| 215 return false; | 215 return false; |
| 216 *html = UTF16ToWideHack(filename_); | 216 *html = UTF16ToWideHack(filename_); |
| 217 *base_url = base_url_; | 217 *base_url = base_url_; |
| 218 return true; | 218 return true; |
| 219 } | 219 } |
| 220 | 220 |
| 221 bool OSExchangeDataProviderGtk::HasString() const { | 221 bool OSExchangeDataProviderGtk::HasString() const { |
| 222 return (known_formats_ & OSExchangeData::STRING) != 0 || | 222 return (known_formats_ & OSExchangeData::STRING) != 0 || |
| 223 (formats_ & OSExchangeData::STRING) != 0; | 223 (formats_ & OSExchangeData::STRING) != 0; |
| 224 } | 224 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 252 // OSExchangeData, public: | 252 // OSExchangeData, public: |
| 253 | 253 |
| 254 // static | 254 // static |
| 255 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 255 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
| 256 return new OSExchangeDataProviderGtk(); | 256 return new OSExchangeDataProviderGtk(); |
| 257 } | 257 } |
| 258 | 258 |
| 259 GdkAtom OSExchangeData::RegisterCustomFormat(const std::string& type) { | 259 GdkAtom OSExchangeData::RegisterCustomFormat(const std::string& type) { |
| 260 return gdk_atom_intern(type.c_str(), false); | 260 return gdk_atom_intern(type.c_str(), false); |
| 261 } | 261 } |
| OLD | NEW |