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