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/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
11 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
13 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 14 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
14 #include "chrome/browser/bookmarks/bookmark_utils.h" | 15 #include "chrome/browser/bookmarks/bookmark_utils.h" |
15 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/ntp_background_util.h" | 18 #include "chrome/browser/ntp_background_util.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 model_->AddObserver(this); | 274 model_->AddObserver(this); |
274 if (model_->IsLoaded()) | 275 if (model_->IsLoaded()) |
275 Loaded(model_, false); | 276 Loaded(model_, false); |
276 // else case: we'll receive notification back from the BookmarkModel when done | 277 // else case: we'll receive notification back from the BookmarkModel when done |
277 // loading, then we'll populate the bar. | 278 // loading, then we'll populate the bar. |
278 } | 279 } |
279 | 280 |
280 void BookmarkBarGtk::SetBookmarkBarState( | 281 void BookmarkBarGtk::SetBookmarkBarState( |
281 BookmarkBar::State state, | 282 BookmarkBar::State state, |
282 BookmarkBar::AnimateChangeType animate_type) { | 283 BookmarkBar::AnimateChangeType animate_type) { |
| 284 TRACE_EVENT0("ui::gtk", "BookmarkBarGtk::SetBookmarkBarState"); |
283 if (animate_type == BookmarkBar::ANIMATE_STATE_CHANGE && | 285 if (animate_type == BookmarkBar::ANIMATE_STATE_CHANGE && |
284 (state == BookmarkBar::DETACHED || | 286 (state == BookmarkBar::DETACHED || |
285 bookmark_bar_state_ == BookmarkBar::DETACHED)) { | 287 bookmark_bar_state_ == BookmarkBar::DETACHED)) { |
286 // TODO(estade): animate the transition between detached and non or remove | 288 // TODO(estade): animate the transition between detached and non or remove |
287 // detached entirely. | 289 // detached entirely. |
288 animate_type = BookmarkBar::DONT_ANIMATE_STATE_CHANGE; | 290 animate_type = BookmarkBar::DONT_ANIMATE_STATE_CHANGE; |
289 } | 291 } |
290 BookmarkBar::State old_state = bookmark_bar_state_; | 292 BookmarkBar::State old_state = bookmark_bar_state_; |
291 bookmark_bar_state_ = state; | 293 bookmark_bar_state_ = state; |
292 if (state == BookmarkBar::SHOW || state == BookmarkBar::DETACHED) | 294 if (state == BookmarkBar::SHOW || state == BookmarkBar::DETACHED) |
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1359 return TRUE; | 1361 return TRUE; |
1360 } | 1362 } |
1361 | 1363 |
1362 // Remove previous highlighting. | 1364 // Remove previous highlighting. |
1363 gtk_drag_unhighlight(button); | 1365 gtk_drag_unhighlight(button); |
1364 return ItemDraggedOverToolbar(context, index, time); | 1366 return ItemDraggedOverToolbar(context, index, time); |
1365 } | 1367 } |
1366 | 1368 |
1367 gboolean BookmarkBarGtk::OnEventBoxExpose(GtkWidget* widget, | 1369 gboolean BookmarkBarGtk::OnEventBoxExpose(GtkWidget* widget, |
1368 GdkEventExpose* event) { | 1370 GdkEventExpose* event) { |
| 1371 TRACE_EVENT0("ui::gtk", "BookmarkBarGtk::OnEventBoxExpose"); |
1369 GtkThemeService* theme_provider = theme_service_; | 1372 GtkThemeService* theme_provider = theme_service_; |
1370 | 1373 |
1371 // We don't need to render the toolbar image in GTK mode, except when | 1374 // We don't need to render the toolbar image in GTK mode, except when |
1372 // detached. | 1375 // detached. |
1373 if (theme_provider->UsingNativeTheme() && | 1376 if (theme_provider->UsingNativeTheme() && |
1374 bookmark_bar_state_ != BookmarkBar::DETACHED) | 1377 bookmark_bar_state_ != BookmarkBar::DETACHED) |
1375 return FALSE; | 1378 return FALSE; |
1376 | 1379 |
1377 if (bookmark_bar_state_ != BookmarkBar::DETACHED) { | 1380 if (bookmark_bar_state_ != BookmarkBar::DETACHED) { |
1378 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); | 1381 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1435 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { | 1438 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { |
1436 GtkDestDefaults dest_defaults = | 1439 GtkDestDefaults dest_defaults = |
1437 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : | 1440 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : |
1438 GTK_DEST_DEFAULT_DROP; | 1441 GTK_DEST_DEFAULT_DROP; |
1439 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); | 1442 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); |
1440 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, | 1443 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, |
1441 NULL, 0, kDragAction); | 1444 NULL, 0, kDragAction); |
1442 ui::SetDestTargetList(overflow_button_, kDestTargetList); | 1445 ui::SetDestTargetList(overflow_button_, kDestTargetList); |
1443 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); | 1446 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); |
1444 } | 1447 } |
OLD | NEW |