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/i18n/string_search.h" | 12 #include "base/i18n/string_search.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.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_node_data.h" | 18 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
19 #include "chrome/browser/history/query_parser.h" | 19 #include "chrome/browser/history/query_parser.h" |
20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/simple_message_box.h" | 22 #include "chrome/browser/simple_message_box.h" |
23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
25 #include "chrome/browser/ui/browser_window.h" | 25 #include "chrome/browser/ui/browser_window.h" |
26 #include "chrome/common/chrome_notification_types.h" | |
27 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
28 #include "content/browser/tab_contents/page_navigator.h" | 27 #include "content/browser/tab_contents/page_navigator.h" |
29 #include "content/browser/tab_contents/tab_contents.h" | 28 #include "content/browser/tab_contents/tab_contents.h" |
30 #include "content/common/notification_service.h" | |
31 #include "grit/chromium_strings.h" | 29 #include "grit/chromium_strings.h" |
32 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
33 #include "grit/ui_strings.h" | 31 #include "grit/ui_strings.h" |
34 #include "net/base/net_util.h" | 32 #include "net/base/net_util.h" |
35 #include "ui/base/dragdrop/drag_drop_types.h" | 33 #include "ui/base/dragdrop/drag_drop_types.h" |
36 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
37 #include "ui/base/models/tree_node_iterator.h" | 35 #include "ui/base/models/tree_node_iterator.h" |
38 | 36 |
39 #if defined(OS_MACOSX) | 37 #if defined(OS_MACOSX) |
40 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" | 38 #include "chrome/browser/bookmarks/bookmark_pasteboard_helper_mac.h" |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 } | 634 } |
637 | 635 |
638 // Formerly in BookmarkBarView | 636 // Formerly in BookmarkBarView |
639 void ToggleWhenVisible(Profile* profile) { | 637 void ToggleWhenVisible(Profile* profile) { |
640 PrefService* prefs = profile->GetPrefs(); | 638 PrefService* prefs = profile->GetPrefs(); |
641 const bool always_show = !prefs->GetBoolean(prefs::kShowBookmarkBar); | 639 const bool always_show = !prefs->GetBoolean(prefs::kShowBookmarkBar); |
642 | 640 |
643 // The user changed when the bookmark bar is shown, update the preferences. | 641 // The user changed when the bookmark bar is shown, update the preferences. |
644 prefs->SetBoolean(prefs::kShowBookmarkBar, always_show); | 642 prefs->SetBoolean(prefs::kShowBookmarkBar, always_show); |
645 prefs->ScheduleSavePersistentPrefs(); | 643 prefs->ScheduleSavePersistentPrefs(); |
646 | |
647 // And notify the notification service. | |
648 Source<Profile> source(profile); | |
649 NotificationService::current()->Notify( | |
650 chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, | |
651 source, | |
652 NotificationService::NoDetails()); | |
653 } | 644 } |
654 | 645 |
655 void RegisterUserPrefs(PrefService* prefs) { | 646 void RegisterUserPrefs(PrefService* prefs) { |
656 prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, | 647 prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, |
657 false, | 648 false, |
658 PrefService::SYNCABLE_PREF); | 649 PrefService::SYNCABLE_PREF); |
659 prefs->RegisterBooleanPref(prefs::kEditBookmarksEnabled, | 650 prefs->RegisterBooleanPref(prefs::kEditBookmarksEnabled, |
660 true, | 651 true, |
661 PrefService::UNSYNCABLE_PREF); | 652 PrefService::UNSYNCABLE_PREF); |
662 } | 653 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 // Remove all the bookmarks. | 761 // Remove all the bookmarks. |
771 for (size_t i = 0; i < bookmarks.size(); ++i) { | 762 for (size_t i = 0; i < bookmarks.size(); ++i) { |
772 const BookmarkNode* node = bookmarks[i]; | 763 const BookmarkNode* node = bookmarks[i]; |
773 int index = node->parent()->GetIndexOf(node); | 764 int index = node->parent()->GetIndexOf(node); |
774 if (index > -1) | 765 if (index > -1) |
775 model->Remove(node->parent(), index); | 766 model->Remove(node->parent(), index); |
776 } | 767 } |
777 } | 768 } |
778 | 769 |
779 } // namespace bookmark_utils | 770 } // namespace bookmark_utils |
OLD | NEW |