OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/bookmarks/core/browser/bookmark_node_data.h" | 5 #include "components/bookmarks/core/browser/bookmark_node_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 } | 105 } |
106 | 106 |
107 BookmarkNodeData::BookmarkNodeData( | 107 BookmarkNodeData::BookmarkNodeData( |
108 const std::vector<const BookmarkNode*>& nodes) { | 108 const std::vector<const BookmarkNode*>& nodes) { |
109 ReadFromVector(nodes); | 109 ReadFromVector(nodes); |
110 } | 110 } |
111 | 111 |
112 BookmarkNodeData::~BookmarkNodeData() { | 112 BookmarkNodeData::~BookmarkNodeData() { |
113 } | 113 } |
114 | 114 |
115 #if !defined(OS_MACOSX) | 115 #if !defined(OS_MACOSX) && !defined(OS_IOS) |
blundell
2014/05/05 12:32:18
This is unnecessary: OS_MACOSX is defined when OS_
sdefresne
2014/05/05 14:45:50
Done.
| |
116 // static | 116 // static |
117 bool BookmarkNodeData::ClipboardContainsBookmarks() { | 117 bool BookmarkNodeData::ClipboardContainsBookmarks() { |
118 return ui::Clipboard::GetForCurrentThread()->IsFormatAvailable( | 118 return ui::Clipboard::GetForCurrentThread()->IsFormatAvailable( |
119 ui::Clipboard::GetFormatType(kClipboardFormatString), | 119 ui::Clipboard::GetFormatType(kClipboardFormatString), |
120 ui::CLIPBOARD_TYPE_COPY_PASTE); | 120 ui::CLIPBOARD_TYPE_COPY_PASTE); |
121 } | 121 } |
122 #endif | 122 #endif // !defined(OS_MACOSX) && !defined(OS_IOS) |
123 | 123 |
124 bool BookmarkNodeData::ReadFromVector( | 124 bool BookmarkNodeData::ReadFromVector( |
125 const std::vector<const BookmarkNode*>& nodes) { | 125 const std::vector<const BookmarkNode*>& nodes) { |
126 Clear(); | 126 Clear(); |
127 | 127 |
128 if (nodes.empty()) | 128 if (nodes.empty()) |
129 return false; | 129 return false; |
130 | 130 |
131 for (size_t i = 0; i < nodes.size(); ++i) | 131 for (size_t i = 0; i < nodes.size(); ++i) |
132 elements.push_back(Element(nodes[i])); | 132 elements.push_back(Element(nodes[i])); |
(...skipping 10 matching lines...) Expand all Loading... | |
143 Element element; | 143 Element element; |
144 element.title = title; | 144 element.title = title; |
145 element.url = url; | 145 element.url = url; |
146 element.is_url = true; | 146 element.is_url = true; |
147 | 147 |
148 elements.push_back(element); | 148 elements.push_back(element); |
149 | 149 |
150 return true; | 150 return true; |
151 } | 151 } |
152 | 152 |
153 #if !defined(OS_MACOSX) | 153 #if !defined(OS_MACOSX) && !defined(OS_IOS) |
154 void BookmarkNodeData::WriteToClipboard(ui::ClipboardType clipboard_type) { | 154 void BookmarkNodeData::WriteToClipboard(ui::ClipboardType clipboard_type) { |
155 DCHECK(clipboard_type == ui::CLIPBOARD_TYPE_COPY_PASTE || | 155 DCHECK(clipboard_type == ui::CLIPBOARD_TYPE_COPY_PASTE || |
156 clipboard_type == ui::CLIPBOARD_TYPE_SELECTION); | 156 clipboard_type == ui::CLIPBOARD_TYPE_SELECTION); |
157 ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(), | 157 ui::ScopedClipboardWriter scw(ui::Clipboard::GetForCurrentThread(), |
158 clipboard_type); | 158 clipboard_type); |
159 | 159 |
160 // If there is only one element and it is a URL, write the URL to the | 160 // If there is only one element and it is a URL, write the URL to the |
161 // clipboard. | 161 // clipboard. |
162 if (elements.size() == 1 && elements[0].is_url) { | 162 if (elements.size() == 1 && elements[0].is_url) { |
163 const base::string16& title = elements[0].title; | 163 const base::string16& title = elements[0].title; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 element.url = GURL(url); | 205 element.url = GURL(url); |
206 element.title = title; | 206 element.title = title; |
207 | 207 |
208 elements.clear(); | 208 elements.clear(); |
209 elements.push_back(element); | 209 elements.push_back(element); |
210 return true; | 210 return true; |
211 } | 211 } |
212 | 212 |
213 return false; | 213 return false; |
214 } | 214 } |
215 #endif | 215 #endif // !defined(OS_MACOSX) && !defined(OS_IOS) |
216 | 216 |
217 void BookmarkNodeData::WriteToPickle(const base::FilePath& profile_path, | 217 void BookmarkNodeData::WriteToPickle(const base::FilePath& profile_path, |
218 Pickle* pickle) const { | 218 Pickle* pickle) const { |
219 profile_path.WriteToPickle(pickle); | 219 profile_path.WriteToPickle(pickle); |
220 pickle->WriteUInt64(elements.size()); | 220 pickle->WriteUInt64(elements.size()); |
221 | 221 |
222 for (size_t i = 0; i < elements.size(); ++i) | 222 for (size_t i = 0; i < elements.size(); ++i) |
223 elements[i].WriteToPickle(pickle); | 223 elements[i].WriteToPickle(pickle); |
224 } | 224 } |
225 | 225 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 const base::FilePath& profile_path) { | 276 const base::FilePath& profile_path) { |
277 DCHECK(profile_path_.empty()); | 277 DCHECK(profile_path_.empty()); |
278 profile_path_ = profile_path; | 278 profile_path_ = profile_path; |
279 } | 279 } |
280 | 280 |
281 bool BookmarkNodeData::IsFromProfilePath( | 281 bool BookmarkNodeData::IsFromProfilePath( |
282 const base::FilePath& profile_path) const { | 282 const base::FilePath& profile_path) const { |
283 // An empty path means the data is not associated with any profile. | 283 // An empty path means the data is not associated with any profile. |
284 return !profile_path_.empty() && profile_path_ == profile_path; | 284 return !profile_path_.empty() && profile_path_ == profile_path; |
285 } | 285 } |
OLD | NEW |