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

Side by Side Diff: chrome/browser/ui/views/bookmark_menu_controller_views.cc

Issue 6200005: Move OSExchangeData from src/app to src/ui/base/dragdrop... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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) 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/bookmark_menu_controller_views.h" 5 #include "chrome/browser/ui/views/bookmark_menu_controller_views.h"
6 6
7 #include "app/os_exchange_data.h"
8 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
9 #include "base/stl_util-inl.h" 8 #include "base/stl_util-inl.h"
10 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/bookmarks/bookmark_node_data.h" 10 #include "chrome/browser/bookmarks/bookmark_node_data.h"
12 #include "chrome/browser/bookmarks/bookmark_model.h" 11 #include "chrome/browser/bookmarks/bookmark_model.h"
13 #include "chrome/browser/bookmarks/bookmark_utils.h" 12 #include "chrome/browser/bookmarks/bookmark_utils.h"
14 #include "chrome/browser/metrics/user_metrics.h" 13 #include "chrome/browser/metrics/user_metrics.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/tab_contents/page_navigator.h" 15 #include "chrome/browser/tab_contents/page_navigator.h"
17 #include "chrome/browser/ui/views/bookmark_bar_view.h" 16 #include "chrome/browser/ui/views/bookmark_bar_view.h"
18 #include "chrome/browser/ui/views/event_utils.h" 17 #include "chrome/browser/ui/views/event_utils.h"
19 #include "chrome/common/page_transition_types.h" 18 #include "chrome/common/page_transition_types.h"
20 #include "grit/app_resources.h" 19 #include "grit/app_resources.h"
21 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
22 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
22 #include "ui/base/dragdrop/os_exchange_data.h"
23 #include "views/controls/button/menu_button.h" 23 #include "views/controls/button/menu_button.h"
24 24
25 using views::MenuItemView; 25 using views::MenuItemView;
26 26
27 // Max width of a menu. There does not appear to be an OS value for this, yet 27 // Max width of a menu. There does not appear to be an OS value for this, yet
28 // both IE and FF restrict the max width of a menu. 28 // both IE and FF restrict the max width of a menu.
29 static const int kMaxMenuWidth = 400; 29 static const int kMaxMenuWidth = 400;
30 30
31 BookmarkMenuController::BookmarkMenuController(Browser* browser, 31 BookmarkMenuController::BookmarkMenuController(Browser* browser,
32 Profile* profile, 32 Profile* profile,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 WindowOpenDisposition initial_disposition = 100 WindowOpenDisposition initial_disposition =
101 event_utils::DispositionFromEventFlags(mouse_event_flags); 101 event_utils::DispositionFromEventFlags(mouse_event_flags);
102 102
103 bookmark_utils::OpenAll(parent_, profile_, page_navigator_, selection, 103 bookmark_utils::OpenAll(parent_, profile_, page_navigator_, selection,
104 initial_disposition); 104 initial_disposition);
105 } 105 }
106 106
107 bool BookmarkMenuController::GetDropFormats( 107 bool BookmarkMenuController::GetDropFormats(
108 MenuItemView* menu, 108 MenuItemView* menu,
109 int* formats, 109 int* formats,
110 std::set<OSExchangeData::CustomFormat>* custom_formats) { 110 std::set<ui::OSExchangeData::CustomFormat>* custom_formats) {
111 *formats = OSExchangeData::URL; 111 *formats = ui::OSExchangeData::URL;
112 custom_formats->insert(BookmarkNodeData::GetBookmarkCustomFormat()); 112 custom_formats->insert(BookmarkNodeData::GetBookmarkCustomFormat());
113 return true; 113 return true;
114 } 114 }
115 115
116 bool BookmarkMenuController::AreDropTypesRequired(MenuItemView* menu) { 116 bool BookmarkMenuController::AreDropTypesRequired(MenuItemView* menu) {
117 return true; 117 return true;
118 } 118 }
119 119
120 bool BookmarkMenuController::CanDrop(MenuItemView* menu, 120 bool BookmarkMenuController::CanDrop(MenuItemView* menu,
121 const OSExchangeData& data) { 121 const ui::OSExchangeData& data) {
122 // Only accept drops of 1 node, which is the case for all data dragged from 122 // Only accept drops of 1 node, which is the case for all data dragged from
123 // bookmark bar and menus. 123 // bookmark bar and menus.
124 124
125 if (!drop_data_.Read(data) || drop_data_.elements.size() != 1) 125 if (!drop_data_.Read(data) || drop_data_.elements.size() != 1)
126 return false; 126 return false;
127 127
128 if (drop_data_.has_single_url()) 128 if (drop_data_.has_single_url())
129 return true; 129 return true;
130 130
131 const BookmarkNode* drag_node = drop_data_.GetFirstNode(profile_); 131 const BookmarkNode* drag_node = drop_data_.GetFirstNode(profile_);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 void BookmarkMenuController::DropMenuClosed(MenuItemView* menu) { 212 void BookmarkMenuController::DropMenuClosed(MenuItemView* menu) {
213 delete this; 213 delete this;
214 } 214 }
215 215
216 bool BookmarkMenuController::CanDrag(MenuItemView* menu) { 216 bool BookmarkMenuController::CanDrag(MenuItemView* menu) {
217 return true; 217 return true;
218 } 218 }
219 219
220 void BookmarkMenuController::WriteDragData(MenuItemView* sender, 220 void BookmarkMenuController::WriteDragData(MenuItemView* sender,
221 OSExchangeData* data) { 221 ui::OSExchangeData* data) {
222 DCHECK(sender && data); 222 DCHECK(sender && data);
223 223
224 UserMetrics::RecordAction(UserMetricsAction("BookmarkBar_DragFromFolder"), 224 UserMetrics::RecordAction(UserMetricsAction("BookmarkBar_DragFromFolder"),
225 profile_); 225 profile_);
226 226
227 BookmarkNodeData drag_data(menu_id_to_node_map_[sender->GetCommand()]); 227 BookmarkNodeData drag_data(menu_id_to_node_map_[sender->GetCommand()]);
228 drag_data.Write(profile_, data); 228 drag_data.Write(profile_, data);
229 } 229 }
230 230
231 int BookmarkMenuController::GetDragOperations(MenuItemView* sender) { 231 int BookmarkMenuController::GetDragOperations(MenuItemView* sender) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 break; 406 break;
407 } 407 }
408 } 408 }
409 if (ancestor_removed) { 409 if (ancestor_removed) {
410 node_to_menu_id_map_.erase(i++); 410 node_to_menu_id_map_.erase(i++);
411 } else { 411 } else {
412 ++i; 412 ++i;
413 } 413 }
414 } 414 }
415 } 415 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmark_menu_controller_views.h ('k') | chrome/browser/ui/views/browser_actions_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698