| 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" | 9 #include "chrome/browser/ui/gtk/extensions/extension_keybinding_registry_gtk.h" |
| 10 #include "chrome/browser/ui/gtk/gtk_util.h" | 10 #include "chrome/browser/ui/gtk/gtk_util.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 295 |
| 296 gfx::Point NativeAppWindowGtk::GetDialogPosition(const gfx::Size& size) { | 296 gfx::Point NativeAppWindowGtk::GetDialogPosition(const gfx::Size& size) { |
| 297 gint current_width = 0; | 297 gint current_width = 0; |
| 298 gint current_height = 0; | 298 gint current_height = 0; |
| 299 gtk_window_get_size(window_, ¤t_width, ¤t_height); | 299 gtk_window_get_size(window_, ¤t_width, ¤t_height); |
| 300 return gfx::Point(current_width / 2 - size.width() / 2, | 300 return gfx::Point(current_width / 2 - size.width() / 2, |
| 301 current_height / 2 - size.height() / 2); | 301 current_height / 2 - size.height() / 2); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void NativeAppWindowGtk::AddObserver( | 304 void NativeAppWindowGtk::AddObserver( |
| 305 WebContentsModalDialogHostObserver* observer) { | 305 web_modal::WebContentsModalDialogHostObserver* observer) { |
| 306 observer_list_.AddObserver(observer); | 306 observer_list_.AddObserver(observer); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void NativeAppWindowGtk::RemoveObserver( | 309 void NativeAppWindowGtk::RemoveObserver( |
| 310 WebContentsModalDialogHostObserver* observer) { | 310 web_modal::WebContentsModalDialogHostObserver* observer) { |
| 311 observer_list_.RemoveObserver(observer); | 311 observer_list_.RemoveObserver(observer); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void NativeAppWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { | 314 void NativeAppWindowGtk::ActiveWindowChanged(GdkWindow* active_window) { |
| 315 // Do nothing if we're in the process of closing the browser window. | 315 // Do nothing if we're in the process of closing the browser window. |
| 316 if (!window_) | 316 if (!window_) |
| 317 return; | 317 return; |
| 318 | 318 |
| 319 is_active_ = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window; | 319 is_active_ = gtk_widget_get_window(GTK_WIDGET(window_)) == active_window; |
| 320 } | 320 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 base::TimeDelta::FromMilliseconds(kDebounceTimeoutMilliseconds), this, | 354 base::TimeDelta::FromMilliseconds(kDebounceTimeoutMilliseconds), this, |
| 355 &NativeAppWindowGtk::OnDebouncedBoundsChanged); | 355 &NativeAppWindowGtk::OnDebouncedBoundsChanged); |
| 356 | 356 |
| 357 return FALSE; | 357 return FALSE; |
| 358 } | 358 } |
| 359 | 359 |
| 360 void NativeAppWindowGtk::OnDebouncedBoundsChanged() { | 360 void NativeAppWindowGtk::OnDebouncedBoundsChanged() { |
| 361 gtk_window_util::UpdateWindowPosition(this, &bounds_, &restored_bounds_); | 361 gtk_window_util::UpdateWindowPosition(this, &bounds_, &restored_bounds_); |
| 362 shell_window_->OnNativeWindowChanged(); | 362 shell_window_->OnNativeWindowChanged(); |
| 363 | 363 |
| 364 FOR_EACH_OBSERVER(WebContentsModalDialogHostObserver, | 364 FOR_EACH_OBSERVER(web_modal::WebContentsModalDialogHostObserver, |
| 365 observer_list_, | 365 observer_list_, |
| 366 OnPositionRequiresUpdate()); | 366 OnPositionRequiresUpdate()); |
| 367 } | 367 } |
| 368 | 368 |
| 369 gboolean NativeAppWindowGtk::OnWindowState(GtkWidget* sender, | 369 gboolean NativeAppWindowGtk::OnWindowState(GtkWidget* sender, |
| 370 GdkEventWindowState* event) { | 370 GdkEventWindowState* event) { |
| 371 state_ = event->new_window_state; | 371 state_ = event->new_window_state; |
| 372 | 372 |
| 373 if (content_thinks_its_fullscreen_ && | 373 if (content_thinks_its_fullscreen_ && |
| 374 !(state_ & GDK_WINDOW_STATE_FULLSCREEN)) { | 374 !(state_ & GDK_WINDOW_STATE_FULLSCREEN)) { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 | 522 |
| 523 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); | 523 draggable_region_.reset(ShellWindow::RawDraggableRegionsToSkRegion(regions)); |
| 524 } | 524 } |
| 525 | 525 |
| 526 // static | 526 // static |
| 527 NativeAppWindow* NativeAppWindow::Create( | 527 NativeAppWindow* NativeAppWindow::Create( |
| 528 ShellWindow* shell_window, | 528 ShellWindow* shell_window, |
| 529 const ShellWindow::CreateParams& params) { | 529 const ShellWindow::CreateParams& params) { |
| 530 return new NativeAppWindowGtk(shell_window, params); | 530 return new NativeAppWindowGtk(shell_window, params); |
| 531 } | 531 } |
| OLD | NEW |