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/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" | 10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" |
11 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 11 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
12 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" | 12 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" |
13 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" | 13 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
15 #include "content/public/browser/native_web_keyboard_event.h" | 15 #include "content/public/browser/native_web_keyboard_event.h" |
| 16 #include "content/public/browser/notification_source.h" |
| 17 #include "content/public/browser/notification_types.h" |
16 #include "content/public/browser/render_widget_host_view.h" | 18 #include "content/public/browser/render_widget_host_view.h" |
17 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
18 #include "content/public/browser/web_contents_view.h" | 20 #include "content/public/browser/web_contents_view.h" |
19 #include "third_party/skia/include/core/SkRegion.h" | 21 #include "third_party/skia/include/core/SkRegion.h" |
20 | 22 |
21 @interface NSWindow (NSPrivateApis) | 23 @interface NSWindow (NSPrivateApis) |
22 - (void)setBottomCornerRounded:(BOOL)rounded; | 24 - (void)setBottomCornerRounded:(BOOL)rounded; |
23 @end | 25 @end |
24 | 26 |
25 // Replicate specific 10.7 SDK declarations for building with prior SDKs. | 27 // Replicate specific 10.7 SDK declarations for building with prior SDKs. |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 InstallView(); | 257 InstallView(); |
256 | 258 |
257 [[window_controller_ window] setDelegate:window_controller_]; | 259 [[window_controller_ window] setDelegate:window_controller_]; |
258 [window_controller_ setAppWindow:this]; | 260 [window_controller_ setAppWindow:this]; |
259 | 261 |
260 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryCocoa( | 262 extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryCocoa( |
261 shell_window_->profile(), | 263 shell_window_->profile(), |
262 window, | 264 window, |
263 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, | 265 extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, |
264 shell_window)); | 266 shell_window)); |
| 267 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 268 content::Source<content::NavigationController>( |
| 269 &web_contents()->GetController())); |
265 } | 270 } |
266 | 271 |
267 void NativeAppWindowCocoa::InstallView() { | 272 void NativeAppWindowCocoa::InstallView() { |
268 NSView* view = web_contents()->GetView()->GetNativeView(); | 273 NSView* view = web_contents()->GetView()->GetNativeView(); |
269 if (has_frame_) { | 274 if (has_frame_) { |
270 [view setFrame:[[window() contentView] bounds]]; | 275 [view setFrame:[[window() contentView] bounds]]; |
271 [[window() contentView] addSubview:view]; | 276 [[window() contentView] addSubview:view]; |
272 if (!max_size_.IsEmpty() && min_size_ == max_size_) { | 277 if (!max_size_.IsEmpty() && min_size_ == max_size_) { |
273 [[window() standardWindowButton:NSWindowZoomButton] setEnabled:NO]; | 278 [[window() standardWindowButton:NSWindowZoomButton] setEnabled:NO]; |
274 [window() setShowsResizeIndicator:NO]; | 279 [window() setShowsResizeIndicator:NO]; |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 scoped_nsobject<NSView> controlRegion( | 636 scoped_nsobject<NSView> controlRegion( |
632 [[ControlRegionView alloc] initWithAppWindow:this]); | 637 [[ControlRegionView alloc] initWithAppWindow:this]); |
633 [controlRegion setFrame:NSMakeRect(iter->x(), | 638 [controlRegion setFrame:NSMakeRect(iter->x(), |
634 webViewHeight - iter->bottom(), | 639 webViewHeight - iter->bottom(), |
635 iter->width(), | 640 iter->width(), |
636 iter->height())]; | 641 iter->height())]; |
637 [webView addSubview:controlRegion]; | 642 [webView addSubview:controlRegion]; |
638 } | 643 } |
639 } | 644 } |
640 | 645 |
| 646 void NativeAppWindowCocoa::Observe( |
| 647 int type, |
| 648 const content::NotificationSource& source, |
| 649 const content::NotificationDetails& details) { |
| 650 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { |
| 651 web_contents()->Focus(); |
| 652 return; |
| 653 } |
| 654 NOTREACHED(); |
| 655 } |
| 656 |
641 void NativeAppWindowCocoa::FlashFrame(bool flash) { | 657 void NativeAppWindowCocoa::FlashFrame(bool flash) { |
642 if (flash) { | 658 if (flash) { |
643 attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest]; | 659 attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest]; |
644 } else { | 660 } else { |
645 [NSApp cancelUserAttentionRequest:attention_request_id_]; | 661 [NSApp cancelUserAttentionRequest:attention_request_id_]; |
646 attention_request_id_ = 0; | 662 attention_request_id_ = 0; |
647 } | 663 } |
648 } | 664 } |
649 | 665 |
650 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { | 666 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); | 758 CHECK(!window || [window isKindOfClass:[ShellNSWindow class]]); |
743 return static_cast<ShellNSWindow*>(window); | 759 return static_cast<ShellNSWindow*>(window); |
744 } | 760 } |
745 | 761 |
746 // static | 762 // static |
747 NativeAppWindow* NativeAppWindow::Create( | 763 NativeAppWindow* NativeAppWindow::Create( |
748 ShellWindow* shell_window, | 764 ShellWindow* shell_window, |
749 const ShellWindow::CreateParams& params) { | 765 const ShellWindow::CreateParams& params) { |
750 return new NativeAppWindowCocoa(shell_window, params); | 766 return new NativeAppWindowCocoa(shell_window, params); |
751 } | 767 } |
OLD | NEW |