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