| OLD | NEW |
| 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/gtk/bookmarks/bookmark_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" | 29 #include "chrome/browser/ui/gtk/hover_controller_gtk.h" |
| 30 #include "chrome/browser/ui/gtk/menu_gtk.h" | 30 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 31 #include "chrome/browser/ui/gtk/rounded_window.h" | 31 #include "chrome/browser/ui/gtk/rounded_window.h" |
| 32 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" | 32 #include "chrome/browser/ui/gtk/tabstrip_origin_provider.h" |
| 33 #include "chrome/browser/ui/gtk/view_id_util.h" | 33 #include "chrome/browser/ui/gtk/view_id_util.h" |
| 34 #include "chrome/common/chrome_notification_types.h" | 34 #include "chrome/common/chrome_notification_types.h" |
| 35 #include "chrome/common/extensions/extension_constants.h" | 35 #include "chrome/common/extensions/extension_constants.h" |
| 36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
| 37 #include "content/browser/tab_contents/tab_contents.h" | 37 #include "content/browser/tab_contents/tab_contents.h" |
| 38 #include "content/browser/tab_contents/tab_contents_view.h" | 38 #include "content/browser/tab_contents/tab_contents_view.h" |
| 39 #include "content/browser/user_metrics.h" | |
| 40 #include "content/public/browser/notification_details.h" | 39 #include "content/public/browser/notification_details.h" |
| 41 #include "content/public/browser/notification_source.h" | 40 #include "content/public/browser/notification_source.h" |
| 41 #include "content/public/browser/user_metrics.h" |
| 42 #include "grit/generated_resources.h" | 42 #include "grit/generated_resources.h" |
| 43 #include "grit/theme_resources.h" | 43 #include "grit/theme_resources.h" |
| 44 #include "grit/ui_resources.h" | 44 #include "grit/ui_resources.h" |
| 45 #include "ui/base/dragdrop/gtk_dnd_util.h" | 45 #include "ui/base/dragdrop/gtk_dnd_util.h" |
| 46 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
| 47 #include "ui/base/resource/resource_bundle.h" | 47 #include "ui/base/resource/resource_bundle.h" |
| 48 #include "ui/gfx/canvas_skia_paint.h" | 48 #include "ui/gfx/canvas_skia_paint.h" |
| 49 #include "ui/gfx/gtk_util.h" | 49 #include "ui/gfx/gtk_util.h" |
| 50 #include "ui/gfx/image/cairo_cached_surface.h" | 50 #include "ui/gfx/image/cairo_cached_surface.h" |
| 51 #include "ui/gfx/image/image.h" | 51 #include "ui/gfx/image/image.h" |
| 52 | 52 |
| 53 using content::UserMetricsAction; |
| 54 |
| 53 namespace { | 55 namespace { |
| 54 | 56 |
| 55 // The showing height of the bar. | 57 // The showing height of the bar. |
| 56 const int kBookmarkBarHeight = 29; | 58 const int kBookmarkBarHeight = 29; |
| 57 | 59 |
| 58 // Padding for when the bookmark bar is detached. | 60 // Padding for when the bookmark bar is detached. |
| 59 const int kTopBottomNTPPadding = 12; | 61 const int kTopBottomNTPPadding = 12; |
| 60 const int kLeftRightNTPPadding = 8; | 62 const int kLeftRightNTPPadding = 8; |
| 61 | 63 |
| 62 // Padding around the bar's content area when the bookmark bar is detached. | 64 // Padding around the bar's content area when the bookmark bar is detached. |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 const BookmarkNode* node = GetNodeForToolButton(sender); | 1129 const BookmarkNode* node = GetNodeForToolButton(sender); |
| 1128 DCHECK(node); | 1130 DCHECK(node); |
| 1129 DCHECK(node->is_url()); | 1131 DCHECK(node->is_url()); |
| 1130 DCHECK(page_navigator_); | 1132 DCHECK(page_navigator_); |
| 1131 | 1133 |
| 1132 Profile* profile = browser_->profile(); | 1134 Profile* profile = browser_->profile(); |
| 1133 RecordAppLaunch(profile, node->url()); | 1135 RecordAppLaunch(profile, node->url()); |
| 1134 bookmark_utils::OpenAll(window_->GetNativeHandle(), profile, page_navigator_, | 1136 bookmark_utils::OpenAll(window_->GetNativeHandle(), profile, page_navigator_, |
| 1135 node, gtk_util::DispositionForCurrentButtonPressEvent()); | 1137 node, gtk_util::DispositionForCurrentButtonPressEvent()); |
| 1136 | 1138 |
| 1137 UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); | 1139 content::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton")); |
| 1138 } | 1140 } |
| 1139 | 1141 |
| 1140 void BookmarkBarGtk::OnButtonDragBegin(GtkWidget* button, | 1142 void BookmarkBarGtk::OnButtonDragBegin(GtkWidget* button, |
| 1141 GdkDragContext* drag_context) { | 1143 GdkDragContext* drag_context) { |
| 1142 // The parent tool item might be removed during the drag. Ref it so |button| | 1144 // The parent tool item might be removed during the drag. Ref it so |button| |
| 1143 // won't get destroyed. | 1145 // won't get destroyed. |
| 1144 g_object_ref(button->parent); | 1146 g_object_ref(button->parent); |
| 1145 | 1147 |
| 1146 const BookmarkNode* node = GetNodeForToolButton(button); | 1148 const BookmarkNode* node = GetNodeForToolButton(button); |
| 1147 DCHECK(!dragged_node_); | 1149 DCHECK(!dragged_node_); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1438 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { | 1440 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { |
| 1439 GtkDestDefaults dest_defaults = | 1441 GtkDestDefaults dest_defaults = |
| 1440 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : | 1442 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : |
| 1441 GTK_DEST_DEFAULT_DROP; | 1443 GTK_DEST_DEFAULT_DROP; |
| 1442 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); | 1444 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); |
| 1443 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, | 1445 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, |
| 1444 NULL, 0, kDragAction); | 1446 NULL, 0, kDragAction); |
| 1445 ui::SetDestTargetList(overflow_button_, kDestTargetList); | 1447 ui::SetDestTargetList(overflow_button_, kDestTargetList); |
| 1446 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); | 1448 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); |
| 1447 } | 1449 } |
| OLD | NEW |