| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/mac_util.h" | 5 #include "base/mac_util.h" |
| 6 #include "base/scoped_nsdisable_screen_updates.h" | 6 #include "base/scoped_nsdisable_screen_updates.h" |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" // IDC_* | 8 #include "chrome/app/chrome_dll_resource.h" // IDC_* |
| 9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
| 10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/encoding_menu_controller.h" | 12 #include "chrome/browser/encoding_menu_controller.h" |
| 13 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents_view.h" | 15 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 16 #include "chrome/browser/tabs/tab_strip_model.h" | 16 #include "chrome/browser/tabs/tab_strip_model.h" |
| 17 #import "chrome/browser/cocoa/bookmark_bar_controller.h" | 17 #import "chrome/browser/cocoa/bookmark_bar_controller.h" |
| 18 #import "chrome/browser/cocoa/browser_window_cocoa.h" | 18 #import "chrome/browser/cocoa/browser_window_cocoa.h" |
| 19 #import "chrome/browser/cocoa/browser_window_controller.h" | 19 #import "chrome/browser/cocoa/browser_window_controller.h" |
| 20 #import "chrome/browser/cocoa/download_shelf_controller.h" |
| 20 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" | 21 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" |
| 21 #include "chrome/browser/cocoa/find_bar_bridge.h" | 22 #include "chrome/browser/cocoa/find_bar_bridge.h" |
| 22 #import "chrome/browser/cocoa/status_bubble_mac.h" | 23 #import "chrome/browser/cocoa/status_bubble_mac.h" |
| 23 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" | 24 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" |
| 24 #import "chrome/browser/cocoa/tab_strip_view.h" | 25 #import "chrome/browser/cocoa/tab_strip_view.h" |
| 25 #import "chrome/browser/cocoa/tab_strip_controller.h" | 26 #import "chrome/browser/cocoa/tab_strip_controller.h" |
| 26 #import "chrome/browser/cocoa/tab_view.h" | 27 #import "chrome/browser/cocoa/tab_view.h" |
| 27 #import "chrome/browser/cocoa/toolbar_controller.h" | 28 #import "chrome/browser/cocoa/toolbar_controller.h" |
| 28 #include "chrome/common/pref_service.h" | 29 #include "chrome/common/pref_service.h" |
| 29 | 30 |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 // Get the new controller by asking the new window for its delegate. | 514 // Get the new controller by asking the new window for its delegate. |
| 514 BrowserWindowController* controller = | 515 BrowserWindowController* controller = |
| 515 [newBrowser->window()->GetNativeHandle() delegate]; | 516 [newBrowser->window()->GetNativeHandle() delegate]; |
| 516 DCHECK(controller && [controller isKindOfClass:[TabWindowController class]]); | 517 DCHECK(controller && [controller isKindOfClass:[TabWindowController class]]); |
| 517 | 518 |
| 518 // Force the added tab to the right size (remove stretching.) | 519 // Force the added tab to the right size (remove stretching.) |
| 519 tabRect.size.height = [TabStripController defaultTabHeight]; | 520 tabRect.size.height = [TabStripController defaultTabHeight]; |
| 520 | 521 |
| 521 // And make sure we use the correct frame in the new view. | 522 // And make sure we use the correct frame in the new view. |
| 522 [[controller tabStripController] setFrameOfSelectedTab:tabRect]; | 523 [[controller tabStripController] setFrameOfSelectedTab:tabRect]; |
| 523 | |
| 524 return controller; | 524 return controller; |
| 525 } | 525 } |
| 526 | 526 |
| 527 | 527 |
| 528 - (void)insertPlaceholderForTab:(TabView*)tab | 528 - (void)insertPlaceholderForTab:(TabView*)tab |
| 529 frame:(NSRect)frame | 529 frame:(NSRect)frame |
| 530 yStretchiness:(CGFloat)yStretchiness { | 530 yStretchiness:(CGFloat)yStretchiness { |
| 531 [tabStripController_ insertPlaceholderForTab:tab | 531 [tabStripController_ insertPlaceholderForTab:tab |
| 532 frame:frame | 532 frame:frame |
| 533 yStretchiness:yStretchiness]; | 533 yStretchiness:yStretchiness]; |
| 534 } | 534 } |
| 535 | 535 |
| 536 - (void)removePlaceholder { | 536 - (void)removePlaceholder { |
| 537 [tabStripController_ insertPlaceholderForTab:nil | 537 [tabStripController_ insertPlaceholderForTab:nil |
| 538 frame:NSZeroRect | 538 frame:NSZeroRect |
| 539 yStretchiness:0]; | 539 yStretchiness:0]; |
| 540 } | 540 } |
| 541 | 541 |
| 542 - (BOOL)isBookmarkBarVisible { | 542 - (BOOL)isBookmarkBarVisible { |
| 543 return [bookmarkBarController_ isBookmarkBarVisible]; | 543 return [bookmarkBarController_ isBookmarkBarVisible]; |
| 544 | 544 |
| 545 } | 545 } |
| 546 | 546 |
| 547 - (void)toggleBookmarkBar { | 547 - (void)toggleBookmarkBar { |
| 548 [bookmarkBarController_ toggleBookmarkBar]; | 548 [bookmarkBarController_ toggleBookmarkBar]; |
| 549 } | 549 } |
| 550 | 550 |
| 551 - (BOOL)isDownloadShelfVisible { |
| 552 return downloadShelfController_ != nil && |
| 553 [downloadShelfController_ isVisible]; |
| 554 } |
| 555 |
| 556 - (DownloadShelfController*)downloadShelf { |
| 557 if (!downloadShelfController_.get()) { |
| 558 downloadShelfController_.reset([[DownloadShelfController alloc] |
| 559 initWithBrowser:browser_.get() contentArea:[self tabContentArea]]); |
| 560 } |
| 561 return downloadShelfController_; |
| 562 } |
| 563 |
| 551 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { | 564 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { |
| 552 // Shouldn't call addFindBar twice. | 565 // Shouldn't call addFindBar twice. |
| 553 DCHECK(!findBarCocoaController_.get()); | 566 DCHECK(!findBarCocoaController_.get()); |
| 554 | 567 |
| 555 // Create a controller for the findbar. | 568 // Create a controller for the findbar. |
| 556 findBarCocoaController_.reset([findBarCocoaController retain]); | 569 findBarCocoaController_.reset([findBarCocoaController retain]); |
| 557 [[[self window] contentView] addSubview:[findBarCocoaController_ view]]; | 570 [[[self window] contentView] addSubview:[findBarCocoaController_ view]]; |
| 558 [findBarCocoaController_ positionFindBarView:[self tabContentArea]]; | 571 [findBarCocoaController_ positionFindBarView:[self tabContentArea]]; |
| 559 } | 572 } |
| 560 | 573 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 [win setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; | 691 [win setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; |
| 679 [win setContentBorderThickness:kWindowGradientHeight forEdge:NSMaxYEdge]; | 692 [win setContentBorderThickness:kWindowGradientHeight forEdge:NSMaxYEdge]; |
| 680 } | 693 } |
| 681 } | 694 } |
| 682 | 695 |
| 683 - (void)tabContentAreaFrameChanged:(id)sender { | 696 - (void)tabContentAreaFrameChanged:(id)sender { |
| 684 // TODO(rohitrao): This is triggered by window resizes also. Make | 697 // TODO(rohitrao): This is triggered by window resizes also. Make |
| 685 // sure we aren't doing anything wasteful in those cases. | 698 // sure we aren't doing anything wasteful in those cases. |
| 686 [bookmarkBarController_ resizeBookmarkBar]; | 699 [bookmarkBarController_ resizeBookmarkBar]; |
| 687 | 700 |
| 688 if (findBarCocoaController_.get()) { | 701 [downloadShelfController_ resizeDownloadShelf]; |
| 689 [findBarCocoaController_ positionFindBarView:[self tabContentArea]]; | 702 |
| 690 } | 703 [findBarCocoaController_ positionFindBarView:[self tabContentArea]]; |
| 691 } | 704 } |
| 692 | 705 |
| 693 - (void)saveWindowPositionIfNeeded { | 706 - (void)saveWindowPositionIfNeeded { |
| 694 if (browser_ != BrowserList::GetLastActive()) | 707 if (browser_ != BrowserList::GetLastActive()) |
| 695 return; | 708 return; |
| 696 | 709 |
| 697 if (!g_browser_process || !g_browser_process->local_state() || | 710 if (!g_browser_process || !g_browser_process->local_state() || |
| 698 !browser_->ShouldSaveWindowPlacement()) | 711 !browser_->ShouldSaveWindowPlacement()) |
| 699 return; | 712 return; |
| 700 | 713 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 browser_->ExecuteCommand(command); | 779 browser_->ExecuteCommand(command); |
| 767 } | 780 } |
| 768 | 781 |
| 769 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { | 782 - (id)windowWillReturnFieldEditor:(NSWindow*)sender toObject:(id)obj { |
| 770 // Ask the toolbar controller if it wants to return a custom field editor | 783 // Ask the toolbar controller if it wants to return a custom field editor |
| 771 // for the specific object. | 784 // for the specific object. |
| 772 return [toolbarController_ customFieldEditorForObject:obj]; | 785 return [toolbarController_ customFieldEditorForObject:obj]; |
| 773 } | 786 } |
| 774 | 787 |
| 775 @end | 788 @end |
| OLD | NEW |