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/ui/views/bookmarks/bookmark_bar_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "chrome/browser/bookmarks/bookmark_model.h" | 18 #include "chrome/browser/bookmarks/bookmark_model.h" |
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/browser_shutdown.h" |
21 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
22 #include "chrome/browser/defaults.h" | 23 #include "chrome/browser/defaults.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/search/search.h" | 26 #include "chrome/browser/search/search.h" |
26 #include "chrome/browser/sync/profile_sync_service.h" | 27 #include "chrome/browser/sync/profile_sync_service.h" |
27 #include "chrome/browser/sync/profile_sync_service_factory.h" | 28 #include "chrome/browser/sync/profile_sync_service_factory.h" |
28 #include "chrome/browser/themes/theme_properties.h" | 29 #include "chrome/browser/themes/theme_properties.h" |
29 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" | 30 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" |
30 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" | 31 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 other_bookmarked_button_->SetText(model_->other_node()->GetTitle()); | 988 other_bookmarked_button_->SetText(model_->other_node()->GetTitle()); |
988 UpdateColors(); | 989 UpdateColors(); |
989 UpdateOtherBookmarksVisibility(); | 990 UpdateOtherBookmarksVisibility(); |
990 other_bookmarked_button_->SetEnabled(true); | 991 other_bookmarked_button_->SetEnabled(true); |
991 | 992 |
992 Layout(); | 993 Layout(); |
993 SchedulePaint(); | 994 SchedulePaint(); |
994 } | 995 } |
995 | 996 |
996 void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkModel* model) { | 997 void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkModel* model) { |
997 NOTREACHED(); | 998 // In normal shutdown The bookmark model should never be deleted before us. |
| 999 // When X exits suddenly though, it can happen, This code exists |
| 1000 // to check for regressions in shutdown code and not crash. |
| 1001 if (!browser_shutdown::ShuttingDownWithoutClosingBrowsers()) |
| 1002 NOTREACHED(); |
| 1003 |
998 // Do minimal cleanup, presumably we'll be deleted shortly. | 1004 // Do minimal cleanup, presumably we'll be deleted shortly. |
999 model_->RemoveObserver(this); | 1005 model_->RemoveObserver(this); |
1000 model_ = NULL; | 1006 model_ = NULL; |
1001 } | 1007 } |
1002 | 1008 |
1003 void BookmarkBarView::BookmarkNodeMoved(BookmarkModel* model, | 1009 void BookmarkBarView::BookmarkNodeMoved(BookmarkModel* model, |
1004 const BookmarkNode* old_parent, | 1010 const BookmarkNode* old_parent, |
1005 int old_index, | 1011 int old_index, |
1006 const BookmarkNode* new_parent, | 1012 const BookmarkNode* new_parent, |
1007 int new_index) { | 1013 int new_index) { |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1849 DCHECK(apps_page_shortcut_); | 1855 DCHECK(apps_page_shortcut_); |
1850 // Only perform layout if required. | 1856 // Only perform layout if required. |
1851 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( | 1857 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( |
1852 browser_->profile(), browser_->host_desktop_type()); | 1858 browser_->profile(), browser_->host_desktop_type()); |
1853 if (apps_page_shortcut_->visible() == visible) | 1859 if (apps_page_shortcut_->visible() == visible) |
1854 return; | 1860 return; |
1855 apps_page_shortcut_->SetVisible(visible); | 1861 apps_page_shortcut_->SetVisible(visible); |
1856 UpdateBookmarksSeparatorVisibility(); | 1862 UpdateBookmarksSeparatorVisibility(); |
1857 Layout(); | 1863 Layout(); |
1858 } | 1864 } |
OLD | NEW |