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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 profile_pref_registrar_.Init(browser_->profile()->GetPrefs()); | 1550 profile_pref_registrar_.Init(browser_->profile()->GetPrefs()); |
1551 profile_pref_registrar_.Add( | 1551 profile_pref_registrar_.Add( |
1552 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 1552 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
1553 base::Bind(&BookmarkBarView::OnAppsPageShortcutVisibilityPrefChanged, | 1553 base::Bind(&BookmarkBarView::OnAppsPageShortcutVisibilityPrefChanged, |
1554 base::Unretained(this))); | 1554 base::Unretained(this))); |
1555 profile_pref_registrar_.Add( | 1555 profile_pref_registrar_.Add( |
1556 bookmarks::prefs::kShowManagedBookmarksInBookmarkBar, | 1556 bookmarks::prefs::kShowManagedBookmarksInBookmarkBar, |
1557 base::Bind(&BookmarkBarView::OnShowManagedBookmarksPrefChanged, | 1557 base::Bind(&BookmarkBarView::OnShowManagedBookmarksPrefChanged, |
1558 base::Unretained(this))); | 1558 base::Unretained(this))); |
1559 apps_page_shortcut_->SetVisible( | 1559 apps_page_shortcut_->SetVisible( |
1560 chrome::ShouldShowAppsShortcutInBookmarkBar( | 1560 chrome::ShouldShowAppsShortcutInBookmarkBar(browser_->profile())); |
1561 browser_->profile(), browser_->host_desktop_type())); | |
1562 | 1561 |
1563 bookmarks_separator_view_ = new ButtonSeparatorView(); | 1562 bookmarks_separator_view_ = new ButtonSeparatorView(); |
1564 AddChildView(bookmarks_separator_view_); | 1563 AddChildView(bookmarks_separator_view_); |
1565 UpdateBookmarksSeparatorVisibility(); | 1564 UpdateBookmarksSeparatorVisibility(); |
1566 | 1565 |
1567 instructions_ = new BookmarkBarInstructionsView(this); | 1566 instructions_ = new BookmarkBarInstructionsView(this); |
1568 AddChildView(instructions_); | 1567 AddChildView(instructions_); |
1569 | 1568 |
1570 set_context_menu_controller(this); | 1569 set_context_menu_controller(this); |
1571 | 1570 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2053 // Ash does not paint the bookmarks separator line because it looks odd on | 2052 // Ash does not paint the bookmarks separator line because it looks odd on |
2054 // the flat background. We keep it present for layout, but don't draw it. | 2053 // the flat background. We keep it present for layout, but don't draw it. |
2055 bookmarks_separator_view_->SetVisible( | 2054 bookmarks_separator_view_->SetVisible( |
2056 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH && | 2055 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH && |
2057 other_bookmarks_button_->visible()); | 2056 other_bookmarks_button_->visible()); |
2058 } | 2057 } |
2059 | 2058 |
2060 void BookmarkBarView::OnAppsPageShortcutVisibilityPrefChanged() { | 2059 void BookmarkBarView::OnAppsPageShortcutVisibilityPrefChanged() { |
2061 DCHECK(apps_page_shortcut_); | 2060 DCHECK(apps_page_shortcut_); |
2062 // Only perform layout if required. | 2061 // Only perform layout if required. |
2063 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( | 2062 bool visible = |
2064 browser_->profile(), browser_->host_desktop_type()); | 2063 chrome::ShouldShowAppsShortcutInBookmarkBar(browser_->profile()); |
2065 if (apps_page_shortcut_->visible() == visible) | 2064 if (apps_page_shortcut_->visible() == visible) |
2066 return; | 2065 return; |
2067 apps_page_shortcut_->SetVisible(visible); | 2066 apps_page_shortcut_->SetVisible(visible); |
2068 UpdateBookmarksSeparatorVisibility(); | 2067 UpdateBookmarksSeparatorVisibility(); |
2069 LayoutAndPaint(); | 2068 LayoutAndPaint(); |
2070 } | 2069 } |
2071 | 2070 |
2072 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { | 2071 void BookmarkBarView::OnShowManagedBookmarksPrefChanged() { |
2073 if (UpdateOtherAndManagedButtonsVisibility()) | 2072 if (UpdateOtherAndManagedButtonsVisibility()) |
2074 LayoutAndPaint(); | 2073 LayoutAndPaint(); |
2075 } | 2074 } |
OLD | NEW |