Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 content::PAGE_TRANSITION_AUTO_BOOKMARK, false); 1201 content::PAGE_TRANSITION_AUTO_BOOKMARK, false);
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(
1217 const gfx::Point& point) { 1212 views::View* source,
1213 const gfx::Point& point,
1214 ui::ContextMenuSourceType source_type) {
1218 if (!model_->loaded()) { 1215 if (!model_->loaded()) {
1219 // Don't do anything if the model isn't loaded. 1216 // Don't do anything if the model isn't loaded.
1220 return; 1217 return;
1221 } 1218 }
1222 1219
1223 const BookmarkNode* parent = NULL; 1220 const BookmarkNode* parent = NULL;
1224 std::vector<const BookmarkNode*> nodes; 1221 std::vector<const BookmarkNode*> nodes;
1225 if (source == other_bookmarked_button_) { 1222 if (source == other_bookmarked_button_) {
1226 parent = model_->other_node(); 1223 parent = model_->other_node();
1227 // Do this so the user can open all bookmarks. BookmarkContextMenu makes 1224 // Do this so the user can open all bookmarks. BookmarkContextMenu makes
(...skipping 15 matching lines...) Expand all
1243 nodes.push_back(parent); 1240 nodes.push_back(parent);
1244 } 1241 }
1245 Profile* profile = browser_->profile(); 1242 Profile* profile = browser_->profile();
1246 bool close_on_remove = 1243 bool close_on_remove =
1247 (parent == BookmarkModelFactory::GetForProfile(profile)->other_node()) && 1244 (parent == BookmarkModelFactory::GetForProfile(profile)->other_node()) &&
1248 (parent->child_count() == 1); 1245 (parent->child_count() == 1);
1249 context_menu_.reset(new BookmarkContextMenu( 1246 context_menu_.reset(new BookmarkContextMenu(
1250 GetWidget(), browser_, profile, 1247 GetWidget(), browser_, profile,
1251 browser_->tab_strip_model()->GetActiveWebContents(), 1248 browser_->tab_strip_model()->GetActiveWebContents(),
1252 parent, nodes, close_on_remove)); 1249 parent, nodes, close_on_remove));
1253 context_menu_->RunMenuAt(point); 1250 context_menu_->RunMenuAt(point, source_type);
1254 } 1251 }
1255 1252
1256 void BookmarkBarView::Init() { 1253 void BookmarkBarView::Init() {
1257 // Note that at this point we're not in a hierarchy so GetThemeProvider() will 1254 // 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 1255 // return NULL. When we're inserted into a hierarchy, we'll call
1259 // UpdateColors(), which will set the appropriate colors for all the objects 1256 // UpdateColors(), which will set the appropriate colors for all the objects
1260 // added in this function. 1257 // added in this function.
1261 1258
1262 // Child views are traversed in the order they are added. Make sure the order 1259 // Child views are traversed in the order they are added. Make sure the order
1263 // they are added matches the visual order. 1260 // they are added matches the visual order.
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 DCHECK(apps_page_shortcut_); 1859 DCHECK(apps_page_shortcut_);
1863 // Only perform layout if required. 1860 // Only perform layout if required.
1864 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar( 1861 bool visible = chrome::ShouldShowAppsShortcutInBookmarkBar(
1865 browser_->profile()); 1862 browser_->profile());
1866 if (apps_page_shortcut_->visible() == visible) 1863 if (apps_page_shortcut_->visible() == visible)
1867 return; 1864 return;
1868 apps_page_shortcut_->SetVisible(visible); 1865 apps_page_shortcut_->SetVisible(visible);
1869 UpdateBookmarksSeparatorVisibility(); 1866 UpdateBookmarksSeparatorVisibility();
1870 Layout(); 1867 Layout();
1871 } 1868 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698