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 "chrome/browser/bookmarks/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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/bookmarks/bookmark_utils.h" | 13 #include "components/bookmarks/core/browser/bookmark_utils.h" |
14 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 14 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
15 | 15 |
16 const char* BookmarkNodeData::kClipboardFormatString = | 16 const char* BookmarkNodeData::kClipboardFormatString = |
17 "chromium/x-bookmark-entries"; | 17 "chromium/x-bookmark-entries"; |
18 | 18 |
19 BookmarkNodeData::Element::Element() : is_url(false), id_(0) { | 19 BookmarkNodeData::Element::Element() : is_url(false), id_(0) { |
20 } | 20 } |
21 | 21 |
22 BookmarkNodeData::Element::Element(const BookmarkNode* node) | 22 BookmarkNodeData::Element::Element(const BookmarkNode* node) |
23 : is_url(node->is_url()), | 23 : is_url(node->is_url()), |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 184 } |
185 | 185 |
186 bool BookmarkNodeData::ReadFromClipboard(ui::ClipboardType type) { | 186 bool BookmarkNodeData::ReadFromClipboard(ui::ClipboardType type) { |
187 DCHECK_EQ(type, ui::CLIPBOARD_TYPE_COPY_PASTE); | 187 DCHECK_EQ(type, ui::CLIPBOARD_TYPE_COPY_PASTE); |
188 std::string data; | 188 std::string data; |
189 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); | 189 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
190 clipboard->ReadData(ui::Clipboard::GetFormatType(kClipboardFormatString), | 190 clipboard->ReadData(ui::Clipboard::GetFormatType(kClipboardFormatString), |
191 &data); | 191 &data); |
192 | 192 |
193 if (!data.empty()) { | 193 if (!data.empty()) { |
194 Pickle pickle(data.data(), data.size()); | 194 Pickle pickle(data.data(), static_cast<int>(data.size())); |
195 if (ReadFromPickle(&pickle)) | 195 if (ReadFromPickle(&pickle)) |
196 return true; | 196 return true; |
197 } | 197 } |
198 | 198 |
199 base::string16 title; | 199 base::string16 title; |
200 std::string url; | 200 std::string url; |
201 clipboard->ReadBookmark(&title, &url); | 201 clipboard->ReadBookmark(&title, &url); |
202 if (!url.empty()) { | 202 if (!url.empty()) { |
203 Element element; | 203 Element element; |
204 element.is_url = true; | 204 element.is_url = true; |
(...skipping 71 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 |