Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(982)

Side by Side Diff: components/bookmarks/browser/bookmark_node_data_views.cc

Issue 867493003: bookmarks: Reuse kJavaScriptScheme constant from //url module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "url/url_constants.h"
11 12
12 namespace bookmarks { 13 namespace bookmarks {
13 14
14 namespace {
15
16 const char kJavaScriptScheme[] = "javascript";
17
18 } // namespace
19
20 // static 15 // static
21 const ui::OSExchangeData::CustomFormat& 16 const ui::OSExchangeData::CustomFormat&
22 BookmarkNodeData::GetBookmarkCustomFormat() { 17 BookmarkNodeData::GetBookmarkCustomFormat() {
23 CR_DEFINE_STATIC_LOCAL( 18 CR_DEFINE_STATIC_LOCAL(
24 ui::OSExchangeData::CustomFormat, 19 ui::OSExchangeData::CustomFormat,
25 format, 20 format,
26 (ui::Clipboard::GetFormatType(BookmarkNodeData::kClipboardFormatString))); 21 (ui::Clipboard::GetFormatType(BookmarkNodeData::kClipboardFormatString)));
27 22
28 return format; 23 return format;
29 } 24 }
30 25
31 void BookmarkNodeData::Write(const base::FilePath& profile_path, 26 void BookmarkNodeData::Write(const base::FilePath& profile_path,
32 ui::OSExchangeData* data) const { 27 ui::OSExchangeData* data) const {
33 DCHECK(data); 28 DCHECK(data);
34 29
35 // 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
36 // clipboard. 31 // clipboard.
37 if (has_single_url()) { 32 if (has_single_url()) {
38 if (elements[0].url.SchemeIs(kJavaScriptScheme)) { 33 if (elements[0].url.SchemeIs(url::kJavaScriptScheme)) {
39 data->SetString(base::UTF8ToUTF16(elements[0].url.spec())); 34 data->SetString(base::UTF8ToUTF16(elements[0].url.spec()));
40 } else { 35 } else {
41 data->SetURL(elements[0].url, elements[0].title); 36 data->SetURL(elements[0].url, elements[0].title);
42 } 37 }
43 } 38 }
44 39
45 Pickle data_pickle; 40 Pickle data_pickle;
46 WriteToPickle(profile_path, &data_pickle); 41 WriteToPickle(profile_path, &data_pickle);
47 42
48 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle); 43 data->SetPickledData(GetBookmarkCustomFormat(), data_pickle);
(...skipping 17 matching lines...) Expand all
66 base::string16 title; 61 base::string16 title;
67 if (data.GetURLAndTitle( 62 if (data.GetURLAndTitle(
68 ui::OSExchangeData::CONVERT_FILENAMES, &url, &title)) 63 ui::OSExchangeData::CONVERT_FILENAMES, &url, &title))
69 ReadFromTuple(url, title); 64 ReadFromTuple(url, title);
70 } 65 }
71 66
72 return is_valid(); 67 return is_valid();
73 } 68 }
74 69
75 } // namespace bookmarks 70 } // namespace bookmarks
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698