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" | |
22 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
23 #include "chrome/browser/defaults.h" | 22 #include "chrome/browser/defaults.h" |
24 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/search/search.h" | 25 #include "chrome/browser/search/search.h" |
27 #include "chrome/browser/sync/profile_sync_service.h" | 26 #include "chrome/browser/sync/profile_sync_service.h" |
28 #include "chrome/browser/sync/profile_sync_service_factory.h" | 27 #include "chrome/browser/sync/profile_sync_service_factory.h" |
29 #include "chrome/browser/themes/theme_properties.h" | 28 #include "chrome/browser/themes/theme_properties.h" |
30 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" | 29 #include "chrome/browser/ui/bookmarks/bookmark_bar_constants.h" |
31 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" | 30 #include "chrome/browser/ui/bookmarks/bookmark_drag_drop.h" |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 other_bookmarked_button_->SetText(model_->other_node()->GetTitle()); | 987 other_bookmarked_button_->SetText(model_->other_node()->GetTitle()); |
989 UpdateColors(); | 988 UpdateColors(); |
990 UpdateOtherBookmarksVisibility(); | 989 UpdateOtherBookmarksVisibility(); |
991 other_bookmarked_button_->SetEnabled(true); | 990 other_bookmarked_button_->SetEnabled(true); |
992 | 991 |
993 Layout(); | 992 Layout(); |
994 SchedulePaint(); | 993 SchedulePaint(); |
995 } | 994 } |
996 | 995 |
997 void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkModel* model) { | 996 void BookmarkBarView::BookmarkModelBeingDeleted(BookmarkModel* model) { |
998 // In normal shutdown The bookmark model should never be deleted before us. | 997 NOTREACHED(); |
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 | |
1004 // Do minimal cleanup, presumably we'll be deleted shortly. | 998 // Do minimal cleanup, presumably we'll be deleted shortly. |
1005 model_->RemoveObserver(this); | 999 model_->RemoveObserver(this); |
1006 model_ = NULL; | 1000 model_ = NULL; |
1007 } | 1001 } |
1008 | 1002 |
1009 void BookmarkBarView::BookmarkNodeMoved(BookmarkModel* model, | 1003 void BookmarkBarView::BookmarkNodeMoved(BookmarkModel* model, |
1010 const BookmarkNode* old_parent, | 1004 const BookmarkNode* old_parent, |
1011 int old_index, | 1005 int old_index, |
1012 const BookmarkNode* new_parent, | 1006 const BookmarkNode* new_parent, |
1013 int new_index) { | 1007 int new_index) { |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 DCHECK(apps_page_shortcut_); | 1849 DCHECK(apps_page_shortcut_); |
1856 // Only perform layout if required. | 1850 // Only perform layout if required. |
1857 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( | 1851 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( |
1858 browser_->profile(), browser_->host_desktop_type()); | 1852 browser_->profile(), browser_->host_desktop_type()); |
1859 if (apps_page_shortcut_->visible() == visible) | 1853 if (apps_page_shortcut_->visible() == visible) |
1860 return; | 1854 return; |
1861 apps_page_shortcut_->SetVisible(visible); | 1855 apps_page_shortcut_->SetVisible(visible); |
1862 UpdateBookmarksSeparatorVisibility(); | 1856 UpdateBookmarksSeparatorVisibility(); |
1863 Layout(); | 1857 Layout(); |
1864 } | 1858 } |
OLD | NEW |