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/cocoa/browser_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 // download shelf was a ChromeView attached to the TabContents, and as its | 196 // download shelf was a ChromeView attached to the TabContents, and as its |
197 // size changed via animation it notified through TCD/etc to the browser view | 197 // size changed via animation it notified through TCD/etc to the browser view |
198 // to relayout for each tick of the animation. We don't need anything of the | 198 // to relayout for each tick of the animation. We don't need anything of the |
199 // sort on Mac. | 199 // sort on Mac. |
200 } | 200 } |
201 | 201 |
202 void BrowserWindowCocoa::UpdateTitleBar() { | 202 void BrowserWindowCocoa::UpdateTitleBar() { |
203 NSString* newTitle = | 203 NSString* newTitle = |
204 base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab()); | 204 base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab()); |
205 | 205 |
206 // Work around Cocoa bug: if a window changes title during the tracking of the | 206 pending_window_title_.reset( |
207 // Window menu it doesn't display well and the constant re-sorting of the list | 207 [BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get() |
208 // makes it difficult for the user to pick the desired window. Delay window | 208 withNewTitle:newTitle |
209 // title updates until the default run-loop mode. | 209 forWindow:window()]); |
210 | |
211 if (pending_window_title_.get()) | |
212 [[NSRunLoop currentRunLoop] | |
213 cancelPerformSelector:@selector(setTitle:) | |
214 target:window() | |
215 argument:pending_window_title_.get()]; | |
216 | |
217 pending_window_title_.reset([newTitle copy]); | |
218 [[NSRunLoop currentRunLoop] | |
219 performSelector:@selector(setTitle:) | |
220 target:window() | |
221 argument:newTitle | |
222 order:0 | |
223 modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]]; | |
224 } | 210 } |
225 | 211 |
226 void BrowserWindowCocoa::BookmarkBarStateChanged( | 212 void BrowserWindowCocoa::BookmarkBarStateChanged( |
227 BookmarkBar::AnimateChangeType change_type) { | 213 BookmarkBar::AnimateChangeType change_type) { |
228 // TODO: route changes to state through this. | 214 // TODO: route changes to state through this. |
229 } | 215 } |
230 | 216 |
231 void BrowserWindowCocoa::UpdateDevTools() { | 217 void BrowserWindowCocoa::UpdateDevTools() { |
232 [controller_ updateDevToolsForContents: | 218 [controller_ updateDevToolsForContents: |
233 browser_->GetSelectedTabContents()]; | 219 browser_->GetSelectedTabContents()]; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 | 564 |
579 NSWindow* BrowserWindowCocoa::window() const { | 565 NSWindow* BrowserWindowCocoa::window() const { |
580 return [controller_ window]; | 566 return [controller_ window]; |
581 } | 567 } |
582 | 568 |
583 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { | 569 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { |
584 if (tab_contents == browser_->GetSelectedTabContents()) { | 570 if (tab_contents == browser_->GetSelectedTabContents()) { |
585 [controller_ updateSidebarForContents:tab_contents]; | 571 [controller_ updateSidebarForContents:tab_contents]; |
586 } | 572 } |
587 } | 573 } |
OLD | NEW |