OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/native_app_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/extensions/native_app_window_gtk.h" |
6 | 6 |
| 7 #include "base/message_loop.h" |
7 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" | 10 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" |
10 #include "chrome/browser/ui/gtk/gtk_util.h" | 11 #include "chrome/browser/ui/gtk/gtk_util.h" |
11 #include "chrome/browser/ui/gtk/gtk_window_util.h" | 12 #include "chrome/browser/ui/gtk/gtk_window_util.h" |
12 #include "chrome/browser/web_applications/web_app.h" | 13 #include "chrome/browser/web_applications/web_app.h" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
15 #include "content/public/browser/render_widget_host_view.h" | 16 #include "content/public/browser/render_widget_host_view.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 void NativeAppWindowGtk::Close() { | 176 void NativeAppWindowGtk::Close() { |
176 shell_window_->OnNativeWindowChanged(); | 177 shell_window_->OnNativeWindowChanged(); |
177 | 178 |
178 // Cancel any pending callback from the window configure debounce timer. | 179 // Cancel any pending callback from the window configure debounce timer. |
179 window_configure_debounce_timer_.Stop(); | 180 window_configure_debounce_timer_.Stop(); |
180 | 181 |
181 GtkWidget* window = GTK_WIDGET(window_); | 182 GtkWidget* window = GTK_WIDGET(window_); |
182 // To help catch bugs in any event handlers that might get fired during the | 183 // To help catch bugs in any event handlers that might get fired during the |
183 // destruction, set window_ to NULL before any handlers will run. | 184 // destruction, set window_ to NULL before any handlers will run. |
184 window_ = NULL; | 185 window_ = NULL; |
| 186 gtk_widget_destroy(window); |
185 | 187 |
186 // OnNativeClose does a delete this so no other members should | 188 // On other platforms, the native window doesn't get destroyed synchronously. |
187 // be accessed after. gtk_widget_destroy is safe (and must | 189 // We simulate that here so that ShellWindow can assume that it doesn't get |
188 // be last). | 190 // deleted immediately upon calling Close(). |
189 shell_window_->OnNativeClose(); | 191 MessageLoop::current()->PostTask( |
190 gtk_widget_destroy(window); | 192 FROM_HERE, |
| 193 base::Bind(&ShellWindow::OnNativeClose, |
| 194 base::Unretained(shell_window_))); |
191 } | 195 } |
192 | 196 |
193 void NativeAppWindowGtk::Activate() { | 197 void NativeAppWindowGtk::Activate() { |
194 gtk_window_present(window_); | 198 gtk_window_present(window_); |
195 } | 199 } |
196 | 200 |
197 void NativeAppWindowGtk::Deactivate() { | 201 void NativeAppWindowGtk::Deactivate() { |
198 gdk_window_lower(gtk_widget_get_window(GTK_WIDGET(window_))); | 202 gdk_window_lower(gtk_widget_get_window(GTK_WIDGET(window_))); |
199 } | 203 } |
200 | 204 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 392 |
389 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); | 393 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); |
390 } | 394 } |
391 | 395 |
392 // static | 396 // static |
393 NativeAppWindow* NativeAppWindow::Create( | 397 NativeAppWindow* NativeAppWindow::Create( |
394 ShellWindow* shell_window, | 398 ShellWindow* shell_window, |
395 const ShellWindow::CreateParams& params) { | 399 const ShellWindow::CreateParams& params) { |
396 return new NativeAppWindowGtk(shell_window, params); | 400 return new NativeAppWindowGtk(shell_window, params); |
397 } | 401 } |
OLD | NEW |