Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm

Issue 461303002: [Mac] Bounce app shims when app windows request attention. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 : app_window_(app_window), 331 : app_window_(app_window),
332 has_frame_(params.frame == AppWindow::FRAME_CHROME), 332 has_frame_(params.frame == AppWindow::FRAME_CHROME),
333 is_hidden_with_app_(false), 333 is_hidden_with_app_(false),
334 is_maximized_(false), 334 is_maximized_(false),
335 is_fullscreen_(false), 335 is_fullscreen_(false),
336 is_resizable_(params.resizable), 336 is_resizable_(params.resizable),
337 shows_resize_controls_(true), 337 shows_resize_controls_(true),
338 shows_fullscreen_controls_(true), 338 shows_fullscreen_controls_(true),
339 has_frame_color_(params.has_frame_color), 339 has_frame_color_(params.has_frame_color),
340 active_frame_color_(params.active_frame_color), 340 active_frame_color_(params.active_frame_color),
341 inactive_frame_color_(params.inactive_frame_color), 341 inactive_frame_color_(params.inactive_frame_color) {
342 attention_request_id_(0) {
343 Observe(WebContents()); 342 Observe(WebContents());
344 343
345 base::scoped_nsobject<NSWindow> window; 344 base::scoped_nsobject<NSWindow> window;
346 Class window_class; 345 Class window_class;
347 if (has_frame_) { 346 if (has_frame_) {
348 window_class = has_frame_color_ ? 347 window_class = has_frame_color_ ?
349 [ShellCustomFrameNSWindow class] : [ShellNSWindow class]; 348 [ShellCustomFrameNSWindow class] : [ShellNSWindow class];
350 } else { 349 } else {
351 window_class = [ShellFramelessNSWindow class]; 350 window_class = [ShellFramelessNSWindow class];
352 } 351 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 NSRect frame = [window() frame]; 562 NSRect frame = [window() frame];
564 gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame)); 563 gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame));
565 bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame)); 564 bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame));
566 return bounds; 565 return bounds;
567 } 566 }
568 567
569 void NativeAppWindowCocoa::Show() { 568 void NativeAppWindowCocoa::Show() {
570 if (is_hidden_with_app_) { 569 if (is_hidden_with_app_) {
571 // If there is a shim to gently request attention, return here. Otherwise 570 // If there is a shim to gently request attention, return here. Otherwise
572 // show the window as usual. 571 // show the window as usual.
573 if (apps::ExtensionAppShimHandler::RequestUserAttentionForWindow( 572 if (apps::ExtensionAppShimHandler::ActivateAndRequestUserAttentionForWindow(
574 app_window_)) { 573 app_window_)) {
575 return; 574 return;
576 } 575 }
577 } 576 }
578 577
579 [window_controller_ showWindow:nil]; 578 [window_controller_ showWindow:nil];
580 Activate(); 579 Activate();
581 } 580 }
582 581
583 void NativeAppWindowCocoa::ShowInactive() { 582 void NativeAppWindowCocoa::ShowInactive() {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 [[ControlRegionView alloc] initWithFrame:NSZeroRect]); 721 [[ControlRegionView alloc] initWithFrame:NSZeroRect]);
723 [controlRegion setFrame:NSMakeRect(iter->x(), 722 [controlRegion setFrame:NSMakeRect(iter->x(),
724 webViewHeight - iter->bottom(), 723 webViewHeight - iter->bottom(),
725 iter->width(), 724 iter->width(),
726 iter->height())]; 725 iter->height())];
727 [webView addSubview:controlRegion]; 726 [webView addSubview:controlRegion];
728 } 727 }
729 } 728 }
730 729
731 void NativeAppWindowCocoa::FlashFrame(bool flash) { 730 void NativeAppWindowCocoa::FlashFrame(bool flash) {
732 if (flash) { 731 apps::ExtensionAppShimHandler::RequestUserAttentionForWindow(
733 attention_request_id_ = [NSApp requestUserAttention:NSInformationalRequest]; 732 app_window_,
734 } else { 733 flash ? apps::APP_SHIM_ATTENTION_CRITICAL
735 [NSApp cancelUserAttentionRequest:attention_request_id_]; 734 : apps::APP_SHIM_ATTENTION_CANCEL);
736 attention_request_id_ = 0;
737 }
738 } 735 }
739 736
740 bool NativeAppWindowCocoa::IsAlwaysOnTop() const { 737 bool NativeAppWindowCocoa::IsAlwaysOnTop() const {
741 return [window() level] == AlwaysOnTopWindowLevel(); 738 return [window() level] == AlwaysOnTopWindowLevel();
742 } 739 }
743 740
744 void NativeAppWindowCocoa::RenderViewCreated(content::RenderViewHost* rvh) { 741 void NativeAppWindowCocoa::RenderViewCreated(content::RenderViewHost* rvh) {
745 if (IsActive()) 742 if (IsActive())
746 WebContents()->RestoreFocus(); 743 WebContents()->RestoreFocus();
747 } 744 }
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 986 }
990 987
991 void NativeAppWindowCocoa::UpdateRestoredBounds() { 988 void NativeAppWindowCocoa::UpdateRestoredBounds() {
992 if (IsRestored(*this)) 989 if (IsRestored(*this))
993 restored_bounds_ = [window() frame]; 990 restored_bounds_ = [window() frame];
994 } 991 }
995 992
996 void NativeAppWindowCocoa::HideWithoutMarkingHidden() { 993 void NativeAppWindowCocoa::HideWithoutMarkingHidden() {
997 [window() orderOut:window_controller_]; 994 [window() orderOut:window_controller_];
998 } 995 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698