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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 return true; | 845 return true; |
846 } | 846 } |
847 | 847 |
848 bool BookmarkBarView::AreDropTypesRequired() { | 848 bool BookmarkBarView::AreDropTypesRequired() { |
849 return true; | 849 return true; |
850 } | 850 } |
851 | 851 |
852 bool BookmarkBarView::CanDrop(const ui::OSExchangeData& data) { | 852 bool BookmarkBarView::CanDrop(const ui::OSExchangeData& data) { |
853 if (!model_ || !model_->loaded() || | 853 if (!model_ || !model_->loaded() || |
854 !browser_->profile()->GetPrefs()->GetBoolean( | 854 !browser_->profile()->GetPrefs()->GetBoolean( |
855 prefs::kEditBookmarksEnabled)) | 855 bookmarks::prefs::kEditBookmarksEnabled)) |
856 return false; | 856 return false; |
857 | 857 |
858 if (!drop_info_.get()) | 858 if (!drop_info_.get()) |
859 drop_info_.reset(new DropInfo()); | 859 drop_info_.reset(new DropInfo()); |
860 | 860 |
861 // Only accept drops of 1 node, which is the case for all data dragged from | 861 // Only accept drops of 1 node, which is the case for all data dragged from |
862 // bookmark bar and menus. | 862 // bookmark bar and menus. |
863 return drop_info_->data.Read(data) && drop_info_->data.size() == 1; | 863 return drop_info_->data.Read(data) && drop_info_->data.size() == 1; |
864 } | 864 } |
865 | 865 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 | 1345 |
1346 managed_bookmarks_button_ = CreateManagedBookmarksButton(); | 1346 managed_bookmarks_button_ = CreateManagedBookmarksButton(); |
1347 // Also re-enabled when the model is loaded. | 1347 // Also re-enabled when the model is loaded. |
1348 managed_bookmarks_button_->SetEnabled(false); | 1348 managed_bookmarks_button_->SetEnabled(false); |
1349 AddChildView(managed_bookmarks_button_); | 1349 AddChildView(managed_bookmarks_button_); |
1350 | 1350 |
1351 apps_page_shortcut_ = CreateAppsPageShortcutButton(); | 1351 apps_page_shortcut_ = CreateAppsPageShortcutButton(); |
1352 AddChildView(apps_page_shortcut_); | 1352 AddChildView(apps_page_shortcut_); |
1353 profile_pref_registrar_.Init(browser_->profile()->GetPrefs()); | 1353 profile_pref_registrar_.Init(browser_->profile()->GetPrefs()); |
1354 profile_pref_registrar_.Add( | 1354 profile_pref_registrar_.Add( |
1355 prefs::kShowAppsShortcutInBookmarkBar, | 1355 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
1356 base::Bind(&BookmarkBarView::OnAppsPageShortcutVisibilityPrefChanged, | 1356 base::Bind(&BookmarkBarView::OnAppsPageShortcutVisibilityPrefChanged, |
1357 base::Unretained(this))); | 1357 base::Unretained(this))); |
1358 profile_pref_registrar_.Add( | 1358 profile_pref_registrar_.Add( |
1359 prefs::kShowManagedBookmarksInBookmarkBar, | 1359 bookmarks::prefs::kShowManagedBookmarksInBookmarkBar, |
1360 base::Bind(&BookmarkBarView::UpdateButtonsVisibility, | 1360 base::Bind(&BookmarkBarView::UpdateButtonsVisibility, |
1361 base::Unretained(this))); | 1361 base::Unretained(this))); |
1362 apps_page_shortcut_->SetVisible( | 1362 apps_page_shortcut_->SetVisible( |
1363 chrome::ShouldShowAppsShortcutInBookmarkBar( | 1363 chrome::ShouldShowAppsShortcutInBookmarkBar( |
1364 browser_->profile(), browser_->host_desktop_type())); | 1364 browser_->profile(), browser_->host_desktop_type())); |
1365 | 1365 |
1366 bookmarks_separator_view_ = new ButtonSeparatorView(); | 1366 bookmarks_separator_view_ = new ButtonSeparatorView(); |
1367 AddChildView(bookmarks_separator_view_); | 1367 AddChildView(bookmarks_separator_view_); |
1368 UpdateBookmarksSeparatorVisibility(); | 1368 UpdateBookmarksSeparatorVisibility(); |
1369 | 1369 |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 void BookmarkBarView::UpdateButtonsVisibility() { | 1817 void BookmarkBarView::UpdateButtonsVisibility() { |
1818 bool has_other_children = !model_->other_node()->empty(); | 1818 bool has_other_children = !model_->other_node()->empty(); |
1819 bool update_other = has_other_children != other_bookmarked_button_->visible(); | 1819 bool update_other = has_other_children != other_bookmarked_button_->visible(); |
1820 if (update_other) { | 1820 if (update_other) { |
1821 other_bookmarked_button_->SetVisible(has_other_children); | 1821 other_bookmarked_button_->SetVisible(has_other_children); |
1822 UpdateBookmarksSeparatorVisibility(); | 1822 UpdateBookmarksSeparatorVisibility(); |
1823 } | 1823 } |
1824 | 1824 |
1825 bool show_managed = !client_->managed_node()->empty() && | 1825 bool show_managed = !client_->managed_node()->empty() && |
1826 browser_->profile()->GetPrefs()->GetBoolean( | 1826 browser_->profile()->GetPrefs()->GetBoolean( |
1827 prefs::kShowManagedBookmarksInBookmarkBar); | 1827 bookmarks::prefs::kShowManagedBookmarksInBookmarkBar); |
1828 bool update_managed = show_managed != managed_bookmarks_button_->visible(); | 1828 bool update_managed = show_managed != managed_bookmarks_button_->visible(); |
1829 if (update_managed) | 1829 if (update_managed) |
1830 managed_bookmarks_button_->SetVisible(show_managed); | 1830 managed_bookmarks_button_->SetVisible(show_managed); |
1831 | 1831 |
1832 if (update_other || update_managed) { | 1832 if (update_other || update_managed) { |
1833 Layout(); | 1833 Layout(); |
1834 SchedulePaint(); | 1834 SchedulePaint(); |
1835 } | 1835 } |
1836 } | 1836 } |
1837 | 1837 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1956 DCHECK(apps_page_shortcut_); | 1956 DCHECK(apps_page_shortcut_); |
1957 // Only perform layout if required. | 1957 // Only perform layout if required. |
1958 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( | 1958 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( |
1959 browser_->profile(), browser_->host_desktop_type()); | 1959 browser_->profile(), browser_->host_desktop_type()); |
1960 if (apps_page_shortcut_->visible() == visible) | 1960 if (apps_page_shortcut_->visible() == visible) |
1961 return; | 1961 return; |
1962 apps_page_shortcut_->SetVisible(visible); | 1962 apps_page_shortcut_->SetVisible(visible); |
1963 UpdateBookmarksSeparatorVisibility(); | 1963 UpdateBookmarksSeparatorVisibility(); |
1964 Layout(); | 1964 Layout(); |
1965 } | 1965 } |
OLD | NEW |