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 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 index = parent_node->child_count(); | 901 index = parent_node->child_count(); |
902 } else { | 902 } else { |
903 parent_node = root; | 903 parent_node = root; |
904 } | 904 } |
905 const BookmarkNodeData data = drop_info_->data; | 905 const BookmarkNodeData data = drop_info_->data; |
906 DCHECK(data.is_valid()); | 906 DCHECK(data.is_valid()); |
907 drop_info_.reset(); | 907 drop_info_.reset(); |
908 return chrome::DropBookmarks(browser_->profile(), data, parent_node, index); | 908 return chrome::DropBookmarks(browser_->profile(), data, parent_node, index); |
909 } | 909 } |
910 | 910 |
911 void BookmarkBarView::ShowContextMenu(const gfx::Point& p, | |
912 bool is_mouse_gesture) { | |
913 ShowContextMenuForView(this, p); | |
914 } | |
915 | |
916 void BookmarkBarView::OnThemeChanged() { | 911 void BookmarkBarView::OnThemeChanged() { |
917 UpdateColors(); | 912 UpdateColors(); |
918 } | 913 } |
919 | 914 |
920 const char* BookmarkBarView::GetClassName() const { | 915 const char* BookmarkBarView::GetClassName() const { |
921 return kViewClassName; | 916 return kViewClassName; |
922 } | 917 } |
923 | 918 |
924 void BookmarkBarView::GetAccessibleState(ui::AccessibleViewState* state) { | 919 void BookmarkBarView::GetAccessibleState(ui::AccessibleViewState* state) { |
925 state->role = ui::AccessibilityTypes::ROLE_TOOLBAR; | 920 state->role = ui::AccessibilityTypes::ROLE_TOOLBAR; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 page_navigator_->OpenURL(params); | 1202 page_navigator_->OpenURL(params); |
1208 } else { | 1203 } else { |
1209 chrome::OpenAll(GetWidget()->GetNativeWindow(), page_navigator_, node, | 1204 chrome::OpenAll(GetWidget()->GetNativeWindow(), page_navigator_, node, |
1210 disposition_from_event_flags, browser_->profile()); | 1205 disposition_from_event_flags, browser_->profile()); |
1211 } | 1206 } |
1212 | 1207 |
1213 bookmark_utils::RecordBookmarkLaunch(GetBookmarkLaunchLocation()); | 1208 bookmark_utils::RecordBookmarkLaunch(GetBookmarkLaunchLocation()); |
1214 } | 1209 } |
1215 | 1210 |
1216 void BookmarkBarView::ShowContextMenuForView(views::View* source, | 1211 void BookmarkBarView::ShowContextMenuForView(views::View* source, |
1217 const gfx::Point& point) { | 1212 const gfx::Point& point, |
| 1213 ui::MenuSourceType source_type) { |
1218 if (!model_->loaded()) { | 1214 if (!model_->loaded()) { |
1219 // Don't do anything if the model isn't loaded. | 1215 // Don't do anything if the model isn't loaded. |
1220 return; | 1216 return; |
1221 } | 1217 } |
1222 | 1218 |
1223 const BookmarkNode* parent = NULL; | 1219 const BookmarkNode* parent = NULL; |
1224 std::vector<const BookmarkNode*> nodes; | 1220 std::vector<const BookmarkNode*> nodes; |
1225 if (source == other_bookmarked_button_) { | 1221 if (source == other_bookmarked_button_) { |
1226 parent = model_->other_node(); | 1222 parent = model_->other_node(); |
1227 // Do this so the user can open all bookmarks. BookmarkContextMenu makes | 1223 // Do this so the user can open all bookmarks. BookmarkContextMenu makes |
(...skipping 15 matching lines...) Expand all Loading... |
1243 nodes.push_back(parent); | 1239 nodes.push_back(parent); |
1244 } | 1240 } |
1245 Profile* profile = browser_->profile(); | 1241 Profile* profile = browser_->profile(); |
1246 bool close_on_remove = | 1242 bool close_on_remove = |
1247 (parent == BookmarkModelFactory::GetForProfile(profile)->other_node()) && | 1243 (parent == BookmarkModelFactory::GetForProfile(profile)->other_node()) && |
1248 (parent->child_count() == 1); | 1244 (parent->child_count() == 1); |
1249 context_menu_.reset(new BookmarkContextMenu( | 1245 context_menu_.reset(new BookmarkContextMenu( |
1250 GetWidget(), browser_, profile, | 1246 GetWidget(), browser_, profile, |
1251 browser_->tab_strip_model()->GetActiveWebContents(), | 1247 browser_->tab_strip_model()->GetActiveWebContents(), |
1252 parent, nodes, close_on_remove)); | 1248 parent, nodes, close_on_remove)); |
1253 context_menu_->RunMenuAt(point); | 1249 context_menu_->RunMenuAt(point, source_type); |
1254 } | 1250 } |
1255 | 1251 |
1256 void BookmarkBarView::Init() { | 1252 void BookmarkBarView::Init() { |
1257 // Note that at this point we're not in a hierarchy so GetThemeProvider() will | 1253 // Note that at this point we're not in a hierarchy so GetThemeProvider() will |
1258 // return NULL. When we're inserted into a hierarchy, we'll call | 1254 // return NULL. When we're inserted into a hierarchy, we'll call |
1259 // UpdateColors(), which will set the appropriate colors for all the objects | 1255 // UpdateColors(), which will set the appropriate colors for all the objects |
1260 // added in this function. | 1256 // added in this function. |
1261 | 1257 |
1262 // Child views are traversed in the order they are added. Make sure the order | 1258 // Child views are traversed in the order they are added. Make sure the order |
1263 // they are added matches the visual order. | 1259 // they are added matches the visual order. |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1862 DCHECK(apps_page_shortcut_); | 1858 DCHECK(apps_page_shortcut_); |
1863 // Only perform layout if required. | 1859 // Only perform layout if required. |
1864 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( | 1860 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( |
1865 browser_->profile()); | 1861 browser_->profile()); |
1866 if (apps_page_shortcut_->visible() == visible) | 1862 if (apps_page_shortcut_->visible() == visible) |
1867 return; | 1863 return; |
1868 apps_page_shortcut_->SetVisible(visible); | 1864 apps_page_shortcut_->SetVisible(visible); |
1869 UpdateBookmarksSeparatorVisibility(); | 1865 UpdateBookmarksSeparatorVisibility(); |
1870 Layout(); | 1866 Layout(); |
1871 } | 1867 } |
OLD | NEW |