| 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/sys_string_conversions.h" | 6 #include "base/sys_string_conversions.h" |
| 7 #include "chrome/app/chrome_dll_resource.h" // IDC_* | 7 #include "chrome/app/chrome_dll_resource.h" // IDC_* |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/tab_contents/web_contents.h" | 10 #include "chrome/browser/tab_contents/web_contents.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 browser_.release(); | 136 browser_.release(); |
| 137 [super dealloc]; | 137 [super dealloc]; |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Access the C++ bridge between the NSWindow and the rest of Chromium | 140 // Access the C++ bridge between the NSWindow and the rest of Chromium |
| 141 - (BrowserWindow*)browserWindow { | 141 - (BrowserWindow*)browserWindow { |
| 142 return windowShim_.get(); | 142 return windowShim_.get(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 - (void)destroyBrowser { | 145 - (void)destroyBrowser { |
| 146 [NSApp removeWindowsItem:[self window]]; |
| 147 |
| 146 // We need the window to go away now. | 148 // We need the window to go away now. |
| 147 [self autorelease]; | 149 [self autorelease]; |
| 148 } | 150 } |
| 149 | 151 |
| 150 // Called when the window meets the criteria to be closed (ie, | 152 // Called when the window meets the criteria to be closed (ie, |
| 151 // |-windowShoudlClose:| returns YES). We must be careful to preserve the | 153 // |-windowShoudlClose:| returns YES). We must be careful to preserve the |
| 152 // semantics of BrowserWindow::Close() and not call the Browser's dtor directly | 154 // semantics of BrowserWindow::Close() and not call the Browser's dtor directly |
| 153 // from this method. | 155 // from this method. |
| 154 - (void)windowWillClose:(NSNotification *)notification { | 156 - (void)windowWillClose:(NSNotification *)notification { |
| 155 DCHECK(!browser_->tabstrip_model()->count()); | 157 DCHECK(!browser_->tabstrip_model()->count()); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 | 418 |
| 417 // Update various elements that are interested in knowing the current | 419 // Update various elements that are interested in knowing the current |
| 418 // TabContents. | 420 // TabContents. |
| 419 #if 0 | 421 #if 0 |
| 420 // TODO(pinkerton):Update as more things become window-specific | 422 // TODO(pinkerton):Update as more things become window-specific |
| 421 infobar_container_->ChangeTabContents(new_contents); | 423 infobar_container_->ChangeTabContents(new_contents); |
| 422 contents_container_->SetTabContents(new_contents); | 424 contents_container_->SetTabContents(new_contents); |
| 423 #endif | 425 #endif |
| 424 newContents->DidBecomeSelected(); | 426 newContents->DidBecomeSelected(); |
| 425 | 427 |
| 428 // Change the entry in the Window menu to match the title of the |
| 429 // currently selected tab. This will create an entry if one does |
| 430 // not already exist. |
| 431 [NSApp changeWindowsItem:[self window] |
| 432 title:base::SysUTF16ToNSString(newContents->GetTitle()) |
| 433 filename:NO]; |
| 434 |
| 426 if (BrowserList::GetLastActive() == browser_ && | 435 if (BrowserList::GetLastActive() == browser_ && |
| 427 !browser_->tabstrip_model()->closing_all() && | 436 !browser_->tabstrip_model()->closing_all() && |
| 428 newContents->AsWebContents()) { | 437 newContents->AsWebContents()) { |
| 429 newContents->AsWebContents()->view()->RestoreFocus(); | 438 newContents->AsWebContents()->view()->RestoreFocus(); |
| 430 } | 439 } |
| 431 | 440 |
| 432 #if 0 | 441 #if 0 |
| 433 // TODO(pinkerton):Update as more things become window-specific | 442 // TODO(pinkerton):Update as more things become window-specific |
| 434 // Update all the UI bits. | 443 // Update all the UI bits. |
| 435 UpdateTitleBar(); | 444 UpdateTitleBar(); |
| 436 toolbar_->SetProfile(new_contents->profile()); | 445 toolbar_->SetProfile(new_contents->profile()); |
| 437 UpdateToolbar(new_contents, true); | 446 UpdateToolbar(new_contents, true); |
| 438 UpdateUIForContents(new_contents); | 447 UpdateUIForContents(new_contents); |
| 439 #endif | 448 #endif |
| 440 } | 449 } |
| 441 | 450 |
| 451 - (void)tabChangedWithContents:(TabContents*)contents |
| 452 atIndex:(NSInteger)index |
| 453 loadingOnly:(BOOL)loading { |
| 454 // Change the entry in the Window menu to match the new title of the tab, |
| 455 // but only if this is the currently selected tab. |
| 456 if (index == browser_->tabstrip_model()->selected_index()) { |
| 457 [NSApp changeWindowsItem:[self window] |
| 458 title:base::SysUTF16ToNSString(contents->GetTitle()) |
| 459 filename:NO]; |
| 460 } |
| 461 } |
| 462 |
| 442 @end | 463 @end |
| 443 | 464 |
| 444 | 465 |
| 445 @interface NSWindow (NSPrivateApis) | 466 @interface NSWindow (NSPrivateApis) |
| 446 // Note: These functions are private, use -[NSObject respondsToSelector:] | 467 // Note: These functions are private, use -[NSObject respondsToSelector:] |
| 447 // before calling them. | 468 // before calling them. |
| 448 | 469 |
| 449 - (void)setAutorecalculatesContentBorderThickness:(BOOL)b | 470 - (void)setAutorecalculatesContentBorderThickness:(BOOL)b |
| 450 forEdge:(NSRectEdge)e; | 471 forEdge:(NSRectEdge)e; |
| 451 - (void)setContentBorderThickness:(CGFloat)b forEdge:(NSRectEdge)e; | 472 - (void)setContentBorderThickness:(CGFloat)b forEdge:(NSRectEdge)e; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 | 520 |
| 500 - (NSRect)window:(NSWindow *)window | 521 - (NSRect)window:(NSWindow *)window |
| 501 willPositionSheet:(NSWindow *)sheet | 522 willPositionSheet:(NSWindow *)sheet |
| 502 usingRect:(NSRect)defaultSheetRect { | 523 usingRect:(NSRect)defaultSheetRect { |
| 503 NSRect windowFrame = [window frame]; | 524 NSRect windowFrame = [window frame]; |
| 504 defaultSheetRect.origin.y = windowFrame.size.height - 10; | 525 defaultSheetRect.origin.y = windowFrame.size.height - 10; |
| 505 return defaultSheetRect; | 526 return defaultSheetRect; |
| 506 } | 527 } |
| 507 | 528 |
| 508 @end | 529 @end |
| OLD | NEW |