| 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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 } | 793 } |
| 794 const BookmarkNodeData data = drop_info_->data; | 794 const BookmarkNodeData data = drop_info_->data; |
| 795 DCHECK(data.is_valid()); | 795 DCHECK(data.is_valid()); |
| 796 drop_info_.reset(); | 796 drop_info_.reset(); |
| 797 return bookmark_utils::PerformBookmarkDrop(browser_->profile(), data, | 797 return bookmark_utils::PerformBookmarkDrop(browser_->profile(), data, |
| 798 parent_node, index); | 798 parent_node, index); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void BookmarkBarView::ShowContextMenu(const gfx::Point& p, | 801 void BookmarkBarView::ShowContextMenu(const gfx::Point& p, |
| 802 bool is_mouse_gesture) { | 802 bool is_mouse_gesture) { |
| 803 ShowContextMenuForView(this, p, is_mouse_gesture); | 803 ShowContextMenuForView(this, p); |
| 804 } | 804 } |
| 805 | 805 |
| 806 void BookmarkBarView::OnThemeChanged() { | 806 void BookmarkBarView::OnThemeChanged() { |
| 807 UpdateColors(); | 807 UpdateColors(); |
| 808 } | 808 } |
| 809 | 809 |
| 810 std::string BookmarkBarView::GetClassName() const { | 810 std::string BookmarkBarView::GetClassName() const { |
| 811 return kViewClassName; | 811 return kViewClassName; |
| 812 } | 812 } |
| 813 | 813 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 bookmark_utils::OpenAll(GetWidget()->GetNativeWindow(), profile, | 1042 bookmark_utils::OpenAll(GetWidget()->GetNativeWindow(), profile, |
| 1043 page_navigator_, node, disposition_from_event_flags); | 1043 page_navigator_, node, disposition_from_event_flags); |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 bookmark_utils::RecordBookmarkLaunch(IsDetached() ? | 1046 bookmark_utils::RecordBookmarkLaunch(IsDetached() ? |
| 1047 bookmark_utils::LAUNCH_DETACHED_BAR : | 1047 bookmark_utils::LAUNCH_DETACHED_BAR : |
| 1048 bookmark_utils::LAUNCH_ATTACHED_BAR); | 1048 bookmark_utils::LAUNCH_ATTACHED_BAR); |
| 1049 content::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); | 1049 content::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 void BookmarkBarView::ShowContextMenuForView(View* source, | 1052 void BookmarkBarView::ShowContextMenuForView(views::View* source, |
| 1053 const gfx::Point& p, | 1053 const gfx::Point& point) { |
| 1054 bool is_mouse_gesture) { | |
| 1055 if (!model_->IsLoaded()) { | 1054 if (!model_->IsLoaded()) { |
| 1056 // Don't do anything if the model isn't loaded. | 1055 // Don't do anything if the model isn't loaded. |
| 1057 return; | 1056 return; |
| 1058 } | 1057 } |
| 1059 | 1058 |
| 1060 const BookmarkNode* parent = NULL; | 1059 const BookmarkNode* parent = NULL; |
| 1061 std::vector<const BookmarkNode*> nodes; | 1060 std::vector<const BookmarkNode*> nodes; |
| 1062 if (source == other_bookmarked_button_) { | 1061 if (source == other_bookmarked_button_) { |
| 1063 parent = model_->other_node(); | 1062 parent = model_->other_node(); |
| 1064 // Do this so the user can open all bookmarks. BookmarkContextMenu makes | 1063 // Do this so the user can open all bookmarks. BookmarkContextMenu makes |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1077 } else { | 1076 } else { |
| 1078 parent = model_->bookmark_bar_node(); | 1077 parent = model_->bookmark_bar_node(); |
| 1079 nodes.push_back(parent); | 1078 nodes.push_back(parent); |
| 1080 } | 1079 } |
| 1081 Profile* profile = browser_->profile(); | 1080 Profile* profile = browser_->profile(); |
| 1082 bool close_on_remove = | 1081 bool close_on_remove = |
| 1083 (parent == profile->GetBookmarkModel()->other_node()) && | 1082 (parent == profile->GetBookmarkModel()->other_node()) && |
| 1084 (parent->child_count() == 1); | 1083 (parent->child_count() == 1); |
| 1085 context_menu_.reset(new BookmarkContextMenu(GetWidget(), profile, | 1084 context_menu_.reset(new BookmarkContextMenu(GetWidget(), profile, |
| 1086 browser_->GetSelectedWebContents(), parent, nodes, close_on_remove)); | 1085 browser_->GetSelectedWebContents(), parent, nodes, close_on_remove)); |
| 1087 context_menu_->RunMenuAt(p); | 1086 context_menu_->RunMenuAt(point); |
| 1088 } | 1087 } |
| 1089 | 1088 |
| 1090 void BookmarkBarView::Observe(int type, | 1089 void BookmarkBarView::Observe(int type, |
| 1091 const content::NotificationSource& source, | 1090 const content::NotificationSource& source, |
| 1092 const content::NotificationDetails& details) { | 1091 const content::NotificationDetails& details) { |
| 1093 DCHECK(browser_->profile()); | 1092 DCHECK(browser_->profile()); |
| 1094 switch (type) { | 1093 switch (type) { |
| 1095 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { | 1094 case chrome::NOTIFICATION_BOOKMARK_BUBBLE_SHOWN: { |
| 1096 StopThrobbing(true); | 1095 StopThrobbing(true); |
| 1097 GURL url = *(content::Details<GURL>(details).ptr()); | 1096 GURL url = *(content::Details<GURL>(details).ptr()); |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 (1 - size_animation_->GetCurrentValue()))); | 1662 (1 - size_animation_->GetCurrentValue()))); |
| 1664 } else { | 1663 } else { |
| 1665 prefsize.set_height( | 1664 prefsize.set_height( |
| 1666 static_cast<int>( | 1665 static_cast<int>( |
| 1667 browser_defaults::kBookmarkBarHeight * | 1666 browser_defaults::kBookmarkBarHeight * |
| 1668 size_animation_->GetCurrentValue())); | 1667 size_animation_->GetCurrentValue())); |
| 1669 } | 1668 } |
| 1670 } | 1669 } |
| 1671 return prefsize; | 1670 return prefsize; |
| 1672 } | 1671 } |
| OLD | NEW |