OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 } else if (view == overflow_button_) { | 1057 } else if (view == overflow_button_) { |
1058 node = model_->GetBookmarkBarNode(); | 1058 node = model_->GetBookmarkBarNode(); |
1059 start_index = GetFirstHiddenNodeIndex(); | 1059 start_index = GetFirstHiddenNodeIndex(); |
1060 } else { | 1060 } else { |
1061 int button_index = GetIndexOf(view); | 1061 int button_index = GetIndexOf(view); |
1062 DCHECK_NE(-1, button_index); | 1062 DCHECK_NE(-1, button_index); |
1063 node = model_->GetBookmarkBarNode()->GetChild(button_index); | 1063 node = model_->GetBookmarkBarNode()->GetChild(button_index); |
1064 } | 1064 } |
1065 | 1065 |
1066 bookmark_menu_ = new BookmarkMenuController( | 1066 bookmark_menu_ = new BookmarkMenuController( |
1067 profile_, page_navigator_, GetWindow()->GetNativeWindow(), node, | 1067 profile_, page_navigator_, GetWidget()->GetNativeWindow(), node, |
1068 start_index); | 1068 start_index); |
1069 bookmark_menu_->set_observer(this); | 1069 bookmark_menu_->set_observer(this); |
1070 bookmark_menu_->RunMenuAt(this, false); | 1070 bookmark_menu_->RunMenuAt(this, false); |
1071 } | 1071 } |
1072 | 1072 |
1073 void BookmarkBarView::ButtonPressed(views::Button* sender, | 1073 void BookmarkBarView::ButtonPressed(views::Button* sender, |
1074 const views::Event& event) { | 1074 const views::Event& event) { |
1075 // Show the login wizard if the user clicked the re-login button. | 1075 // Show the login wizard if the user clicked the re-login button. |
1076 if (sender->tag() == kSyncErrorButtonTag) { | 1076 if (sender->tag() == kSyncErrorButtonTag) { |
1077 DCHECK(sender == sync_error_button_); | 1077 DCHECK(sender == sync_error_button_); |
(...skipping 13 matching lines...) Expand all Loading... |
1091 DCHECK(page_navigator_); | 1091 DCHECK(page_navigator_); |
1092 | 1092 |
1093 WindowOpenDisposition disposition_from_event_flags = | 1093 WindowOpenDisposition disposition_from_event_flags = |
1094 event_utils::DispositionFromEventFlags(sender->mouse_event_flags()); | 1094 event_utils::DispositionFromEventFlags(sender->mouse_event_flags()); |
1095 | 1095 |
1096 if (node->is_url()) { | 1096 if (node->is_url()) { |
1097 RecordAppLaunch(profile_, node->GetURL()); | 1097 RecordAppLaunch(profile_, node->GetURL()); |
1098 page_navigator_->OpenURL(node->GetURL(), GURL(), | 1098 page_navigator_->OpenURL(node->GetURL(), GURL(), |
1099 disposition_from_event_flags, PageTransition::AUTO_BOOKMARK); | 1099 disposition_from_event_flags, PageTransition::AUTO_BOOKMARK); |
1100 } else { | 1100 } else { |
1101 bookmark_utils::OpenAll(GetWindow()->GetNativeWindow(), profile_, | 1101 bookmark_utils::OpenAll(GetWidget()->GetNativeWindow(), profile_, |
1102 page_navigator_, node, disposition_from_event_flags); | 1102 page_navigator_, node, disposition_from_event_flags); |
1103 } | 1103 } |
1104 UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); | 1104 UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); |
1105 } | 1105 } |
1106 | 1106 |
1107 void BookmarkBarView::ShowContextMenuForView(View* source, | 1107 void BookmarkBarView::ShowContextMenuForView(View* source, |
1108 const gfx::Point& p, | 1108 const gfx::Point& p, |
1109 bool is_mouse_gesture) { | 1109 bool is_mouse_gesture) { |
1110 if (!model_->IsLoaded()) { | 1110 if (!model_->IsLoaded()) { |
1111 // Don't do anything if the model isn't loaded. | 1111 // Don't do anything if the model isn't loaded. |
(...skipping 20 matching lines...) Expand all Loading... |
1132 } else { | 1132 } else { |
1133 parent = model_->GetBookmarkBarNode(); | 1133 parent = model_->GetBookmarkBarNode(); |
1134 nodes.push_back(parent); | 1134 nodes.push_back(parent); |
1135 } | 1135 } |
1136 // Browser may be null during testing. | 1136 // Browser may be null during testing. |
1137 PageNavigator* navigator = | 1137 PageNavigator* navigator = |
1138 browser() ? browser()->GetSelectedTabContents() : NULL; | 1138 browser() ? browser()->GetSelectedTabContents() : NULL; |
1139 bool close_on_remove = | 1139 bool close_on_remove = |
1140 (parent == profile_->GetBookmarkModel()->other_node() && | 1140 (parent == profile_->GetBookmarkModel()->other_node() && |
1141 parent->child_count() == 1); | 1141 parent->child_count() == 1); |
1142 BookmarkContextMenu controller(GetWindow()->GetNativeWindow(), profile_, | 1142 BookmarkContextMenu controller(GetWidget()->GetNativeWindow(), profile_, |
1143 navigator, parent, nodes, close_on_remove); | 1143 navigator, parent, nodes, close_on_remove); |
1144 controller.RunMenuAt(p); | 1144 controller.RunMenuAt(p); |
1145 } | 1145 } |
1146 | 1146 |
1147 void BookmarkBarView::Observe(NotificationType type, | 1147 void BookmarkBarView::Observe(NotificationType type, |
1148 const NotificationSource& source, | 1148 const NotificationSource& source, |
1149 const NotificationDetails& details) { | 1149 const NotificationDetails& details) { |
1150 DCHECK(profile_); | 1150 DCHECK(profile_); |
1151 switch (type.value) { | 1151 switch (type.value) { |
1152 case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: | 1152 case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 views::MenuButton* menu_button = GetMenuButtonForNode(node); | 1394 views::MenuButton* menu_button = GetMenuButtonForNode(node); |
1395 if (!menu_button) | 1395 if (!menu_button) |
1396 return; | 1396 return; |
1397 | 1397 |
1398 int start_index = 0; | 1398 int start_index = 0; |
1399 if (node == model_->GetBookmarkBarNode()) | 1399 if (node == model_->GetBookmarkBarNode()) |
1400 start_index = GetFirstHiddenNodeIndex(); | 1400 start_index = GetFirstHiddenNodeIndex(); |
1401 | 1401 |
1402 drop_info_->is_menu_showing = true; | 1402 drop_info_->is_menu_showing = true; |
1403 bookmark_drop_menu_ = new BookmarkMenuController( | 1403 bookmark_drop_menu_ = new BookmarkMenuController( |
1404 profile_, page_navigator_, GetWindow()->GetNativeWindow(), node, | 1404 profile_, page_navigator_, GetWidget()->GetNativeWindow(), node, |
1405 start_index); | 1405 start_index); |
1406 bookmark_drop_menu_->set_observer(this); | 1406 bookmark_drop_menu_->set_observer(this); |
1407 bookmark_drop_menu_->RunMenuAt(this, true); | 1407 bookmark_drop_menu_->RunMenuAt(this, true); |
1408 } | 1408 } |
1409 | 1409 |
1410 void BookmarkBarView::StopShowFolderDropMenuTimer() { | 1410 void BookmarkBarView::StopShowFolderDropMenuTimer() { |
1411 show_folder_method_factory_.RevokeAll(); | 1411 show_folder_method_factory_.RevokeAll(); |
1412 } | 1412 } |
1413 | 1413 |
1414 void BookmarkBarView::StartShowFolderDropMenuTimer(const BookmarkNode* node) { | 1414 void BookmarkBarView::StartShowFolderDropMenuTimer(const BookmarkNode* node) { |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 (1 - size_animation_->GetCurrentValue()))); | 1765 (1 - size_animation_->GetCurrentValue()))); |
1766 } else { | 1766 } else { |
1767 prefsize.set_height( | 1767 prefsize.set_height( |
1768 static_cast<int>( | 1768 static_cast<int>( |
1769 browser_defaults::kBookmarkBarHeight * | 1769 browser_defaults::kBookmarkBarHeight * |
1770 size_animation_->GetCurrentValue())); | 1770 size_animation_->GetCurrentValue())); |
1771 } | 1771 } |
1772 } | 1772 } |
1773 return prefsize; | 1773 return prefsize; |
1774 } | 1774 } |
OLD | NEW |