OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string16.h" | 12 #include "base/string16.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/bookmarks/bookmark_model.h" | 16 #include "chrome/browser/bookmarks/bookmark_model.h" |
17 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 17 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
18 #include "chrome/browser/history/query_parser.h" | 18 #include "chrome/browser/history/query_parser.h" |
19 #include "chrome/browser/platform_util.h" | |
20 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/simple_message_box.h" |
22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
24 #include "chrome/browser/ui/browser_window.h" | 24 #include "chrome/browser/ui/browser_window.h" |
25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
27 #include "content/browser/tab_contents/page_navigator.h" | 27 #include "content/browser/tab_contents/page_navigator.h" |
28 #include "content/browser/tab_contents/tab_contents.h" | 28 #include "content/browser/tab_contents/tab_contents.h" |
29 #include "content/common/notification_service.h" | 29 #include "content/common/notification_service.h" |
30 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
31 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 int child_count = 0; | 184 int child_count = 0; |
185 for (size_t i = 0; i < nodes.size(); ++i) | 185 for (size_t i = 0; i < nodes.size(); ++i) |
186 child_count += ChildURLCount(nodes[i]); | 186 child_count += ChildURLCount(nodes[i]); |
187 if (child_count < bookmark_utils::num_urls_before_prompting) | 187 if (child_count < bookmark_utils::num_urls_before_prompting) |
188 return true; | 188 return true; |
189 | 189 |
190 string16 message = l10n_util::GetStringFUTF16( | 190 string16 message = l10n_util::GetStringFUTF16( |
191 IDS_BOOKMARK_BAR_SHOULD_OPEN_ALL, | 191 IDS_BOOKMARK_BAR_SHOULD_OPEN_ALL, |
192 base::IntToString16(child_count)); | 192 base::IntToString16(child_count)); |
193 string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 193 string16 title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
194 return platform_util::SimpleYesNoBox(parent, title, message); | 194 return browser::ShowYesNoBox(parent, title, message); |
195 } | 195 } |
196 | 196 |
197 // Comparison function that compares based on date modified of the two nodes. | 197 // Comparison function that compares based on date modified of the two nodes. |
198 bool MoreRecentlyModified(const BookmarkNode* n1, const BookmarkNode* n2) { | 198 bool MoreRecentlyModified(const BookmarkNode* n1, const BookmarkNode* n2) { |
199 return n1->date_folder_modified() > n2->date_folder_modified(); | 199 return n1->date_folder_modified() > n2->date_folder_modified(); |
200 } | 200 } |
201 | 201 |
202 // Returns true if |text| contains each string in |words|. This is used when | 202 // Returns true if |text| contains each string in |words|. This is used when |
203 // searching for bookmarks. | 203 // searching for bookmarks. |
204 bool DoesBookmarkTextContainWords(const string16& text, | 204 bool DoesBookmarkTextContainWords(const string16& text, |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 for (int i = 0; i < node->child_count(); ++i) { | 724 for (int i = 0; i < node->child_count(); ++i) { |
725 if (NodeHasURLs(node->GetChild(i))) | 725 if (NodeHasURLs(node->GetChild(i))) |
726 return true; | 726 return true; |
727 } | 727 } |
728 return false; | 728 return false; |
729 } | 729 } |
730 | 730 |
731 bool ConfirmDeleteBookmarkNode(const BookmarkNode* node, | 731 bool ConfirmDeleteBookmarkNode(const BookmarkNode* node, |
732 gfx::NativeWindow window) { | 732 gfx::NativeWindow window) { |
733 DCHECK(node && node->is_folder() && !node->empty()); | 733 DCHECK(node && node->is_folder() && !node->empty()); |
734 return platform_util::SimpleYesNoBox(window, | 734 return browser::ShowYesNoBox(window, |
735 l10n_util::GetStringUTF16(IDS_DELETE), | 735 l10n_util::GetStringUTF16(IDS_DELETE), |
736 l10n_util::GetStringFUTF16Int(IDS_BOOMARK_EDITOR_CONFIRM_DELETE, | 736 l10n_util::GetStringFUTF16Int(IDS_BOOMARK_EDITOR_CONFIRM_DELETE, |
737 ChildURLCountTotal(node))); | 737 ChildURLCountTotal(node))); |
738 } | 738 } |
739 | 739 |
740 void DeleteBookmarkFolders(BookmarkModel* model, | 740 void DeleteBookmarkFolders(BookmarkModel* model, |
741 const std::vector<int64>& ids) { | 741 const std::vector<int64>& ids) { |
742 // Remove the folders that were removed. This has to be done after all the | 742 // Remove the folders that were removed. This has to be done after all the |
743 // other changes have been committed. | 743 // other changes have been committed. |
744 for (std::vector<int64>::const_iterator iter = ids.begin(); | 744 for (std::vector<int64>::const_iterator iter = ids.begin(); |
745 iter != ids.end(); | 745 iter != ids.end(); |
746 ++iter) { | 746 ++iter) { |
747 const BookmarkNode* node = model->GetNodeByID(*iter); | 747 const BookmarkNode* node = model->GetNodeByID(*iter); |
748 if (!node) | 748 if (!node) |
749 continue; | 749 continue; |
750 const BookmarkNode* parent = node->parent(); | 750 const BookmarkNode* parent = node->parent(); |
751 model->Remove(parent, parent->GetIndexOf(node)); | 751 model->Remove(parent, parent->GetIndexOf(node)); |
752 } | 752 } |
753 } | 753 } |
754 | 754 |
755 } // namespace bookmark_utils | 755 } // namespace bookmark_utils |
OLD | NEW |