| 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 "base/time.h" | 12 #include "base/time.h" |
| 13 #include "chrome/app/chrome_command_ids.h" // IDC_* | 13 #include "chrome/app/chrome_command_ids.h" // IDC_* |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/tabs/tab_strip_model.h" | 15 #include "chrome/browser/tabs/tab_strip_model.h" |
| 16 #include "chrome/browser/themes/theme_service.h" | 16 #include "chrome/browser/themes/theme_service.h" |
| 17 #include "chrome/browser/themes/theme_service_factory.h" | 17 #include "chrome/browser/themes/theme_service_factory.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
| 20 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 20 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 21 #import "chrome/browser/ui/cocoa/event_utils.h" | 21 #import "chrome/browser/ui/cocoa/event_utils.h" |
| 22 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 22 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 23 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 23 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 24 #import "chrome/browser/ui/cocoa/menu_controller.h" | 24 #import "chrome/browser/ui/cocoa/menu_controller.h" |
| 25 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" | 25 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" |
| 26 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
| 26 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" | 27 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" |
| 27 #include "chrome/browser/ui/panels/panel.h" | 28 #include "chrome/browser/ui/panels/panel.h" |
| 28 #include "chrome/browser/ui/panels/panel_bounds_animation.h" | 29 #include "chrome/browser/ui/panels/panel_bounds_animation.h" |
| 29 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" | 30 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" |
| 30 #include "chrome/browser/ui/panels/panel_manager.h" | 31 #include "chrome/browser/ui/panels/panel_manager.h" |
| 31 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" | 32 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" |
| 32 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" | 33 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" |
| 33 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 34 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
| 34 #include "chrome/common/chrome_notification_types.h" | 35 #include "chrome/common/chrome_notification_types.h" |
| 35 #include "content/browser/renderer_host/render_widget_host_view.h" | 36 #include "content/browser/renderer_host/render_widget_host_view.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 @implementation PanelWindowControllerCocoa | 73 @implementation PanelWindowControllerCocoa |
| 73 | 74 |
| 74 - (id)initWithBrowserWindow:(PanelBrowserWindowCocoa*)window { | 75 - (id)initWithBrowserWindow:(PanelBrowserWindowCocoa*)window { |
| 75 NSString* nibpath = | 76 NSString* nibpath = |
| 76 [base::mac::MainAppBundle() pathForResource:@"Panel" ofType:@"nib"]; | 77 [base::mac::MainAppBundle() pathForResource:@"Panel" ofType:@"nib"]; |
| 77 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { | 78 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { |
| 78 windowShim_.reset(window); | 79 windowShim_.reset(window); |
| 79 animateOnBoundsChange_ = YES; | 80 animateOnBoundsChange_ = YES; |
| 80 } | 81 } |
| 81 contentsController_.reset( | 82 contentsController_.reset( |
| 82 [[TabContentsController alloc] initWithContents:nil | 83 [[TabContentsController alloc] initWithContents:nil]); |
| 83 delegate:nil]); | |
| 84 return self; | 84 return self; |
| 85 } | 85 } |
| 86 | 86 |
| 87 - (void)dealloc { | 87 - (void)dealloc { |
| 88 if (windowTrackingArea_.get()) { | 88 if (windowTrackingArea_.get()) { |
| 89 [[[[self window] contentView] superview] | 89 [[[[self window] contentView] superview] |
| 90 removeTrackingArea:windowTrackingArea_.get()]; | 90 removeTrackingArea:windowTrackingArea_.get()]; |
| 91 } | 91 } |
| 92 [super dealloc]; | 92 [super dealloc]; |
| 93 } | 93 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 [findBarCocoaController positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; | 251 [findBarCocoaController positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; |
| 252 } | 252 } |
| 253 | 253 |
| 254 - (void)tabInserted:(WebContents*)contents { | 254 - (void)tabInserted:(WebContents*)contents { |
| 255 [contentsController_ changeWebContents:contents]; | 255 [contentsController_ changeWebContents:contents]; |
| 256 DCHECK(![[contentsController_ view] isHidden]); | 256 DCHECK(![[contentsController_ view] isHidden]); |
| 257 } | 257 } |
| 258 | 258 |
| 259 - (void)tabDetached:(WebContents*)contents { | 259 - (void)tabDetached:(WebContents*)contents { |
| 260 DCHECK(contents == [contentsController_ webContents]); | 260 DCHECK(contents == [contentsController_ webContents]); |
| 261 [contentsController_ changeWebContents:NULL]; | 261 [contentsController_ changeWebContents:nil]; |
| 262 [[contentsController_ view] setHidden:YES]; | 262 [[contentsController_ view] setHidden:YES]; |
| 263 } | 263 } |
| 264 | 264 |
| 265 - (PanelTitlebarViewCocoa*)titlebarView { | 265 - (PanelTitlebarViewCocoa*)titlebarView { |
| 266 return titlebar_view_; | 266 return titlebar_view_; |
| 267 } | 267 } |
| 268 | 268 |
| 269 // Called to validate menu and toolbar items when this window is key. All the | 269 // Called to validate menu and toolbar items when this window is key. All the |
| 270 // items we care about have been set with the |-commandDispatch:| or | 270 // items we care about have been set with the |-commandDispatch:| or |
| 271 // |-commandDispatchUsingKeyModifiers:| actions and a target of FirstResponder | 271 // |-commandDispatchUsingKeyModifiers:| actions and a target of FirstResponder |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 - (BOOL)canBecomeKeyWindow { | 603 - (BOOL)canBecomeKeyWindow { |
| 604 // Panel can only gain focus if it is expanded. Minimized panels do not | 604 // Panel can only gain focus if it is expanded. Minimized panels do not |
| 605 // participate in Cmd-~ rotation. | 605 // participate in Cmd-~ rotation. |
| 606 // TODO(dimich): If it will be ever desired to expand/focus the Panel on | 606 // TODO(dimich): If it will be ever desired to expand/focus the Panel on |
| 607 // keyboard navigation or via main menu, the care should be taken to avoid | 607 // keyboard navigation or via main menu, the care should be taken to avoid |
| 608 // cases when minimized Panel is getting keyboard input, invisibly. | 608 // cases when minimized Panel is getting keyboard input, invisibly. |
| 609 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; | 609 return windowShim_->panel()->expansion_state() == Panel::EXPANDED; |
| 610 } | 610 } |
| 611 | 611 |
| 612 @end | 612 @end |
| OLD | NEW |