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 // We need to activate the controls (in the "WebView"). To do this, get the |
| 423 // selected TabContents's RenderWidgetHostViewMac and tell it to activate. |
| 424 if (TabContents* contents = |
| 425 windowShim_->browser()->GetSelectedTabContents()) { |
| 426 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) |
| 427 rwhv->SetActive(true); |
| 428 } |
| 429 } |
| 430 |
| 431 - (void)windowDidResignKey:(NSNotification*)notification { |
| 432 // If our app is still active and we're still the key window, ignore this |
| 433 // message, since it just means that a menu extra (on the "system status bar") |
| 434 // was activated; we'll get another |-windowDidResignKey| if we ever really |
| 435 // lose key window status. |
| 436 if ([NSApp isActive] && ([NSApp keyWindow] == [self window])) |
| 437 return; |
| 438 |
| 439 // We need to deactivate the controls (in the "WebView"). To do this, get the |
| 440 // selected TabContents's RenderWidgetHostView and tell it to deactivate. |
| 441 if (TabContents* contents = |
| 442 windowShim_->browser()->GetSelectedTabContents()) { |
| 443 if (RenderWidgetHostView* rwhv = contents->GetRenderWidgetHostView()) |
| 444 rwhv->SetActive(false); |
| 445 } |
| 446 } |
| 447 |
415 // TestingAPI interface implementation | 448 // TestingAPI interface implementation |
416 | 449 |
417 + (void)enableBoundsAnimationNotifications { | 450 + (void)enableBoundsAnimationNotifications { |
418 g_reportAnimationStatus = YES; | 451 g_reportAnimationStatus = YES; |
419 } | 452 } |
420 | 453 |
421 @end | 454 @end |
OLD | NEW |