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 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" |
23 #include "chrome/browser/ui/panels/panel.h" | 24 #include "chrome/browser/ui/panels/panel.h" |
24 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" | 25 #include "chrome/browser/ui/panels/panel_browser_window_cocoa.h" |
25 #include "chrome/browser/ui/panels/panel_manager.h" | 26 #include "chrome/browser/ui/panels/panel_manager.h" |
26 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" | 27 #include "chrome/browser/ui/panels/panel_settings_menu_model.h" |
27 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" | 28 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" |
28 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 29 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
29 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.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 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 172 } |
172 | 173 |
173 - (void)updateTitleBar { | 174 - (void)updateTitleBar { |
174 NSString* newTitle = base::SysUTF16ToNSString( | 175 NSString* newTitle = base::SysUTF16ToNSString( |
175 windowShim_->browser()->GetWindowTitleForCurrentTab()); | 176 windowShim_->browser()->GetWindowTitleForCurrentTab()); |
176 pendingWindowTitle_.reset( | 177 pendingWindowTitle_.reset( |
177 [BrowserWindowUtils scheduleReplaceOldTitle:pendingWindowTitle_.get() | 178 [BrowserWindowUtils scheduleReplaceOldTitle:pendingWindowTitle_.get() |
178 withNewTitle:newTitle | 179 withNewTitle:newTitle |
179 forWindow:[self window]]); | 180 forWindow:[self window]]); |
180 [titlebar_view_ setTitle:newTitle]; | 181 [titlebar_view_ setTitle:newTitle]; |
| 182 |
| 183 NSImage* newIcon = mac::FaviconForTabContents( |
| 184 windowShim_->browser()->GetSelectedTabContentsWrapper()); |
| 185 [titlebar_view_ setIcon:newIcon]; |
| 186 |
| 187 [titlebar_view_ updateIconAndTitleLayout]; |
181 } | 188 } |
182 | 189 |
183 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { | 190 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { |
184 NSView* contentView = [[self window] contentView]; | 191 NSView* contentView = [[self window] contentView]; |
185 [contentView addSubview:[findBarCocoaController view]]; | 192 [contentView addSubview:[findBarCocoaController view]]; |
186 | 193 |
187 CGFloat maxY = NSMaxY([contentView frame]); | 194 CGFloat maxY = NSMaxY([contentView frame]); |
188 CGFloat maxWidth = NSWidth([contentView frame]); | 195 CGFloat maxWidth = NSWidth([contentView frame]); |
189 [findBarCocoaController positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; | 196 [findBarCocoaController positionFindBarViewAtMaxY:maxY maxWidth:maxWidth]; |
190 } | 197 } |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 NSView* titlebar = [self titlebarView]; | 419 NSView* titlebar = [self titlebarView]; |
413 return NSHeight([titlebar convertRect:[titlebar bounds] toView:nil]); | 420 return NSHeight([titlebar convertRect:[titlebar bounds] toView:nil]); |
414 } | 421 } |
415 // TestingAPI interface implementation | 422 // TestingAPI interface implementation |
416 | 423 |
417 + (void)enableBoundsAnimationNotifications { | 424 + (void)enableBoundsAnimationNotifications { |
418 g_reportAnimationStatus = YES; | 425 g_reportAnimationStatus = YES; |
419 } | 426 } |
420 | 427 |
421 @end | 428 @end |
OLD | NEW |