OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/bookmark_bar_view.h" | 5 #include "chrome/browser/views/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 20 matching lines...) Expand all Loading... |
31 #include "chrome/browser/tab_contents/tab_contents.h" | 31 #include "chrome/browser/tab_contents/tab_contents.h" |
32 #include "chrome/browser/view_ids.h" | 32 #include "chrome/browser/view_ids.h" |
33 #include "chrome/browser/views/bookmark_context_menu.h" | 33 #include "chrome/browser/views/bookmark_context_menu.h" |
34 #include "chrome/browser/views/event_utils.h" | 34 #include "chrome/browser/views/event_utils.h" |
35 #include "chrome/browser/views/frame/browser_view.h" | 35 #include "chrome/browser/views/frame/browser_view.h" |
36 #include "chrome/browser/views/location_bar/location_bar_view.h" | 36 #include "chrome/browser/views/location_bar/location_bar_view.h" |
37 #include "chrome/common/notification_service.h" | 37 #include "chrome/common/notification_service.h" |
38 #include "chrome/common/page_transition_types.h" | 38 #include "chrome/common/page_transition_types.h" |
39 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
40 #include "gfx/canvas.h" | 40 #include "gfx/canvas.h" |
| 41 #include "gfx/canvas_skia.h" |
41 #include "grit/app_resources.h" | 42 #include "grit/app_resources.h" |
42 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
43 #include "grit/theme_resources.h" | 44 #include "grit/theme_resources.h" |
44 #include "views/controls/button/menu_button.h" | 45 #include "views/controls/button/menu_button.h" |
45 #include "views/controls/label.h" | 46 #include "views/controls/label.h" |
46 #include "views/controls/menu/menu_item_view.h" | 47 #include "views/controls/menu/menu_item_view.h" |
47 #include "views/drag_utils.h" | 48 #include "views/drag_utils.h" |
48 #include "views/view_constants.h" | 49 #include "views/view_constants.h" |
49 #include "views/widget/tooltip_manager.h" | 50 #include "views/widget/tooltip_manager.h" |
50 #include "views/widget/widget.h" | 51 #include "views/widget/widget.h" |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 | 1104 |
1104 void BookmarkBarView::WriteDragData(View* sender, | 1105 void BookmarkBarView::WriteDragData(View* sender, |
1105 const gfx::Point& press_pt, | 1106 const gfx::Point& press_pt, |
1106 OSExchangeData* data) { | 1107 OSExchangeData* data) { |
1107 UserMetrics::RecordAction(UserMetricsAction("BookmarkBar_DragButton"), | 1108 UserMetrics::RecordAction(UserMetricsAction("BookmarkBar_DragButton"), |
1108 profile_); | 1109 profile_); |
1109 | 1110 |
1110 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { | 1111 for (int i = 0; i < GetBookmarkButtonCount(); ++i) { |
1111 if (sender == GetBookmarkButton(i)) { | 1112 if (sender == GetBookmarkButton(i)) { |
1112 views::TextButton* button = GetBookmarkButton(i); | 1113 views::TextButton* button = GetBookmarkButton(i); |
1113 gfx::Canvas canvas(button->width(), button->height(), false); | 1114 gfx::CanvasSkia canvas(button->width(), button->height(), false); |
1114 button->Paint(&canvas, true); | 1115 button->Paint(canvas.AsCanvas(), true); |
1115 drag_utils::SetDragImageOnDataObject(canvas, button->size(), press_pt, | 1116 drag_utils::SetDragImageOnDataObject(*canvas.AsCanvas(), button->size(), |
1116 data); | 1117 press_pt, data); |
1117 WriteDragData(model_->GetBookmarkBarNode()->GetChild(i), data); | 1118 WriteDragData(model_->GetBookmarkBarNode()->GetChild(i), data); |
1118 return; | 1119 return; |
1119 } | 1120 } |
1120 } | 1121 } |
1121 NOTREACHED(); | 1122 NOTREACHED(); |
1122 } | 1123 } |
1123 | 1124 |
1124 int BookmarkBarView::GetDragOperations(View* sender, const gfx::Point& p) { | 1125 int BookmarkBarView::GetDragOperations(View* sender, const gfx::Point& p) { |
1125 if (size_animation_->is_animating() || | 1126 if (size_animation_->is_animating() || |
1126 (size_animation_->GetCurrentValue() == 0 && !OnNewTabPage())) { | 1127 (size_animation_->GetCurrentValue() == 0 && !OnNewTabPage())) { |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 | 1744 |
1744 void BookmarkBarView::CheckIntegrity() { | 1745 void BookmarkBarView::CheckIntegrity() { |
1745 // We better be on the ui thread. | 1746 // We better be on the ui thread. |
1746 CHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 1747 CHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
1747 | 1748 |
1748 // And the number of views on the bookmark bar better match that of the model. | 1749 // And the number of views on the bookmark bar better match that of the model. |
1749 volatile int model_count = model_->GetBookmarkBarNode()->GetChildCount(); | 1750 volatile int model_count = model_->GetBookmarkBarNode()->GetChildCount(); |
1750 volatile int view_count = GetBookmarkButtonCount(); | 1751 volatile int view_count = GetBookmarkButtonCount(); |
1751 CHECK_EQ(model_count, view_count); | 1752 CHECK_EQ(model_count, view_count); |
1752 } | 1753 } |
OLD | NEW |