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" |
7 #include "base/command_line.h" | 8 #include "base/command_line.h" |
8 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/cocoa/browser_window_utils.h" | 13 #include "chrome/browser/ui/cocoa/browser_window_utils.h" |
12 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 14 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
13 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" | 15 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" |
14 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" | 16 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
15 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
17 #include "content/public/browser/native_web_keyboard_event.h" | 19 #include "content/public/browser/native_web_keyboard_event.h" |
18 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 } | 753 } |
752 | 754 |
753 void NativeAppWindowCocoa::RemoveObserver( | 755 void NativeAppWindowCocoa::RemoveObserver( |
754 web_modal::WebContentsModalDialogHostObserver* observer) { | 756 web_modal::WebContentsModalDialogHostObserver* observer) { |
755 NOTIMPLEMENTED(); | 757 NOTIMPLEMENTED(); |
756 } | 758 } |
757 | 759 |
758 void NativeAppWindowCocoa::WindowWillClose() { | 760 void NativeAppWindowCocoa::WindowWillClose() { |
759 [window_controller_ setAppWindow:NULL]; | 761 [window_controller_ setAppWindow:NULL]; |
760 shell_window_->OnNativeWindowChanged(); | 762 shell_window_->OnNativeWindowChanged(); |
761 shell_window_->OnNativeClose(); | 763 // On other platforms, the native window doesn't get destroyed synchronously. |
| 764 // We simulate that here so that ShellWindow can assume that it doesn't get |
| 765 // deleted immediately upon calling Close(). |
| 766 base::MessageLoop::current()->PostTask( |
| 767 FROM_HERE, |
| 768 base::Bind(&ShellWindow::OnNativeClose, |
| 769 base::Unretained(shell_window_))); |
762 } | 770 } |
763 | 771 |
764 void NativeAppWindowCocoa::WindowDidBecomeKey() { | 772 void NativeAppWindowCocoa::WindowDidBecomeKey() { |
765 content::RenderWidgetHostView* rwhv = | 773 content::RenderWidgetHostView* rwhv = |
766 web_contents()->GetRenderWidgetHostView(); | 774 web_contents()->GetRenderWidgetHostView(); |
767 if (rwhv) | 775 if (rwhv) |
768 rwhv->SetActive(true); | 776 rwhv->SetActive(true); |
769 shell_window_->OnNativeWindowActivated(); | 777 shell_window_->OnNativeWindowActivated(); |
770 } | 778 } |
771 | 779 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); | 850 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); |
843 return static_cast<ShellNSWindow*>(window); | 851 return static_cast<ShellNSWindow*>(window); |
844 } | 852 } |
845 | 853 |
846 // static | 854 // static |
847 NativeAppWindow* NativeAppWindow::Create( | 855 NativeAppWindow* NativeAppWindow::Create( |
848 ShellWindow* shell_window, | 856 ShellWindow* shell_window, |
849 const ShellWindow::CreateParams& params) { | 857 const ShellWindow::CreateParams& params) { |
850 return new NativeAppWindowCocoa(shell_window, params); | 858 return new NativeAppWindowCocoa(shell_window, params); |
851 } | 859 } |
OLD | NEW |