Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/browser/ui/gtk/tab_contents_container_gtk.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/tab_contents_container_gtk.h" 5 #include "chrome/browser/ui/gtk/tab_contents_container_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" 10 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 gtk_widget_show(expanded_); 58 gtk_widget_show(expanded_);
59 gtk_widget_show(floating_.get()); 59 gtk_widget_show(floating_.get());
60 60
61 ViewIDUtil::SetDelegateForWidget(widget(), this); 61 ViewIDUtil::SetDelegateForWidget(widget(), this);
62 } 62 }
63 63
64 void TabContentsContainerGtk::SetTab(TabContentsWrapper* tab) { 64 void TabContentsContainerGtk::SetTab(TabContentsWrapper* tab) {
65 HideTab(tab_); 65 HideTab(tab_);
66 if (tab_) { 66 if (tab_) {
67 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, 67 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
68 Source<TabContents>(tab_->tab_contents())); 68 Source<TabContents>(tab_->tab_contents()));
69 } 69 }
70 70
71 tab_ = tab; 71 tab_ = tab;
72 72
73 if (tab_ == preview_) { 73 if (tab_ == preview_) {
74 // If the preview contents is becoming the new permanent tab contents, we 74 // If the preview contents is becoming the new permanent tab contents, we
75 // just reassign some pointers. 75 // just reassign some pointers.
76 preview_ = NULL; 76 preview_ = NULL;
77 } else if (tab_) { 77 } else if (tab_) {
78 // Otherwise we actually have to add it to the widget hierarchy. 78 // Otherwise we actually have to add it to the widget hierarchy.
79 PackTab(tab); 79 PackTab(tab);
80 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, 80 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
81 Source<TabContents>(tab_->tab_contents())); 81 Source<TabContents>(tab_->tab_contents()));
82 } 82 }
83 } 83 }
84 84
85 TabContentsWrapper* TabContentsContainerGtk::GetVisibleTab() { 85 TabContentsWrapper* TabContentsContainerGtk::GetVisibleTab() {
86 return preview_ ? preview_ : tab_; 86 return preview_ ? preview_ : tab_;
87 } 87 }
88 88
89 void TabContentsContainerGtk::SetPreview(TabContentsWrapper* preview) { 89 void TabContentsContainerGtk::SetPreview(TabContentsWrapper* preview) {
90 if (preview_) 90 if (preview_)
91 RemovePreview(); 91 RemovePreview();
92 else 92 else
93 HideTab(tab_); 93 HideTab(tab_);
94 94
95 preview_ = preview; 95 preview_ = preview;
96 96
97 PackTab(preview); 97 PackTab(preview);
98 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, 98 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
99 Source<TabContents>(preview_->tab_contents())); 99 Source<TabContents>(preview_->tab_contents()));
100 } 100 }
101 101
102 void TabContentsContainerGtk::RemovePreview() { 102 void TabContentsContainerGtk::RemovePreview() {
103 if (!preview_) 103 if (!preview_)
104 return; 104 return;
105 105
106 HideTab(preview_); 106 HideTab(preview_);
107 107
108 GtkWidget* preview_widget = preview_->tab_contents()->GetNativeView(); 108 GtkWidget* preview_widget = preview_->tab_contents()->GetNativeView();
109 if (preview_widget) 109 if (preview_widget)
110 gtk_container_remove(GTK_CONTAINER(expanded_), preview_widget); 110 gtk_container_remove(GTK_CONTAINER(expanded_), preview_widget);
111 111
112 registrar_.Remove(this, NotificationType::TAB_CONTENTS_DESTROYED, 112 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
113 Source<TabContents>(preview_->tab_contents())); 113 Source<TabContents>(preview_->tab_contents()));
114 preview_ = NULL; 114 preview_ = NULL;
115 } 115 }
116 116
117 void TabContentsContainerGtk::PopPreview() { 117 void TabContentsContainerGtk::PopPreview() {
118 if (!preview_) 118 if (!preview_)
119 return; 119 return;
120 120
121 RemovePreview(); 121 RemovePreview();
122 122
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 gfx::NativeView widget = tab->tab_contents()->GetNativeView(); 161 gfx::NativeView widget = tab->tab_contents()->GetNativeView();
162 162
163 // It is possible to detach an unrealized, unparented TabContents if you 163 // It is possible to detach an unrealized, unparented TabContents if you
164 // slow things down enough in valgrind. Might happen in the real world, too. 164 // slow things down enough in valgrind. Might happen in the real world, too.
165 if (widget && widget->parent) { 165 if (widget && widget->parent) {
166 DCHECK_EQ(widget->parent, expanded_); 166 DCHECK_EQ(widget->parent, expanded_);
167 gtk_container_remove(GTK_CONTAINER(expanded_), widget); 167 gtk_container_remove(GTK_CONTAINER(expanded_), widget);
168 } 168 }
169 } 169 }
170 170
171 void TabContentsContainerGtk::Observe(NotificationType type, 171 void TabContentsContainerGtk::Observe(int type,
172 const NotificationSource& source, 172 const NotificationSource& source,
173 const NotificationDetails& details) { 173 const NotificationDetails& details) {
174 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); 174 DCHECK(type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED);
175 175
176 TabContentsDestroyed(Source<TabContents>(source).ptr()); 176 TabContentsDestroyed(Source<TabContents>(source).ptr());
177 } 177 }
178 178
179 void TabContentsContainerGtk::TabContentsDestroyed(TabContents* contents) { 179 void TabContentsContainerGtk::TabContentsDestroyed(TabContents* contents) {
180 // Sometimes, a TabContents is destroyed before we know about it. This allows 180 // Sometimes, a TabContents is destroyed before we know about it. This allows
181 // us to clean up our state in case this happens. 181 // us to clean up our state in case this happens.
182 if (preview_ && contents == preview_->tab_contents()) 182 if (preview_ && contents == preview_->tab_contents())
183 PopPreview(); 183 PopPreview();
184 else if (tab_ && contents == tab_->tab_contents()) 184 else if (tab_ && contents == tab_->tab_contents())
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 g_value_set_int(&value, allocation->width - requisition.width); 236 g_value_set_int(&value, allocation->width - requisition.width);
237 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 237 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
238 status->widget(), "x", &value); 238 status->widget(), "x", &value);
239 239
240 int child_y = std::max(allocation->height - requisition.height, 0); 240 int child_y = std::max(allocation->height - requisition.height, 0);
241 g_value_set_int(&value, child_y + status->y_offset()); 241 g_value_set_int(&value, child_y + status->y_offset());
242 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 242 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
243 status->widget(), "y", &value); 243 status->widget(), "y", &value);
244 g_value_unset(&value); 244 g_value_unset(&value);
245 } 245 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tab_contents_container_gtk.h ('k') | chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698