| 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 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/tab_contents/page_navigator.h" | 30 #include "chrome/browser/tab_contents/page_navigator.h" |
| 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_skia.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" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // the context menu. They should not trigger the opening of underlying urls. | 236 // the context menu. They should not trigger the opening of underlying urls. |
| 236 if (e.GetFlags() == views::MouseEvent::EF_LEFT_BUTTON_DOWN || | 237 if (e.GetFlags() == views::MouseEvent::EF_LEFT_BUTTON_DOWN || |
| 237 e.GetFlags() == views::MouseEvent::EF_RIGHT_BUTTON_DOWN) | 238 e.GetFlags() == views::MouseEvent::EF_RIGHT_BUTTON_DOWN) |
| 238 return false; | 239 return false; |
| 239 | 240 |
| 240 WindowOpenDisposition disposition( | 241 WindowOpenDisposition disposition( |
| 241 event_utils::DispositionFromEventFlags(e.GetFlags())); | 242 event_utils::DispositionFromEventFlags(e.GetFlags())); |
| 242 return disposition != CURRENT_TAB; | 243 return disposition != CURRENT_TAB; |
| 243 } | 244 } |
| 244 | 245 |
| 245 virtual void Paint(gfx::Canvas* canvas) { | 246 virtual void Paint(gfx::Canvas *canvas) { |
| 246 views::MenuButton::Paint(canvas, false); | 247 views::MenuButton::Paint(canvas, false); |
| 247 } | 248 } |
| 248 | 249 |
| 249 private: | 250 private: |
| 250 scoped_ptr<SlideAnimation> show_animation_; | 251 scoped_ptr<SlideAnimation> show_animation_; |
| 251 | 252 |
| 252 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderButton); | 253 DISALLOW_COPY_AND_ASSIGN(BookmarkFolderButton); |
| 253 }; | 254 }; |
| 254 | 255 |
| 255 // OverFlowButton (chevron) -------------------------------------------------- | 256 // OverFlowButton (chevron) -------------------------------------------------- |
| (...skipping 847 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::CanvasSkia canvas(button->width(), button->height(), false); | 1114 // TODO(beng): convert to CanvasSkia |
| 1115 gfx::Canvas canvas(button->width(), button->height(), false); |
| 1114 button->Paint(&canvas, true); | 1116 button->Paint(&canvas, true); |
| 1115 drag_utils::SetDragImageOnDataObject(canvas, button->size(), | 1117 drag_utils::SetDragImageOnDataObject(canvas, button->size(), |
| 1116 press_pt, data); | 1118 press_pt, data); |
| 1117 WriteDragData(model_->GetBookmarkBarNode()->GetChild(i), data); | 1119 WriteDragData(model_->GetBookmarkBarNode()->GetChild(i), data); |
| 1118 return; | 1120 return; |
| 1119 } | 1121 } |
| 1120 } | 1122 } |
| 1121 NOTREACHED(); | 1123 NOTREACHED(); |
| 1122 } | 1124 } |
| 1123 | 1125 |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1743 | 1745 |
| 1744 void BookmarkBarView::CheckIntegrity() { | 1746 void BookmarkBarView::CheckIntegrity() { |
| 1745 // We better be on the ui thread. | 1747 // We better be on the ui thread. |
| 1746 CHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 1748 CHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 1747 | 1749 |
| 1748 // And the number of views on the bookmark bar better match that of the model. | 1750 // And the number of views on the bookmark bar better match that of the model. |
| 1749 volatile int model_count = model_->GetBookmarkBarNode()->GetChildCount(); | 1751 volatile int model_count = model_->GetBookmarkBarNode()->GetChildCount(); |
| 1750 volatile int view_count = GetBookmarkButtonCount(); | 1752 volatile int view_count = GetBookmarkButtonCount(); |
| 1751 CHECK_EQ(model_count, view_count); | 1753 CHECK_EQ(model_count, view_count); |
| 1752 } | 1754 } |
| OLD | NEW |