| 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> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "ui/base/l10n/l10n_util.h" | 68 #include "ui/base/l10n/l10n_util.h" |
| 69 #include "ui/base/resource/resource_bundle.h" | 69 #include "ui/base/resource/resource_bundle.h" |
| 70 #include "ui/base/theme_provider.h" | 70 #include "ui/base/theme_provider.h" |
| 71 #include "ui/base/window_open_disposition.h" | 71 #include "ui/base/window_open_disposition.h" |
| 72 #include "ui/gfx/animation/slide_animation.h" | 72 #include "ui/gfx/animation/slide_animation.h" |
| 73 #include "ui/gfx/canvas.h" | 73 #include "ui/gfx/canvas.h" |
| 74 #include "ui/gfx/text_elider.h" | 74 #include "ui/gfx/text_elider.h" |
| 75 #include "ui/views/button_drag_utils.h" | 75 #include "ui/views/button_drag_utils.h" |
| 76 #include "ui/views/controls/button/menu_button.h" | 76 #include "ui/views/controls/button/menu_button.h" |
| 77 #include "ui/views/controls/label.h" | 77 #include "ui/views/controls/label.h" |
| 78 #include "ui/views/controls/menu/menu_item_view.h" | |
| 79 #include "ui/views/drag_utils.h" | 78 #include "ui/views/drag_utils.h" |
| 80 #include "ui/views/metrics.h" | 79 #include "ui/views/metrics.h" |
| 81 #include "ui/views/view_constants.h" | 80 #include "ui/views/view_constants.h" |
| 82 #include "ui/views/widget/tooltip_manager.h" | 81 #include "ui/views/widget/tooltip_manager.h" |
| 83 #include "ui/views/widget/widget.h" | 82 #include "ui/views/widget/widget.h" |
| 84 #include "ui/views/window/non_client_view.h" | 83 #include "ui/views/window/non_client_view.h" |
| 85 | 84 |
| 86 using base::UserMetricsAction; | 85 using base::UserMetricsAction; |
| 87 using content::OpenURLParams; | 86 using content::OpenURLParams; |
| 88 using content::PageNavigator; | 87 using content::PageNavigator; |
| 89 using content::Referrer; | 88 using content::Referrer; |
| 90 using ui::DropTargetEvent; | 89 using ui::DropTargetEvent; |
| 91 using views::CustomButton; | 90 using views::CustomButton; |
| 92 using views::MenuButton; | 91 using views::MenuButton; |
| 93 using views::MenuItemView; | |
| 94 using views::View; | 92 using views::View; |
| 95 | 93 |
| 96 // Margins around the content. | 94 // Margins around the content. |
| 97 static const int kDetachedTopMargin = 1; // When attached, we use 0 and let the | 95 static const int kDetachedTopMargin = 1; // When attached, we use 0 and let the |
| 98 // toolbar above serve as the margin. | 96 // toolbar above serve as the margin. |
| 99 static const int kBottomMargin = 2; | 97 static const int kBottomMargin = 2; |
| 100 static const int kLeftMargin = 1; | 98 static const int kLeftMargin = 1; |
| 101 static const int kRightMargin = 1; | 99 static const int kRightMargin = 1; |
| 102 | 100 |
| 103 // static | 101 // static |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 if (node == model_->bookmark_bar_node()) | 558 if (node == model_->bookmark_bar_node()) |
| 561 return overflow_button_; | 559 return overflow_button_; |
| 562 int index = model_->bookmark_bar_node()->GetIndexOf(node); | 560 int index = model_->bookmark_bar_node()->GetIndexOf(node); |
| 563 if (index == -1 || !node->is_folder()) | 561 if (index == -1 || !node->is_folder()) |
| 564 return NULL; | 562 return NULL; |
| 565 return static_cast<views::MenuButton*>(child_at(index)); | 563 return static_cast<views::MenuButton*>(child_at(index)); |
| 566 } | 564 } |
| 567 | 565 |
| 568 void BookmarkBarView::GetAnchorPositionForButton( | 566 void BookmarkBarView::GetAnchorPositionForButton( |
| 569 views::MenuButton* button, | 567 views::MenuButton* button, |
| 570 MenuItemView::AnchorPosition* anchor) { | 568 ui::MenuAnchorPosition* anchor) { |
| 571 if (button == other_bookmarked_button_ || button == overflow_button_) | 569 if (button == other_bookmarked_button_ || button == overflow_button_) |
| 572 *anchor = MenuItemView::TOPRIGHT; | 570 *anchor = ui::MENU_ANCHOR_TOPRIGHT; |
| 573 else | 571 else |
| 574 *anchor = MenuItemView::TOPLEFT; | 572 *anchor = ui::MENU_ANCHOR_TOPLEFT; |
| 575 } | 573 } |
| 576 | 574 |
| 577 views::MenuItemView* BookmarkBarView::GetMenu() { | 575 views::MenuItemView* BookmarkBarView::GetMenu() { |
| 578 return bookmark_menu_ ? bookmark_menu_->menu() : NULL; | 576 return bookmark_menu_ ? bookmark_menu_->menu() : NULL; |
| 579 } | 577 } |
| 580 | 578 |
| 581 views::MenuItemView* BookmarkBarView::GetContextMenu() { | 579 views::MenuItemView* BookmarkBarView::GetContextMenu() { |
| 582 return bookmark_menu_ ? bookmark_menu_->context_menu() : NULL; | 580 return bookmark_menu_ ? bookmark_menu_->context_menu() : NULL; |
| 583 } | 581 } |
| 584 | 582 |
| (...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 DCHECK(apps_page_shortcut_); | 1850 DCHECK(apps_page_shortcut_); |
| 1853 // Only perform layout if required. | 1851 // Only perform layout if required. |
| 1854 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( | 1852 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( |
| 1855 browser_->profile(), browser_->host_desktop_type()); | 1853 browser_->profile(), browser_->host_desktop_type()); |
| 1856 if (apps_page_shortcut_->visible() == visible) | 1854 if (apps_page_shortcut_->visible() == visible) |
| 1857 return; | 1855 return; |
| 1858 apps_page_shortcut_->SetVisible(visible); | 1856 apps_page_shortcut_->SetVisible(visible); |
| 1859 UpdateBookmarksSeparatorVisibility(); | 1857 UpdateBookmarksSeparatorVisibility(); |
| 1860 Layout(); | 1858 Layout(); |
| 1861 } | 1859 } |
| OLD | NEW |