| 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/cocoa/extensions/native_app_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/extensions/native_app_window_cocoa.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | |
| 8 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 9 #include "base/message_loop.h" | |
| 10 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/cocoa/browser_window_utils.h" | 10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 13 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 11 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
| 14 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" | 12 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" |
| 15 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" | 13 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
| 16 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 17 #include "content/public/browser/native_web_keyboard_event.h" | 15 #include "content/public/browser/native_web_keyboard_event.h" |
| 18 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 19 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 return gfx::Insets(); | 672 return gfx::Insets(); |
| 675 gfx::Rect frameRect(NSRectToCGRect([window() frame])); | 673 gfx::Rect frameRect(NSRectToCGRect([window() frame])); |
| 676 gfx::Rect contentRect( | 674 gfx::Rect contentRect( |
| 677 NSRectToCGRect([window() contentRectForFrameRect:[window() frame]])); | 675 NSRectToCGRect([window() contentRectForFrameRect:[window() frame]])); |
| 678 return frameRect.InsetsFrom(contentRect); | 676 return frameRect.InsetsFrom(contentRect); |
| 679 } | 677 } |
| 680 | 678 |
| 681 void NativeAppWindowCocoa::WindowWillClose() { | 679 void NativeAppWindowCocoa::WindowWillClose() { |
| 682 [window_controller_ setAppWindow:NULL]; | 680 [window_controller_ setAppWindow:NULL]; |
| 683 shell_window_->OnNativeWindowChanged(); | 681 shell_window_->OnNativeWindowChanged(); |
| 684 // On other platforms, the native window doesn't get destroyed synchronously. | 682 shell_window_->OnNativeClose(); |
| 685 // We simulate that here so that ShellWindow can assume that it doesn't get | |
| 686 // deleted immediately upon calling Close(). | |
| 687 MessageLoop::current()->PostTask( | |
| 688 FROM_HERE, | |
| 689 base::Bind(&ShellWindow::OnNativeClose, | |
| 690 base::Unretained(shell_window_))); | |
| 691 } | 683 } |
| 692 | 684 |
| 693 void NativeAppWindowCocoa::WindowDidBecomeKey() { | 685 void NativeAppWindowCocoa::WindowDidBecomeKey() { |
| 694 content::RenderWidgetHostView* rwhv = | 686 content::RenderWidgetHostView* rwhv = |
| 695 web_contents()->GetRenderWidgetHostView(); | 687 web_contents()->GetRenderWidgetHostView(); |
| 696 if (rwhv) | 688 if (rwhv) |
| 697 rwhv->SetActive(true); | 689 rwhv->SetActive(true); |
| 698 } | 690 } |
| 699 | 691 |
| 700 void NativeAppWindowCocoa::WindowDidResignKey() { | 692 void NativeAppWindowCocoa::WindowDidResignKey() { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); | 758 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); |
| 767 return static_cast<ShellNSWindow*>(window); | 759 return static_cast<ShellNSWindow*>(window); |
| 768 } | 760 } |
| 769 | 761 |
| 770 // static | 762 // static |
| 771 NativeAppWindow* NativeAppWindow::Create( | 763 NativeAppWindow* NativeAppWindow::Create( |
| 772 ShellWindow* shell_window, | 764 ShellWindow* shell_window, |
| 773 const ShellWindow::CreateParams& params) { | 765 const ShellWindow::CreateParams& params) { |
| 774 return new NativeAppWindowCocoa(shell_window, params); | 766 return new NativeAppWindowCocoa(shell_window, params); |
| 775 } | 767 } |
| OLD | NEW |