Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(617)

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_cocoa.mm

Issue 1412083002: Indicate in the Window menu which Chrome window has an active sound playing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applied changes based on the CR, and also refactor the logic Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 string];
Robert Sesek 2015/10/22 00:01:52 Use [NSMutableString stringWithString:] to avoid u
305 [titleWithMediaState appendString:newTitle];
306
307 if (media_state_ == TAB_MEDIA_STATE_AUDIO_PLAYING) {
308 [titleWithMediaState appendFormat:@"%c", kWhiteSpaceCharacter];
miu 2015/10/21 20:06:52 Can the whitespace char be included in the string
309 [titleWithMediaState appendString:@"🔊"];
miu 2015/10/21 20:06:52 Was this moved to generated_resources.prd? If so,
Robert Sesek 2015/10/22 00:01:52 Two appends shouldn't be necessary. Just [title a
310 }
311 else if (media_state_ == TAB_MEDIA_STATE_AUDIO_MUTING) {
Robert Sesek 2015/10/22 00:01:52 nit: this goes on line 310.
312 [titleWithMediaState appendFormat:@"%c", kWhiteSpaceCharacter];
313 [titleWithMediaState appendString:@"🔇"];
314 }
315
302 pending_window_title_.reset( 316 pending_window_title_.reset(
303 [BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get() 317 [BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get()
304 withNewTitle:newTitle 318 withNewTitle:titleWithMediaState
305 forWindow:window()]); 319 forWindow:window()]);
306 } 320 }
307 321
322 void BrowserWindowCocoa::UpdateMediaState(TabMediaState media_state) {
323 media_state_ = media_state;
324 UpdateTitleBar();
325 }
326
308 void BrowserWindowCocoa::BookmarkBarStateChanged( 327 void BrowserWindowCocoa::BookmarkBarStateChanged(
309 BookmarkBar::AnimateChangeType change_type) { 328 BookmarkBar::AnimateChangeType change_type) {
310 [[controller_ bookmarkBarController] 329 [[controller_ bookmarkBarController]
311 updateState:browser_->bookmark_bar_state() 330 updateState:browser_->bookmark_bar_state()
312 changeType:change_type]; 331 changeType:change_type];
313 } 332 }
314 333
315 void BrowserWindowCocoa::UpdateDevTools() { 334 void BrowserWindowCocoa::UpdateDevTools() {
316 [controller_ updateDevToolsForContents: 335 [controller_ updateDevToolsForContents:
317 browser_->tab_strip_model()->GetActiveWebContents()]; 336 browser_->tab_strip_model()->GetActiveWebContents()];
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 void BrowserWindowCocoa::UnhideDownloadShelf() { 873 void BrowserWindowCocoa::UnhideDownloadShelf() {
855 GetDownloadShelf()->Unhide(); 874 GetDownloadShelf()->Unhide();
856 } 875 }
857 876
858 void BrowserWindowCocoa::HideDownloadShelf() { 877 void BrowserWindowCocoa::HideDownloadShelf() {
859 GetDownloadShelf()->Hide(); 878 GetDownloadShelf()->Hide();
860 StatusBubble* statusBubble = GetStatusBubble(); 879 StatusBubble* statusBubble = GetStatusBubble();
861 if (statusBubble) 880 if (statusBubble)
862 statusBubble->Hide(); 881 statusBubble->Hide();
863 } 882 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698