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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "ui/base/dragdrop/gtk_dnd_util.h" | 46 #include "ui/base/dragdrop/gtk_dnd_util.h" |
47 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
48 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
49 #include "ui/gfx/canvas_skia_paint.h" | 49 #include "ui/gfx/canvas_skia_paint.h" |
50 #include "ui/gfx/gtk_util.h" | 50 #include "ui/gfx/gtk_util.h" |
51 #include "ui/gfx/image/cairo_cached_surface.h" | 51 #include "ui/gfx/image/cairo_cached_surface.h" |
52 #include "ui/gfx/image/image.h" | 52 #include "ui/gfx/image/image.h" |
53 | 53 |
54 using content::PageNavigator; | 54 using content::PageNavigator; |
55 using content::UserMetricsAction; | 55 using content::UserMetricsAction; |
| 56 using content::WebContents; |
56 | 57 |
57 namespace { | 58 namespace { |
58 | 59 |
59 // The showing height of the bar. | 60 // The showing height of the bar. |
60 const int kBookmarkBarHeight = 29; | 61 const int kBookmarkBarHeight = 29; |
61 | 62 |
62 // Padding for when the bookmark bar is detached. | 63 // Padding for when the bookmark bar is detached. |
63 const int kTopBottomNTPPadding = 12; | 64 const int kTopBottomNTPPadding = 12; |
64 const int kLeftRightNTPPadding = 8; | 65 const int kLeftRightNTPPadding = 8; |
65 | 66 |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 gtk_widget_queue_draw(event_box_.get()); | 672 gtk_widget_queue_draw(event_box_.get()); |
672 } | 673 } |
673 } | 674 } |
674 | 675 |
675 bool BookmarkBarGtk::GetTabContentsSize(gfx::Size* size) { | 676 bool BookmarkBarGtk::GetTabContentsSize(gfx::Size* size) { |
676 Browser* browser = browser_; | 677 Browser* browser = browser_; |
677 if (!browser) { | 678 if (!browser) { |
678 NOTREACHED(); | 679 NOTREACHED(); |
679 return false; | 680 return false; |
680 } | 681 } |
681 TabContents* tab_contents = browser->GetSelectedTabContents(); | 682 WebContents* web_contents = browser->GetSelectedWebContents(); |
682 if (!tab_contents) { | 683 if (!web_contents) { |
683 // It is possible to have a browser but no TabContents while under testing, | 684 // It is possible to have a browser but no TabContents while under testing, |
684 // so don't NOTREACHED() and error the program. | 685 // so don't NOTREACHED() and error the program. |
685 return false; | 686 return false; |
686 } | 687 } |
687 if (!tab_contents->GetView()) { | 688 if (!web_contents->GetView()) { |
688 NOTREACHED(); | 689 NOTREACHED(); |
689 return false; | 690 return false; |
690 } | 691 } |
691 *size = tab_contents->GetView()->GetContainerSize(); | 692 *size = web_contents->GetView()->GetContainerSize(); |
692 return true; | 693 return true; |
693 } | 694 } |
694 | 695 |
695 void BookmarkBarGtk::StartThrobbingAfterAllocation(GtkWidget* item) { | 696 void BookmarkBarGtk::StartThrobbingAfterAllocation(GtkWidget* item) { |
696 g_signal_connect_after( | 697 g_signal_connect_after( |
697 item, "size-allocate", G_CALLBACK(OnItemAllocateThunk), this); | 698 item, "size-allocate", G_CALLBACK(OnItemAllocateThunk), this); |
698 } | 699 } |
699 | 700 |
700 void BookmarkBarGtk::OnItemAllocate(GtkWidget* item, | 701 void BookmarkBarGtk::OnItemAllocate(GtkWidget* item, |
701 GtkAllocation* allocation) { | 702 GtkAllocation* allocation) { |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { | 1440 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { |
1440 GtkDestDefaults dest_defaults = | 1441 GtkDestDefaults dest_defaults = |
1441 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : | 1442 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : |
1442 GTK_DEST_DEFAULT_DROP; | 1443 GTK_DEST_DEFAULT_DROP; |
1443 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); | 1444 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); |
1444 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, | 1445 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, |
1445 NULL, 0, kDragAction); | 1446 NULL, 0, kDragAction); |
1446 ui::SetDestTargetList(overflow_button_, kDestTargetList); | 1447 ui::SetDestTargetList(overflow_button_, kDestTargetList); |
1447 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); | 1448 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); |
1448 } | 1449 } |
OLD | NEW |