OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/bookmarks/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 "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
11 #include "ui/base/clipboard/clipboard.h" | 11 #include "ui/base/clipboard/clipboard.h" |
12 | 12 |
13 // static | 13 // static |
14 const ui::OSExchangeData::CustomFormat& | 14 const ui::OSExchangeData::CustomFormat& |
15 BookmarkNodeData::GetBookmarkCustomFormat() { | 15 BookmarkNodeData::GetBookmarkCustomFormat() { |
16 CR_DEFINE_STATIC_LOCAL( | 16 CR_DEFINE_STATIC_LOCAL( |
17 ui::OSExchangeData::CustomFormat, | 17 ui::OSExchangeData::CustomFormat, |
18 format, | 18 format, |
19 (ui::Clipboard::GetFormatType(BookmarkNodeData::kClipboardFormatString))); | 19 (ui::Clipboard::GetFormatType(BookmarkNodeData::kClipboardFormatString))); |
20 | 20 |
21 return format; | 21 return format; |
22 } | 22 } |
23 | 23 |
24 void BookmarkNodeData::Write(Profile* profile, ui::OSExchangeData* data) const { | 24 void BookmarkNodeData::Write(Profile* profile, ui::OSExchangeData* data) const { |
25 DCHECK(data); | 25 DCHECK(data); |
26 | 26 |
27 // If there is only one element and it is a URL, write the URL to the | 27 // If there is only one element and it is a URL, write the URL to the |
28 // clipboard. | 28 // clipboard. |
29 if (elements.size() == 1 && elements[0].is_url) { | 29 if (elements.size() == 1 && elements[0].is_url) { |
30 if (elements[0].url.SchemeIs(chrome::kJavaScriptScheme)) { | 30 if (elements[0].url.SchemeIs(content::kJavaScriptScheme)) { |
31 data->SetString(UTF8ToUTF16(elements[0].url.spec())); | 31 data->SetString(UTF8ToUTF16(elements[0].url.spec())); |
32 } else { | 32 } else { |
33 data->SetURL(elements[0].url, elements[0].title); | 33 data->SetURL(elements[0].url, elements[0].title); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 Pickle data_pickle; | 37 Pickle data_pickle; |
38 WriteToPickle(profile, &data_pickle); | 38 WriteToPickle(profile, &data_pickle); |
39 | 39 |
40 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle); | 40 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle); |
(...skipping 14 matching lines...) Expand all Loading... |
55 // See if there is a URL on the clipboard. | 55 // See if there is a URL on the clipboard. |
56 Element element; | 56 Element element; |
57 GURL url; | 57 GURL url; |
58 string16 title; | 58 string16 title; |
59 if (data.GetURLAndTitle(&url, &title)) | 59 if (data.GetURLAndTitle(&url, &title)) |
60 ReadFromTuple(url, title); | 60 ReadFromTuple(url, title); |
61 } | 61 } |
62 | 62 |
63 return is_valid(); | 63 return is_valid(); |
64 } | 64 } |
OLD | NEW |