| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/panels/panel_window_controller_cocoa.h" | 5 #include "chrome/browser/ui/panels/panel_window_controller_cocoa.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" | 26 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" |
| 27 #include "chrome/browser/ui/panels/panel.h" | 27 #include "chrome/browser/ui/panels/panel.h" |
| 28 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" | 28 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" |
| 29 #include "chrome/browser/ui/panels/panel_manager.h" | 29 #include "chrome/browser/ui/panels/panel_manager.h" |
| 30 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" | 30 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" |
| 31 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" | 31 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" |
| 32 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 32 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 33 #include "chrome/common/chrome_notification_types.h" | 33 #include "chrome/common/chrome_notification_types.h" |
| 34 #include "content/browser/renderer_host/render_widget_host_view.h" | 34 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 35 #include "content/browser/tab_contents/tab_contents.h" | 35 #include "content/browser/tab_contents/tab_contents.h" |
| 36 #include "content/common/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 37 #include "grit/ui_resources.h" | 37 #include "grit/ui_resources.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/gfx/image/image.h" | 39 #include "ui/gfx/image/image.h" |
| 40 #include "ui/gfx/mac/nsimage_cache.h" | 40 #include "ui/gfx/mac/nsimage_cache.h" |
| 41 | 41 |
| 42 const int kMinimumWindowSize = 1; | 42 const int kMinimumWindowSize = 1; |
| 43 const double kBoundsChangeAnimationDuration = 0.25; | 43 const double kBoundsChangeAnimationDuration = 0.25; |
| 44 | 44 |
| 45 // Delay before click on a titlebar is allowed to minimize the panel | 45 // Delay before click on a titlebar is allowed to minimize the panel |
| 46 // after the 'draw attention' mode has been cleared. | 46 // after the 'draw attention' mode has been cleared. |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 435 |
| 436 [boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking]; | 436 [boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking]; |
| 437 [boundsAnimation_ setDuration: kBoundsChangeAnimationDuration]; | 437 [boundsAnimation_ setDuration: kBoundsChangeAnimationDuration]; |
| 438 [boundsAnimation_ startAnimation]; | 438 [boundsAnimation_ startAnimation]; |
| 439 } | 439 } |
| 440 | 440 |
| 441 - (void)animationDidEnd:(NSAnimation*)animation { | 441 - (void)animationDidEnd:(NSAnimation*)animation { |
| 442 if (windowShim_->panel()->expansion_state() == Panel::EXPANDED) | 442 if (windowShim_->panel()->expansion_state() == Panel::EXPANDED) |
| 443 [self enableTabContentsViewAutosizing]; | 443 [self enableTabContentsViewAutosizing]; |
| 444 | 444 |
| 445 NotificationService::current()->Notify( | 445 content::NotificationService::current()->Notify( |
| 446 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, | 446 chrome::NOTIFICATION_PANEL_BOUNDS_ANIMATIONS_FINISHED, |
| 447 content::Source<Panel>(windowShim_->panel()), | 447 content::Source<Panel>(windowShim_->panel()), |
| 448 NotificationService::NoDetails()); | 448 content::NotificationService::NoDetails()); |
| 449 } | 449 } |
| 450 | 450 |
| 451 - (void)terminateBoundsAnimation { | 451 - (void)terminateBoundsAnimation { |
| 452 if (!boundsAnimation_) | 452 if (!boundsAnimation_) |
| 453 return; | 453 return; |
| 454 [boundsAnimation_ stopAnimation]; | 454 [boundsAnimation_ stopAnimation]; |
| 455 [boundsAnimation_ setDelegate:nil]; | 455 [boundsAnimation_ setDelegate:nil]; |
| 456 [boundsAnimation_ release]; | 456 [boundsAnimation_ release]; |
| 457 boundsAnimation_ = nil; | 457 boundsAnimation_ = nil; |
| 458 } | 458 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 // being already expanded and drawing attention - in this case, we don't | 505 // being already expanded and drawing attention - in this case, we don't |
| 506 // want to minimize it on subsequent mouseUp. | 506 // want to minimize it on subsequent mouseUp. |
| 507 // We use time interval because the window may become key in various ways | 507 // We use time interval because the window may become key in various ways |
| 508 // (via keyboard for example) which are not distinguishable at this point. | 508 // (via keyboard for example) which are not distinguishable at this point. |
| 509 // Apparently this interval is not affecting the user in other cases. | 509 // Apparently this interval is not affecting the user in other cases. |
| 510 disableMinimizeUntilTime_ = | 510 disableMinimizeUntilTime_ = |
| 511 base::Time::Now() + kSuspendMinimizeOnClickIntervalMs; | 511 base::Time::Now() + kSuspendMinimizeOnClickIntervalMs; |
| 512 [[self titlebarView] stopDrawingAttention]; | 512 [[self titlebarView] stopDrawingAttention]; |
| 513 } | 513 } |
| 514 | 514 |
| 515 NotificationService::current()->Notify( | 515 content::NotificationService::current()->Notify( |
| 516 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | 516 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
| 517 content::Source<Panel>(windowShim_->panel()), | 517 content::Source<Panel>(windowShim_->panel()), |
| 518 NotificationService::NoDetails()); | 518 content::NotificationService::NoDetails()); |
| 519 } | 519 } |
| 520 | 520 |
| 521 - (void)windowDidResignKey:(NSNotification*)notification { | 521 - (void)windowDidResignKey:(NSNotification*)notification { |
| 522 // If our app is still active and we're still the key window, ignore this | 522 // If our app is still active and we're still the key window, ignore this |
| 523 // message, since it just means that a menu extra (on the "system status bar") | 523 // message, since it just means that a menu extra (on the "system status bar") |
| 524 // was activated; we'll get another |-windowDidResignKey| if we ever really | 524 // was activated; we'll get another |-windowDidResignKey| if we ever really |
| 525 // lose key window status. | 525 // lose key window status. |
| 526 if ([NSApp isActive] && ([NSApp keyWindow] == [self window])) | 526 if ([NSApp isActive] && ([NSApp keyWindow] == [self window])) |
| 527 return; | 527 return; |
| 528 | 528 |
| 529 // We need to deactivate the controls (in the "WebView"). To do this, get the | 529 // We need to deactivate the controls (in the "WebView"). To do this, get the |
| 530 // selected TabContents's RenderWidgetHostView and tell it to deactivate. | 530 // selected TabContents's RenderWidgetHostView and tell it to deactivate. |
| 531 if (TabContents* contents = | 531 if (TabContents* contents = |
| 532 windowShim_->browser()->GetSelectedTabContents()) { | 532 windowShim_->browser()->GetSelectedTabContents()) { |
| 533 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) | 533 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) |
| 534 rwhv->SetActive(false); | 534 rwhv->SetActive(false); |
| 535 } | 535 } |
| 536 | 536 |
| 537 NotificationService::current()->Notify( | 537 content::NotificationService::current()->Notify( |
| 538 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, | 538 chrome::NOTIFICATION_PANEL_CHANGED_ACTIVE_STATUS, |
| 539 content::Source<Panel>(windowShim_->panel()), | 539 content::Source<Panel>(windowShim_->panel()), |
| 540 NotificationService::NoDetails()); | 540 content::NotificationService::NoDetails()); |
| 541 } | 541 } |
| 542 | 542 |
| 543 @end | 543 @end |
| OLD | NEW |