OLD | NEW |
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_aura.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/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 #include "ui/base/dragdrop/file_info.h" |
12 | 13 |
13 namespace ui { | 14 namespace ui { |
14 | 15 |
15 OSExchangeDataProviderAura::OSExchangeDataProviderAura() | 16 OSExchangeDataProviderAura::OSExchangeDataProviderAura() |
16 : formats_(0) { | 17 : formats_(0) { |
17 } | 18 } |
18 | 19 |
19 OSExchangeDataProviderAura::~OSExchangeDataProviderAura() {} | 20 OSExchangeDataProviderAura::~OSExchangeDataProviderAura() {} |
20 | 21 |
21 OSExchangeData::Provider* OSExchangeDataProviderAura::Clone() const { | 22 OSExchangeData::Provider* OSExchangeDataProviderAura::Clone() const { |
(...skipping 29 matching lines...) Expand all Loading... |
51 const base::string16& title) { | 52 const base::string16& title) { |
52 url_ = url; | 53 url_ = url; |
53 title_ = title; | 54 title_ = title; |
54 formats_ |= OSExchangeData::URL; | 55 formats_ |= OSExchangeData::URL; |
55 | 56 |
56 SetString(base::UTF8ToUTF16(url.spec())); | 57 SetString(base::UTF8ToUTF16(url.spec())); |
57 } | 58 } |
58 | 59 |
59 void OSExchangeDataProviderAura::SetFilename(const base::FilePath& path) { | 60 void OSExchangeDataProviderAura::SetFilename(const base::FilePath& path) { |
60 filenames_.clear(); | 61 filenames_.clear(); |
61 filenames_.push_back(OSExchangeData::FileInfo(path, base::FilePath())); | 62 filenames_.push_back(FileInfo(path, base::FilePath())); |
62 formats_ |= OSExchangeData::FILE_NAME; | 63 formats_ |= OSExchangeData::FILE_NAME; |
63 } | 64 } |
64 | 65 |
65 void OSExchangeDataProviderAura::SetFilenames( | 66 void OSExchangeDataProviderAura::SetFilenames( |
66 const std::vector<OSExchangeData::FileInfo>& filenames) { | 67 const std::vector<FileInfo>& filenames) { |
67 filenames_ = filenames; | 68 filenames_ = filenames; |
68 formats_ |= OSExchangeData::FILE_NAME; | 69 formats_ |= OSExchangeData::FILE_NAME; |
69 } | 70 } |
70 | 71 |
71 void OSExchangeDataProviderAura::SetPickledData( | 72 void OSExchangeDataProviderAura::SetPickledData( |
72 const OSExchangeData::CustomFormat& format, | 73 const OSExchangeData::CustomFormat& format, |
73 const Pickle& data) { | 74 const Pickle& data) { |
74 pickle_data_[format] = data; | 75 pickle_data_[format] = data; |
75 formats_ |= OSExchangeData::PICKLED_DATA; | 76 formats_ |= OSExchangeData::PICKLED_DATA; |
76 } | 77 } |
(...skipping 25 matching lines...) Expand all Loading... |
102 | 103 |
103 bool OSExchangeDataProviderAura::GetFilename(base::FilePath* path) const { | 104 bool OSExchangeDataProviderAura::GetFilename(base::FilePath* path) const { |
104 if ((formats_ & OSExchangeData::FILE_NAME) == 0) | 105 if ((formats_ & OSExchangeData::FILE_NAME) == 0) |
105 return false; | 106 return false; |
106 DCHECK(!filenames_.empty()); | 107 DCHECK(!filenames_.empty()); |
107 *path = filenames_[0].path; | 108 *path = filenames_[0].path; |
108 return true; | 109 return true; |
109 } | 110 } |
110 | 111 |
111 bool OSExchangeDataProviderAura::GetFilenames( | 112 bool OSExchangeDataProviderAura::GetFilenames( |
112 std::vector<OSExchangeData::FileInfo>* filenames) const { | 113 std::vector<FileInfo>* filenames) const { |
113 if ((formats_ & OSExchangeData::FILE_NAME) == 0) | 114 if ((formats_ & OSExchangeData::FILE_NAME) == 0) |
114 return false; | 115 return false; |
115 *filenames = filenames_; | 116 *filenames = filenames_; |
116 return true; | 117 return true; |
117 } | 118 } |
118 | 119 |
119 bool OSExchangeDataProviderAura::GetPickledData( | 120 bool OSExchangeDataProviderAura::GetPickledData( |
120 const OSExchangeData::CustomFormat& format, | 121 const OSExchangeData::CustomFormat& format, |
121 Pickle* data) const { | 122 Pickle* data) const { |
122 PickleData::const_iterator i = pickle_data_.find(format); | 123 PickleData::const_iterator i = pickle_data_.find(format); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 202 |
202 /////////////////////////////////////////////////////////////////////////////// | 203 /////////////////////////////////////////////////////////////////////////////// |
203 // OSExchangeData, public: | 204 // OSExchangeData, public: |
204 | 205 |
205 // static | 206 // static |
206 OSExchangeData::Provider* OSExchangeData::CreateProvider() { | 207 OSExchangeData::Provider* OSExchangeData::CreateProvider() { |
207 return new OSExchangeDataProviderAura(); | 208 return new OSExchangeDataProviderAura(); |
208 } | 209 } |
209 | 210 |
210 } // namespace ui | 211 } // namespace ui |
OLD | NEW |