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

Side by Side Diff: chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.cc

Issue 6881107: Rework the way Widget::Init works: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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/views/tab_contents/tab_contents_view_gtk.h" 5 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 } // namespace 97 } // namespace
98 98
99 // static 99 // static
100 TabContentsView* TabContentsView::Create(TabContents* tab_contents) { 100 TabContentsView* TabContentsView::Create(TabContents* tab_contents) {
101 return new TabContentsViewGtk(tab_contents); 101 return new TabContentsViewGtk(tab_contents);
102 } 102 }
103 103
104 TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents) 104 TabContentsViewGtk::TabContentsViewGtk(TabContents* tab_contents)
105 : TabContentsView(tab_contents), 105 : TabContentsView(tab_contents),
106 views::WidgetGtk(TYPE_CHILD),
107 sad_tab_(NULL), 106 sad_tab_(NULL),
108 ignore_next_char_event_(false) { 107 ignore_next_char_event_(false) {
109 drag_source_.reset(new TabContentsDragSource(this)); 108 drag_source_.reset(new TabContentsDragSource(this));
110 last_focused_view_storage_id_ = 109 last_focused_view_storage_id_ =
111 views::ViewStorage::GetInstance()->CreateStorageID(); 110 views::ViewStorage::GetInstance()->CreateStorageID();
112 } 111 }
113 112
114 TabContentsViewGtk::~TabContentsViewGtk() { 113 TabContentsViewGtk::~TabContentsViewGtk() {
115 // Make sure to remove any stored view we may still have in the ViewStorage. 114 // Make sure to remove any stored view we may still have in the ViewStorage.
116 // 115 //
(...skipping 26 matching lines...) Expand all
143 ConstrainedWindowGtk* constrained_window) { 142 ConstrainedWindowGtk* constrained_window) {
144 std::vector<ConstrainedWindowGtk*>::iterator item = 143 std::vector<ConstrainedWindowGtk*>::iterator item =
145 find(constrained_windows_.begin(), constrained_windows_.end(), 144 find(constrained_windows_.begin(), constrained_windows_.end(),
146 constrained_window); 145 constrained_window);
147 DCHECK(item != constrained_windows_.end()); 146 DCHECK(item != constrained_windows_.end());
148 RemoveChild((*item)->widget()); 147 RemoveChild((*item)->widget());
149 constrained_windows_.erase(item); 148 constrained_windows_.erase(item);
150 } 149 }
151 150
152 void TabContentsViewGtk::CreateView(const gfx::Size& initial_size) { 151 void TabContentsViewGtk::CreateView(const gfx::Size& initial_size) {
153 set_delete_on_destroy(false); 152 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_CONTROL);
154 WidgetGtk::Init(NULL, gfx::Rect(0, 0, initial_size.width(), 153 params.delete_on_destroy = false;
155 initial_size.height())); 154 params.bounds = gfx::Rect(initial_size);
155 GetWidget()->Init(params);
156 // We need to own the widget in order to attach/detach the native view 156 // We need to own the widget in order to attach/detach the native view
157 // to container. 157 // to container.
158 gtk_object_ref(GTK_OBJECT(GetNativeView())); 158 gtk_object_ref(GTK_OBJECT(GetNativeView()));
159 } 159 }
160 160
161 RenderWidgetHostView* TabContentsViewGtk::CreateViewForWidget( 161 RenderWidgetHostView* TabContentsViewGtk::CreateViewForWidget(
162 RenderWidgetHost* render_widget_host) { 162 RenderWidgetHost* render_widget_host) {
163 if (render_widget_host->view()) { 163 if (render_widget_host->view()) {
164 // During testing, the view will already be set up in most cases to the 164 // During testing, the view will already be set up in most cases to the
165 // test view, so we don't want to clobber it with a real one. To verify that 165 // test view, so we don't want to clobber it with a real one. To verify that
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 // not NULL, else our delegate. 479 // not NULL, else our delegate.
480 gboolean TabContentsViewGtk::OnMouseMove(GtkWidget* widget, 480 gboolean TabContentsViewGtk::OnMouseMove(GtkWidget* widget,
481 GdkEventMotion* event) { 481 GdkEventMotion* event) {
482 if (sad_tab_ != NULL) 482 if (sad_tab_ != NULL)
483 WidgetGtk::OnMotionNotify(widget, event); 483 WidgetGtk::OnMotionNotify(widget, event);
484 else if (tab_contents()->delegate()) 484 else if (tab_contents()->delegate())
485 tab_contents()->delegate()->ContentsMouseEvent( 485 tab_contents()->delegate()->ContentsMouseEvent(
486 tab_contents(), views::Screen::GetCursorScreenPoint(), true); 486 tab_contents(), views::Screen::GetCursorScreenPoint(), true);
487 return FALSE; 487 return FALSE;
488 } 488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698