| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/apps/native_app_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h" |
| 6 | 6 |
| 7 #include "apps/app_shim/extension_app_shim_handler_mac.h" | 7 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 : app_window_(app_window), | 330 : app_window_(app_window), |
| 331 has_frame_(params.frame == AppWindow::FRAME_CHROME), | 331 has_frame_(params.frame == AppWindow::FRAME_CHROME), |
| 332 is_hidden_with_app_(false), | 332 is_hidden_with_app_(false), |
| 333 is_maximized_(false), | 333 is_maximized_(false), |
| 334 is_fullscreen_(false), | 334 is_fullscreen_(false), |
| 335 is_resizable_(params.resizable), | 335 is_resizable_(params.resizable), |
| 336 shows_resize_controls_(true), | 336 shows_resize_controls_(true), |
| 337 shows_fullscreen_controls_(true), | 337 shows_fullscreen_controls_(true), |
| 338 has_frame_color_(params.has_frame_color), | 338 has_frame_color_(params.has_frame_color), |
| 339 active_frame_color_(params.active_frame_color), | 339 active_frame_color_(params.active_frame_color), |
| 340 inactive_frame_color_(params.inactive_frame_color), | 340 inactive_frame_color_(params.inactive_frame_color) { |
| 341 attention_request_id_(0) { | |
| 342 Observe(WebContents()); | 341 Observe(WebContents()); |
| 343 | 342 |
| 344 base::scoped_nsobject<NSWindow> window; | 343 base::scoped_nsobject<NSWindow> window; |
| 345 Class window_class; | 344 Class window_class; |
| 346 if (has_frame_) { | 345 if (has_frame_) { |
| 347 window_class = has_frame_color_ ? | 346 window_class = has_frame_color_ ? |
| 348 [ShellCustomFrameNSWindow class] : [ShellNSWindow class]; | 347 [ShellCustomFrameNSWindow class] : [ShellNSWindow class]; |
| 349 } else { | 348 } else { |
| 350 window_class = [ShellFramelessNSWindow class]; | 349 window_class = [ShellFramelessNSWindow class]; |
| 351 } | 350 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 NSRect frame = [window() frame]; | 561 NSRect frame = [window() frame]; |
| 563 gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame)); | 562 gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame)); |
| 564 bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame)); | 563 bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame)); |
| 565 return bounds; | 564 return bounds; |
| 566 } | 565 } |
| 567 | 566 |
| 568 void NativeAppWindowCocoa::Show() { | 567 void NativeAppWindowCocoa::Show() { |
| 569 if (is_hidden_with_app_) { | 568 if (is_hidden_with_app_) { |
| 570 // If there is a shim to gently request attention, return here. Otherwise | 569 // If there is a shim to gently request attention, return here. Otherwise |
| 571 // show the window as usual. | 570 // show the window as usual. |
| 572 if (apps::ExtensionAppShimHandler::RequestUserAttentionForWindow( | 571 if (apps::ExtensionAppShimHandler::ActivateAndRequestUserAttentionForWindow( |
| 573 app_window_)) { | 572 app_window_)) { |
| 574 return; | 573 return; |
| 575 } | 574 } |
| 576 } | 575 } |
| 577 | 576 |
| 578 [window_controller_ showWindow:nil]; | 577 [window_controller_ showWindow:nil]; |
| 579 Activate(); | 578 Activate(); |
| 580 } | 579 } |
| 581 | 580 |
| 582 void NativeAppWindowCocoa::ShowInactive() { | 581 void NativeAppWindowCocoa::ShowInactive() { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 [[ControlRegionView alloc] initWithFrame:NSZeroRect]); | 720 [[ControlRegionView alloc] initWithFrame:NSZeroRect]); |
| 722 [controlRegion setFrame:NSMakeRect(iter->x(), | 721 [controlRegion setFrame:NSMakeRect(iter->x(), |
| 723 webViewHeight - iter->bottom(), | 722 webViewHeight - iter->bottom(), |
| 724 iter->width(), | 723 iter->width(), |
| 725 iter->height())]; | 724 iter->height())]; |
| 726 [webView addSubview:controlRegion]; | 725 [webView addSubview:controlRegion]; |
| 727 } | 726 } |
| 728 } | 727 } |
| 729 | 728 |
| 730 void NativeAppWindowCocoa::FlashFrame(bool flash) { | 729 void NativeAppWindowCocoa::FlashFrame(bool flash) { |
| 731 if (flash) { | 730 apps::ExtensionAppShimHandler::RequestUserAttentionForWindow( |
| 732 attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest]; | 731 app_window_, |
| 733 } else { | 732 flash ? apps::APP_SHIM_ATTENTION_CRITICAL |
| 734 [NSApp cancelUserAttentionRequest:attention_request_id_]; | 733 : apps::APP_SHIM_ATTENTION_CANCEL); |
| 735 attention_request_id_ = 0; | |
| 736 } | |
| 737 } | 734 } |
| 738 | 735 |
| 739 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { | 736 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { |
| 740 return [window() level] == AlwaysOnTopWindowLevel(); | 737 return [window() level] == AlwaysOnTopWindowLevel(); |
| 741 } | 738 } |
| 742 | 739 |
| 743 void NativeAppWindowCocoa::RenderViewCreated(content::RenderViewHost* rvh) { | 740 void NativeAppWindowCocoa::RenderViewCreated(content::RenderViewHost* rvh) { |
| 744 if (IsActive()) | 741 if (IsActive()) |
| 745 WebContents()->RestoreFocus(); | 742 WebContents()->RestoreFocus(); |
| 746 } | 743 } |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 } | 985 } |
| 989 | 986 |
| 990 void NativeAppWindowCocoa::UpdateRestoredBounds() { | 987 void NativeAppWindowCocoa::UpdateRestoredBounds() { |
| 991 if (IsRestored(*this)) | 988 if (IsRestored(*this)) |
| 992 restored_bounds_ = [window() frame]; | 989 restored_bounds_ = [window() frame]; |
| 993 } | 990 } |
| 994 | 991 |
| 995 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { | 992 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { |
| 996 [window() orderOut:window_controller_]; | 993 [window() orderOut:window_controller_]; |
| 997 } | 994 } |
| OLD | NEW |