Chromium Code Reviews| 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" |
| 11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 12 #include "chrome/app/chrome_command_ids.h" // IDC_* | 12 #include "chrome/app/chrome_command_ids.h" // IDC_* |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/tabs/tab_strip_model.h" | 14 #include "chrome/browser/tabs/tab_strip_model.h" |
| 15 #include "chrome/browser/themes/theme_service.h" | 15 #include "chrome/browser/themes/theme_service.h" |
| 16 #include "chrome/browser/themes/theme_service_factory.h" | 16 #include "chrome/browser/themes/theme_service_factory.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 18 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 19 #import "chrome/browser/ui/cocoa/event_utils.h" | 19 #import "chrome/browser/ui/cocoa/event_utils.h" |
| 20 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 20 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 21 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 21 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 22 #import "chrome/browser/ui/cocoa/menu_controller.h" | 22 #import "chrome/browser/ui/cocoa/menu_controller.h" |
| 23 #include "chrome/browser/ui/panels/panel.h" | 23 #include "chrome/browser/ui/panels/panel.h" |
| 24 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" | 24 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" |
| 25 #include "chrome/browser/ui/panels/panel_manager.h" | 25 #include "chrome/browser/ui/panels/panel_manager.h" |
| 26 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" | 26 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" |
| 27 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" | 27 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" |
| 28 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 28 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "content/browser/renderer_host/render_widget_host_view.h" | |
| 30 #include "content/browser/tab_contents/tab_contents.h" | 31 #include "content/browser/tab_contents/tab_contents.h" |
| 31 #include "content/common/notification_service.h" | 32 #include "content/common/notification_service.h" |
| 32 | 33 |
| 33 const int kMinimumWindowSize = 1; | 34 const int kMinimumWindowSize = 1; |
| 34 const double kBoundsChangeAnimationDuration = 0.25; | 35 const double kBoundsChangeAnimationDuration = 0.25; |
| 35 | 36 |
| 36 // Replicate specific 10.6 SDK declarations for building with prior SDKs. | 37 // Replicate specific 10.6 SDK declarations for building with prior SDKs. |
| 37 #if !defined(MAC_OS_X_VERSION_10_6) || \ | 38 #if !defined(MAC_OS_X_VERSION_10_6) || \ |
| 38 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | 39 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 |
| 39 | 40 |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 Panel::ExpansionState newExpansionState = | 406 Panel::ExpansionState newExpansionState = |
| 406 (panel->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED | 407 (panel->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED |
| 407 : Panel::MINIMIZED; | 408 : Panel::MINIMIZED; |
| 408 panel->SetExpansionState(newExpansionState); | 409 panel->SetExpansionState(newExpansionState); |
| 409 } | 410 } |
| 410 | 411 |
| 411 - (int)titlebarHeightInScreeenCoordinates { | 412 - (int)titlebarHeightInScreeenCoordinates { |
| 412 NSView* titlebar = [self titlebarView]; | 413 NSView* titlebar = [self titlebarView]; |
| 413 return NSHeight([titlebar convertRect:[titlebar bounds] toView:nil]); | 414 return NSHeight([titlebar convertRect:[titlebar bounds] toView:nil]); |
| 414 } | 415 } |
| 416 | |
| 417 // TODO(dcheng): These two selectors are almost copy-and-paste from | |
| 418 // BrowserWindowController. Figure out the appropriate way of code sharing, | |
| 419 // whether it's refactoring more things into BrowserWindowUtils or making a | |
| 420 // common base controller for browser windows. | |
| 421 - (void)windowDidBecomeKey:(NSNotification*)notification { | |
| 422 if (TabContents* contents = | |
| 423 windowShim_->browser()->GetSelectedTabContents()) { | |
| 424 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) | |
| 425 rwhv->SetActive(true); | |
| 426 } | |
| 427 } | |
| 428 | |
| 429 - (void)windowDidResignKey:(NSNotification*)notification { | |
| 430 if ([NSApp isActive] && ([NSApp keyWindow] == [self window])) | |
|
Dmitry Titov
2011/09/20 23:36:00
could you figure out why we do these checks and ad
| |
| 431 return; | |
| 432 | |
| 433 if (TabContents* contents = | |
| 434 windowShim_->browser()->GetSelectedTabContents()) { | |
| 435 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) | |
| 436 rwhv->SetActive(false); | |
| 437 } | |
| 438 } | |
| 439 | |
| 415 // TestingAPI interface implementation | 440 // TestingAPI interface implementation |
| 416 | 441 |
| 417 + (void)enableBoundsAnimationNotifications { | 442 + (void)enableBoundsAnimationNotifications { |
| 418 g_reportAnimationStatus = YES; | 443 g_reportAnimationStatus = YES; |
| 419 } | 444 } |
| 420 | 445 |
| 421 @end | 446 @end |
| OLD | NEW |