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_menu_controller_views.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_menu_controller_views.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 views::View::ConvertPointToScreen(menu_button, &screen_loc); | 58 views::View::ConvertPointToScreen(menu_button, &screen_loc); |
59 // Subtract 1 from the height to make the popup flush with the button border. | 59 // Subtract 1 from the height to make the popup flush with the button border. |
60 gfx::Rect bounds(screen_loc.x(), screen_loc.y(), menu_button->width(), | 60 gfx::Rect bounds(screen_loc.x(), screen_loc.y(), menu_button->width(), |
61 menu_button->height() - 1); | 61 menu_button->height() - 1); |
62 for_drop_ = for_drop; | 62 for_drop_ = for_drop; |
63 BookmarkModelFactory::GetForProfile( | 63 BookmarkModelFactory::GetForProfile( |
64 menu_delegate_->profile())->AddObserver(this); | 64 menu_delegate_->profile())->AddObserver(this); |
65 // We only delete ourself after the menu completes, so we can safely ignore | 65 // We only delete ourself after the menu completes, so we can safely ignore |
66 // the return value. | 66 // the return value. |
67 ignore_result(menu_runner_->RunMenuAt(menu_delegate_->parent(), menu_button, | 67 ignore_result(menu_runner_->RunMenuAt(menu_delegate_->parent(), menu_button, |
68 bounds, anchor, for_drop ? views::MenuRunner::FOR_DROP : 0)); | 68 bounds, anchor, ui::MENU_SOURCE_NONE, |
| 69 for_drop ? views::MenuRunner::FOR_DROP : 0)); |
69 if (!for_drop) | 70 if (!for_drop) |
70 delete this; | 71 delete this; |
71 } | 72 } |
72 | 73 |
73 void BookmarkMenuController::Cancel() { | 74 void BookmarkMenuController::Cancel() { |
74 menu_delegate_->menu()->Cancel(); | 75 menu_delegate_->menu()->Cancel(); |
75 } | 76 } |
76 | 77 |
77 MenuItemView* BookmarkMenuController::menu() const { | 78 MenuItemView* BookmarkMenuController::menu() const { |
78 return menu_delegate_->menu(); | 79 return menu_delegate_->menu(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const ui::DropTargetEvent& event) { | 134 const ui::DropTargetEvent& event) { |
134 int result = menu_delegate_->OnPerformDrop(menu, position, event); | 135 int result = menu_delegate_->OnPerformDrop(menu, position, event); |
135 if (for_drop_) | 136 if (for_drop_) |
136 delete this; | 137 delete this; |
137 return result; | 138 return result; |
138 } | 139 } |
139 | 140 |
140 bool BookmarkMenuController::ShowContextMenu(MenuItemView* source, | 141 bool BookmarkMenuController::ShowContextMenu(MenuItemView* source, |
141 int id, | 142 int id, |
142 const gfx::Point& p, | 143 const gfx::Point& p, |
143 bool is_mouse_gesture) { | 144 ui::MenuSourceType source_type) { |
144 return menu_delegate_->ShowContextMenu(source, id, p, is_mouse_gesture); | 145 return menu_delegate_->ShowContextMenu(source, id, p, source_type); |
145 } | 146 } |
146 | 147 |
147 void BookmarkMenuController::DropMenuClosed(MenuItemView* menu) { | 148 void BookmarkMenuController::DropMenuClosed(MenuItemView* menu) { |
148 delete this; | 149 delete this; |
149 } | 150 } |
150 | 151 |
151 bool BookmarkMenuController::CanDrag(MenuItemView* menu) { | 152 bool BookmarkMenuController::CanDrag(MenuItemView* menu) { |
152 return menu_delegate_->CanDrag(menu); | 153 return menu_delegate_->CanDrag(menu); |
153 } | 154 } |
154 | 155 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 if (!menu_delegate_->is_mutating_model()) | 193 if (!menu_delegate_->is_mutating_model()) |
193 menu()->Cancel(); | 194 menu()->Cancel(); |
194 } | 195 } |
195 | 196 |
196 BookmarkMenuController::~BookmarkMenuController() { | 197 BookmarkMenuController::~BookmarkMenuController() { |
197 BookmarkModelFactory::GetForProfile( | 198 BookmarkModelFactory::GetForProfile( |
198 menu_delegate_->profile())->RemoveObserver(this); | 199 menu_delegate_->profile())->RemoveObserver(this); |
199 if (observer_) | 200 if (observer_) |
200 observer_->BookmarkMenuDeleted(this); | 201 observer_->BookmarkMenuDeleted(this); |
201 } | 202 } |
OLD | NEW |