| 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_utils.h" | 5 #include "components/bookmarks/core/browser/bookmark_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/i18n/case_conversion.h" | 11 #include "base/i18n/case_conversion.h" |
| 12 #include "base/i18n/string_search.h" | 12 #include "base/i18n/string_search.h" |
| 13 #include "base/metrics/user_metrics_action.h" | 13 #include "base/metrics/user_metrics_action.h" |
| 14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "chrome/browser/bookmarks/bookmark_model.h" | 18 #include "components/bookmarks/core/browser/bookmark_model.h" |
| 19 #include "components/bookmarks/core/common/bookmark_pref_names.h" | 19 #include "components/bookmarks/core/common/bookmark_pref_names.h" |
| 20 #include "components/query_parser/query_parser.h" | 20 #include "components/query_parser/query_parser.h" |
| 21 #include "components/user_prefs/pref_registry_syncable.h" | 21 #include "components/user_prefs/pref_registry_syncable.h" |
| 22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
| 23 #include "ui/base/models/tree_node_iterator.h" | 23 #include "ui/base/models/tree_node_iterator.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 #if !defined(OS_ANDROID) | 26 #if !defined(OS_ANDROID) |
| 27 #include "chrome/browser/bookmarks/scoped_group_bookmark_actions.h" | 27 #include "components/bookmarks/core/browser/scoped_group_bookmark_actions.h" |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 using base::Time; | 30 using base::Time; |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // The maximum length of URL or title returned by the Cleanup functions. | 34 // The maximum length of URL or title returned by the Cleanup functions. |
| 35 const size_t kCleanedUpUrlMaxLength = 1024u; | 35 const size_t kCleanedUpUrlMaxLength = 1024u; |
| 36 const size_t kCleanedUpTitleMaxLength = 1024u; | 36 const size_t kCleanedUpTitleMaxLength = 1024u; |
| 37 | 37 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 void CloneBookmarkNode(BookmarkModel* model, | 153 void CloneBookmarkNode(BookmarkModel* model, |
| 154 const std::vector<BookmarkNodeData::Element>& elements, | 154 const std::vector<BookmarkNodeData::Element>& elements, |
| 155 const BookmarkNode* parent, | 155 const BookmarkNode* parent, |
| 156 int index_to_add_at, | 156 int index_to_add_at, |
| 157 bool reset_node_times) { | 157 bool reset_node_times) { |
| 158 if (!parent->is_folder() || !model) { | 158 if (!parent->is_folder() || !model) { |
| 159 NOTREACHED(); | 159 NOTREACHED(); |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 for (size_t i = 0; i < elements.size(); ++i) { | 162 for (size_t i = 0; i < elements.size(); ++i) { |
| 163 CloneBookmarkNodeImpl(model, elements[i], parent, index_to_add_at + i, | 163 CloneBookmarkNodeImpl(model, elements[i], parent, |
| 164 index_to_add_at + static_cast<int>(i), |
| 164 reset_node_times); | 165 reset_node_times); |
| 165 } | 166 } |
| 166 } | 167 } |
| 167 | 168 |
| 168 void CopyToClipboard(BookmarkModel* model, | 169 void CopyToClipboard(BookmarkModel* model, |
| 169 const std::vector<const BookmarkNode*>& nodes, | 170 const std::vector<const BookmarkNode*>& nodes, |
| 170 bool remove_nodes) { | 171 bool remove_nodes) { |
| 171 if (nodes.empty()) | 172 if (nodes.empty()) |
| 172 return; | 173 return; |
| 173 | 174 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 base::string16 CleanUpTitleForMatching(const base::string16& title) { | 422 base::string16 CleanUpTitleForMatching(const base::string16& title) { |
| 422 return base::i18n::ToLower(title.substr(0u, kCleanedUpTitleMaxLength)); | 423 return base::i18n::ToLower(title.substr(0u, kCleanedUpTitleMaxLength)); |
| 423 } | 424 } |
| 424 | 425 |
| 425 } // namespace bookmark_utils | 426 } // namespace bookmark_utils |
| 426 | 427 |
| 427 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id) { | 428 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id) { |
| 428 // TODO(sky): TreeNode needs a method that visits all nodes using a predicate. | 429 // TODO(sky): TreeNode needs a method that visits all nodes using a predicate. |
| 429 return GetNodeByID(model->root_node(), id); | 430 return GetNodeByID(model->root_node(), id); |
| 430 } | 431 } |
| OLD | NEW |