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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 | 291 |
290 gfx::NativeWindow BrowserWindowCocoa::GetNativeWindow() const { | 292 gfx::NativeWindow BrowserWindowCocoa::GetNativeWindow() const { |
291 return window(); | 293 return window(); |
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 = GetWindowTitle(); |
300 base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab()); | |
301 | 302 |
302 pending_window_title_.reset( | 303 pending_window_title_.reset([BrowserWindowUtils |
303 [BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get() | 304 scheduleReplaceOldTitle:pending_window_title_.get() |
304 withNewTitle:newTitle | 305 withNewTitle:newTitle |
305 forWindow:window()]); | 306 forWindow:window()]); |
307 } | |
308 | |
309 void BrowserWindowCocoa::UpdateMediaState(TabMediaState media_state) { | |
310 media_state_ = media_state; | |
311 UpdateTitleBar(); | |
312 } | |
313 | |
314 NSString* BrowserWindowCocoa::GetWindowTitle() { | |
315 NSMutableString* newTitle = [NSMutableString | |
316 stringWithString:base::SysUTF16ToNSString( | |
317 browser_->GetWindowTitleForCurrentTab())]; | |
318 | |
319 if (media_state_ == TAB_MEDIA_STATE_AUDIO_PLAYING) | |
Robert Sesek
2015/10/28 18:45:57
nit: needs braces {} around both if and else if.
| |
320 [newTitle | |
321 appendFormat:@"%c%@", kWhiteSpaceCharacter, | |
Robert Sesek
2015/10/28 18:45:57
… continuing comment from the GRD file. Then this
| |
322 l10n_util::GetNSString(IDS_WINDOW_AUDIO_PLAYING_MAC)]; | |
323 else if (media_state_ == TAB_MEDIA_STATE_AUDIO_MUTING) | |
324 [newTitle appendFormat:@"%c%@", kWhiteSpaceCharacter, | |
325 l10n_util::GetNSString(IDS_WINDOW_AUDIO_MUTE_MAC)]; | |
326 return newTitle; | |
327 } | |
328 | |
329 TabMediaState BrowserWindowCocoa::GetMediaState() { | |
330 return media_state_; | |
306 } | 331 } |
307 | 332 |
308 void BrowserWindowCocoa::BookmarkBarStateChanged( | 333 void BrowserWindowCocoa::BookmarkBarStateChanged( |
309 BookmarkBar::AnimateChangeType change_type) { | 334 BookmarkBar::AnimateChangeType change_type) { |
310 [[controller_ bookmarkBarController] | 335 [[controller_ bookmarkBarController] |
311 updateState:browser_->bookmark_bar_state() | 336 updateState:browser_->bookmark_bar_state() |
312 changeType:change_type]; | 337 changeType:change_type]; |
313 } | 338 } |
314 | 339 |
315 void BrowserWindowCocoa::UpdateDevTools() { | 340 void BrowserWindowCocoa::UpdateDevTools() { |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
854 void BrowserWindowCocoa::UnhideDownloadShelf() { | 879 void BrowserWindowCocoa::UnhideDownloadShelf() { |
855 GetDownloadShelf()->Unhide(); | 880 GetDownloadShelf()->Unhide(); |
856 } | 881 } |
857 | 882 |
858 void BrowserWindowCocoa::HideDownloadShelf() { | 883 void BrowserWindowCocoa::HideDownloadShelf() { |
859 GetDownloadShelf()->Hide(); | 884 GetDownloadShelf()->Hide(); |
860 StatusBubble* statusBubble = GetStatusBubble(); | 885 StatusBubble* statusBubble = GetStatusBubble(); |
861 if (statusBubble) | 886 if (statusBubble) |
862 statusBubble->Hide(); | 887 statusBubble->Hide(); |
863 } | 888 } |
OLD | NEW |