OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 // Used for defining the layout of the NSAlert and NSTextField within the | 81 // Used for defining the layout of the NSAlert and NSTextField within the |
82 // accessory view. | 82 // accessory view. |
83 const int kAppTextFieldVerticalSpacing = 2; | 83 const int kAppTextFieldVerticalSpacing = 2; |
84 const int kAppTextFieldWidth = 200; | 84 const int kAppTextFieldWidth = 200; |
85 const int kAppTextFieldHeight = 22; | 85 const int kAppTextFieldHeight = 22; |
86 const int kBookmarkAppBubbleViewWidth = 200; | 86 const int kBookmarkAppBubbleViewWidth = 200; |
87 const int kBookmarkAppBubbleViewHeight = 46; | 87 const int kBookmarkAppBubbleViewHeight = 46; |
88 | 88 |
89 const int kIconPreviewTargetSize = 128; | 89 const int kIconPreviewTargetSize = 128; |
90 | 90 |
91 const char kWhiteSpaceCharacter = ' '; | |
92 | |
91 base::string16 TrimText(NSString* controlText) { | 93 base::string16 TrimText(NSString* controlText) { |
92 base::string16 text = base::SysNSStringToUTF16(controlText); | 94 base::string16 text = base::SysNSStringToUTF16(controlText); |
93 base::TrimWhitespace(text, base::TRIM_ALL, &text); | 95 base::TrimWhitespace(text, base::TRIM_ALL, &text); |
94 return text; | 96 return text; |
95 } | 97 } |
96 | 98 |
97 } // namespace | 99 } // namespace |
98 | 100 |
99 @interface TextRequiringDelegate : NSObject<NSTextFieldDelegate> { | 101 @interface TextRequiringDelegate : NSObject<NSTextFieldDelegate> { |
100 @private | 102 @private |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 } | 294 } |
293 | 295 |
294 StatusBubble* BrowserWindowCocoa::GetStatusBubble() { | 296 StatusBubble* BrowserWindowCocoa::GetStatusBubble() { |
295 return [controller_ statusBubble]; | 297 return [controller_ statusBubble]; |
296 } | 298 } |
297 | 299 |
298 void BrowserWindowCocoa::UpdateTitleBar() { | 300 void BrowserWindowCocoa::UpdateTitleBar() { |
299 NSString* newTitle = | 301 NSString* newTitle = |
300 base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab()); | 302 base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab()); |
301 | 303 |
304 NSMutableString* titleWithMediaState = [NSMutableString | |
305 stringWithString:newTitle]; | |
Robert Sesek
2015/10/23 14:26:37
There's no reason to not keep |newTitle| around at
| |
306 | |
307 if (media_state_ == TAB_MEDIA_STATE_AUDIO_PLAYING) | |
308 [titleWithMediaState appendFormat:@"%c 🔊", kWhiteSpaceCharacter]; | |
Robert Sesek
2015/10/23 14:26:37
There's now the %c whitespace character that's bei
| |
309 else if (media_state_ == TAB_MEDIA_STATE_AUDIO_MUTING) | |
Robert Sesek
2015/10/23 14:26:37
nit: extra space after ==
| |
310 [titleWithMediaState appendFormat:@"%c 🔇", kWhiteSpaceCharacter]; | |
311 | |
302 pending_window_title_.reset( | 312 pending_window_title_.reset( |
303 [BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get() | 313 [BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get() |
304 withNewTitle:newTitle | 314 withNewTitle:titleWithMediaState |
305 forWindow:window()]); | 315 forWindow:window()]); |
306 } | 316 } |
307 | 317 |
318 void BrowserWindowCocoa::UpdateMediaState(TabMediaState media_state) { | |
319 media_state_ = media_state; | |
320 UpdateTitleBar(); | |
321 } | |
322 | |
308 void BrowserWindowCocoa::BookmarkBarStateChanged( | 323 void BrowserWindowCocoa::BookmarkBarStateChanged( |
309 BookmarkBar::AnimateChangeType change_type) { | 324 BookmarkBar::AnimateChangeType change_type) { |
310 [[controller_ bookmarkBarController] | 325 [[controller_ bookmarkBarController] |
311 updateState:browser_->bookmark_bar_state() | 326 updateState:browser_->bookmark_bar_state() |
312 changeType:change_type]; | 327 changeType:change_type]; |
313 } | 328 } |
314 | 329 |
315 void BrowserWindowCocoa::UpdateDevTools() { | 330 void BrowserWindowCocoa::UpdateDevTools() { |
316 [controller_ updateDevToolsForContents: | 331 [controller_ updateDevToolsForContents: |
317 browser_->tab_strip_model()->GetActiveWebContents()]; | 332 browser_->tab_strip_model()->GetActiveWebContents()]; |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
854 void BrowserWindowCocoa::UnhideDownloadShelf() { | 869 void BrowserWindowCocoa::UnhideDownloadShelf() { |
855 GetDownloadShelf()->Unhide(); | 870 GetDownloadShelf()->Unhide(); |
856 } | 871 } |
857 | 872 |
858 void BrowserWindowCocoa::HideDownloadShelf() { | 873 void BrowserWindowCocoa::HideDownloadShelf() { |
859 GetDownloadShelf()->Hide(); | 874 GetDownloadShelf()->Hide(); |
860 StatusBubble* statusBubble = GetStatusBubble(); | 875 StatusBubble* statusBubble = GetStatusBubble(); |
861 if (statusBubble) | 876 if (statusBubble) |
862 statusBubble->Hide(); | 877 statusBubble->Hide(); |
863 } | 878 } |
OLD | NEW |