OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/bookmarks/bookmark_drag_data.h" | 10 #include "chrome/browser/bookmarks/bookmark_drag_data.h" |
11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
12 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
13 #include "chrome/browser/browser_list.h" | 13 #include "chrome/browser/browser_list.h" |
14 #include "chrome/browser/history/query_parser.h" | 14 #include "chrome/browser/history/query_parser.h" |
15 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
16 #include "chrome/browser/tab_contents/page_navigator.h" | 16 #include "chrome/browser/tab_contents/page_navigator.h" |
17 #include "chrome/common/drag_drop_types.h" | 17 #include "chrome/common/drag_drop_types.h" |
18 #include "chrome/common/l10n_util.h" | 18 #include "chrome/common/l10n_util.h" |
| 19 #include "chrome/common/notification_service.h" |
| 20 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/common/pref_service.h" |
19 #include "chrome/views/controls/tree/tree_node_iterator.h" | 22 #include "chrome/views/controls/tree/tree_node_iterator.h" |
20 #include "chrome/views/event.h" | 23 #include "chrome/views/event.h" |
21 #include "grit/chromium_strings.h" | 24 #include "grit/chromium_strings.h" |
22 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
23 | 26 |
24 // TODO(port): Port these files. | 27 // TODO(port): Port these files. |
25 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
26 #include "chrome/browser/tab_contents/tab_contents.h" | 29 #include "chrome/browser/tab_contents/tab_contents.h" |
27 #include "chrome/common/os_exchange_data.h" | 30 #include "chrome/common/os_exchange_data.h" |
28 #else | 31 #else |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 bool DoesBookmarkContainText(BookmarkNode* node, const std::wstring& text) { | 525 bool DoesBookmarkContainText(BookmarkNode* node, const std::wstring& text) { |
523 std::vector<std::wstring> words; | 526 std::vector<std::wstring> words; |
524 QueryParser parser; | 527 QueryParser parser; |
525 parser.ExtractQueryWords(l10n_util::ToLower(text), &words); | 528 parser.ExtractQueryWords(l10n_util::ToLower(text), &words); |
526 if (words.empty()) | 529 if (words.empty()) |
527 return false; | 530 return false; |
528 | 531 |
529 return (node->is_url() && DoesBookmarkContainWords(node, words)); | 532 return (node->is_url() && DoesBookmarkContainWords(node, words)); |
530 } | 533 } |
531 | 534 |
| 535 // Formerly in BookmarkBarView |
| 536 void ToggleWhenVisible(Profile* profile) { |
| 537 PrefService* prefs = profile->GetPrefs(); |
| 538 const bool always_show = !prefs->GetBoolean(prefs::kShowBookmarkBar); |
| 539 |
| 540 // The user changed when the bookmark bar is shown, update the preferences. |
| 541 prefs->SetBoolean(prefs::kShowBookmarkBar, always_show); |
| 542 prefs->ScheduleSavePersistentPrefs(g_browser_process->file_thread()); |
| 543 |
| 544 // And notify the notification service. |
| 545 Source<Profile> source(profile); |
| 546 NotificationService::current()->Notify( |
| 547 NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, |
| 548 source, |
| 549 NotificationService::NoDetails()); |
| 550 } |
| 551 |
| 552 void RegisterUserPrefs(PrefService* prefs) { |
| 553 // Formerly in BookmarkBarView |
| 554 prefs->RegisterBooleanPref(prefs::kShowBookmarkBar, false); |
| 555 |
| 556 // Formerly in BookmarkTableView |
| 557 prefs->RegisterIntegerPref(prefs::kBookmarkTableNameWidth1, -1); |
| 558 prefs->RegisterIntegerPref(prefs::kBookmarkTableURLWidth1, -1); |
| 559 prefs->RegisterIntegerPref(prefs::kBookmarkTableNameWidth2, -1); |
| 560 prefs->RegisterIntegerPref(prefs::kBookmarkTableURLWidth2, -1); |
| 561 prefs->RegisterIntegerPref(prefs::kBookmarkTablePathWidth, -1); |
| 562 } |
| 563 |
532 } // namespace bookmark_utils | 564 } // namespace bookmark_utils |
OLD | NEW |