| 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 <gdk/gdkx.h> | 7 #include <gdk/gdkx.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | |
| 11 #include "base/message_loop/message_pump_gtk.h" | 10 #include "base/message_loop/message_pump_gtk.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" | 13 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" |
| 15 #include "chrome/browser/ui/gtk/gtk_util.h" | 14 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_window_util.h" | 15 #include "chrome/browser/ui/gtk/gtk_window_util.h" |
| 17 #include "chrome/browser/web_applications/web_app.h" | 16 #include "chrome/browser/web_applications/web_app.h" |
| 18 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 19 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/render_widget_host_view.h" | 19 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 void NativeAppWindowGtk::Close() { | 236 void NativeAppWindowGtk::Close() { |
| 238 shell_window_->OnNativeWindowChanged(); | 237 shell_window_->OnNativeWindowChanged(); |
| 239 | 238 |
| 240 // Cancel any pending callback from the window configure debounce timer. | 239 // Cancel any pending callback from the window configure debounce timer. |
| 241 window_configure_debounce_timer_.Stop(); | 240 window_configure_debounce_timer_.Stop(); |
| 242 | 241 |
| 243 GtkWidget* window = GTK_WIDGET(window_); | 242 GtkWidget* window = GTK_WIDGET(window_); |
| 244 // To help catch bugs in any event handlers that might get fired during the | 243 // To help catch bugs in any event handlers that might get fired during the |
| 245 // destruction, set window_ to NULL before any handlers will run. | 244 // destruction, set window_ to NULL before any handlers will run. |
| 246 window_ = NULL; | 245 window_ = NULL; |
| 246 |
| 247 // OnNativeClose does a delete this so no other members should |
| 248 // be accessed after. gtk_widget_destroy is safe (and must |
| 249 // be last). |
| 250 shell_window_->OnNativeClose(); |
| 247 gtk_widget_destroy(window); | 251 gtk_widget_destroy(window); |
| 248 | |
| 249 // On other platforms, the native window doesn't get destroyed synchronously. | |
| 250 // We simulate that here so that ShellWindow can assume that it doesn't get | |
| 251 // deleted immediately upon calling Close(). | |
| 252 base::MessageLoop::current()->PostTask( | |
| 253 FROM_HERE, | |
| 254 base::Bind(&ShellWindow::OnNativeClose, | |
| 255 base::Unretained(shell_window_))); | |
| 256 } | 252 } |
| 257 | 253 |
| 258 void NativeAppWindowGtk::Activate() { | 254 void NativeAppWindowGtk::Activate() { |
| 259 gtk_window_present(window_); | 255 gtk_window_present(window_); |
| 260 } | 256 } |
| 261 | 257 |
| 262 void NativeAppWindowGtk::Deactivate() { | 258 void NativeAppWindowGtk::Deactivate() { |
| 263 gdk_window_lower(gtk_widget_get_window(GTK_WIDGET(window_))); | 259 gdk_window_lower(gtk_widget_get_window(GTK_WIDGET(window_))); |
| 264 } | 260 } |
| 265 | 261 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 | 620 |
| 625 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); | 621 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); |
| 626 } | 622 } |
| 627 | 623 |
| 628 // static | 624 // static |
| 629 NativeAppWindow* NativeAppWindow::Create( | 625 NativeAppWindow* NativeAppWindow::Create( |
| 630 ShellWindow* shell_window, | 626 ShellWindow* shell_window, |
| 631 const ShellWindow::CreateParams& params) { | 627 const ShellWindow::CreateParams& params) { |
| 632 return new NativeAppWindowGtk(shell_window, params); | 628 return new NativeAppWindowGtk(shell_window, params); |
| 633 } | 629 } |
| OLD | NEW |