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 "chrome/browser/bookmarks/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/file_path.h" | 10 #include "base/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/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/string16.h" | 14 #include "base/string16.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/bookmarks/bookmark_model.h" | 17 #include "chrome/browser/bookmarks/bookmark_model.h" |
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
19 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 19 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
20 #include "chrome/browser/history/query_parser.h" | 20 #include "chrome/browser/history/query_parser.h" |
21 #include "chrome/browser/prefs/pref_service_syncable.h" | 21 #include "chrome/browser/prefs/pref_service_syncable.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
24 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
25 #include "grit/ui_strings.h" | |
26 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
27 #include "ui/base/dragdrop/drag_drop_types.h" | 26 #include "ui/base/dragdrop/drag_drop_types.h" |
28 #include "ui/base/events/event.h" | 27 #include "ui/base/events/event.h" |
29 #include "ui/base/l10n/l10n_util.h" | |
30 #include "ui/base/models/tree_node_iterator.h" | 28 #include "ui/base/models/tree_node_iterator.h" |
31 | 29 |
32 using base::Time; | 30 using base::Time; |
33 | 31 |
34 namespace { | 32 namespace { |
35 | 33 |
36 void CloneBookmarkNodeImpl(BookmarkModel* model, | 34 void CloneBookmarkNodeImpl(BookmarkModel* model, |
37 const BookmarkNodeData::Element& element, | 35 const BookmarkNodeData::Element& element, |
38 const BookmarkNode* parent, | 36 const BookmarkNode* parent, |
39 int index_to_add_at) { | 37 int index_to_add_at) { |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 bookmark_utils::CloneBookmarkNode( | 267 bookmark_utils::CloneBookmarkNode( |
270 model, bookmark_data.elements, parent, index); | 268 model, bookmark_data.elements, parent, index); |
271 } | 269 } |
272 | 270 |
273 bool CanPasteFromClipboard(const BookmarkNode* node) { | 271 bool CanPasteFromClipboard(const BookmarkNode* node) { |
274 if (!node) | 272 if (!node) |
275 return false; | 273 return false; |
276 return BookmarkNodeData::ClipboardContainsBookmarks(); | 274 return BookmarkNodeData::ClipboardContainsBookmarks(); |
277 } | 275 } |
278 | 276 |
279 string16 GetNameForURL(const GURL& url) { | |
280 if (url.is_valid()) { | |
281 return net::GetSuggestedFilename(url, "", "", "", "", std::string()); | |
282 } else { | |
283 return l10n_util::GetStringUTF16(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME); | |
284 } | |
285 } | |
286 | |
287 // This is used with a tree iterator to skip subtrees which are not visible. | 277 // This is used with a tree iterator to skip subtrees which are not visible. |
288 static bool PruneInvisibleFolders(const BookmarkNode* node) { | 278 static bool PruneInvisibleFolders(const BookmarkNode* node) { |
289 return !node->IsVisible(); | 279 return !node->IsVisible(); |
290 } | 280 } |
291 | 281 |
292 std::vector<const BookmarkNode*> GetMostRecentlyModifiedFolders( | 282 std::vector<const BookmarkNode*> GetMostRecentlyModifiedFolders( |
293 BookmarkModel* model, | 283 BookmarkModel* model, |
294 size_t max_count) { | 284 size_t max_count) { |
295 std::vector<const BookmarkNode*> nodes; | 285 std::vector<const BookmarkNode*> nodes; |
296 ui::TreeNodeIterator<const BookmarkNode> | 286 ui::TreeNodeIterator<const BookmarkNode> |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) { | 519 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) { |
530 g_bookmark_bar_view_animations_disabled = disabled; | 520 g_bookmark_bar_view_animations_disabled = disabled; |
531 } | 521 } |
532 | 522 |
533 bool IsBookmarkBarViewAnimationsDisabled() { | 523 bool IsBookmarkBarViewAnimationsDisabled() { |
534 return g_bookmark_bar_view_animations_disabled; | 524 return g_bookmark_bar_view_animations_disabled; |
535 } | 525 } |
536 #endif | 526 #endif |
537 | 527 |
538 } // namespace bookmark_utils | 528 } // namespace bookmark_utils |
OLD | NEW |