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/browser/bookmark_node_data.h" | 5 #include "components/bookmarks/browser/bookmark_node_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "ui/base/clipboard/clipboard.h" | 10 #include "ui/base/clipboard/clipboard.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // If there is only one element and it is a URL, write the URL to the | 30 // If there is only one element and it is a URL, write the URL to the |
31 // clipboard. | 31 // clipboard. |
32 if (has_single_url()) { | 32 if (has_single_url()) { |
33 if (elements[0].url.SchemeIs(url::kJavaScriptScheme)) { | 33 if (elements[0].url.SchemeIs(url::kJavaScriptScheme)) { |
34 data->SetString(base::UTF8ToUTF16(elements[0].url.spec())); | 34 data->SetString(base::UTF8ToUTF16(elements[0].url.spec())); |
35 } else { | 35 } else { |
36 data->SetURL(elements[0].url, elements[0].title); | 36 data->SetURL(elements[0].url, elements[0].title); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 Pickle data_pickle; | 40 base::Pickle data_pickle; |
41 WriteToPickle(profile_path, &data_pickle); | 41 WriteToPickle(profile_path, &data_pickle); |
42 | 42 |
43 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle); | 43 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle); |
44 } | 44 } |
45 | 45 |
46 bool BookmarkNodeData::Read(const ui::OSExchangeData& data) { | 46 bool BookmarkNodeData::Read(const ui::OSExchangeData& data) { |
47 elements.clear(); | 47 elements.clear(); |
48 | 48 |
49 profile_path_.clear(); | 49 profile_path_.clear(); |
50 | 50 |
51 if (data.HasCustomFormat(GetBookmarkCustomFormat())) { | 51 if (data.HasCustomFormat(GetBookmarkCustomFormat())) { |
52 Pickle drag_data_pickle; | 52 base::Pickle drag_data_pickle; |
53 if (data.GetPickledData(GetBookmarkCustomFormat(), &drag_data_pickle)) { | 53 if (data.GetPickledData(GetBookmarkCustomFormat(), &drag_data_pickle)) { |
54 if (!ReadFromPickle(&drag_data_pickle)) | 54 if (!ReadFromPickle(&drag_data_pickle)) |
55 return false; | 55 return false; |
56 } | 56 } |
57 } else { | 57 } else { |
58 // See if there is a URL on the clipboard. | 58 // See if there is a URL on the clipboard. |
59 GURL url; | 59 GURL url; |
60 base::string16 title; | 60 base::string16 title; |
61 if (data.GetURLAndTitle( | 61 if (data.GetURLAndTitle( |
62 ui::OSExchangeData::CONVERT_FILENAMES, &url, &title)) | 62 ui::OSExchangeData::CONVERT_FILENAMES, &url, &title)) |
63 ReadFromTuple(url, title); | 63 ReadFromTuple(url, title); |
64 } | 64 } |
65 | 65 |
66 return is_valid(); | 66 return is_valid(); |
67 } | 67 } |
68 | 68 |
69 } // namespace bookmarks | 69 } // namespace bookmarks |
OLD | NEW |