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

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: To show which Chromium window has an active/muted sound playing 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* const kWhiteSpaceCharacter = " ";
Robert Sesek 2015/10/20 13:39:47 This doesn't need to be a string, it can be a sing
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
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 =
Robert Sesek 2015/10/20 13:39:47 nit: over-indented by one space.
300 base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab()); 302 base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab());
301 303
304 NSMutableString* titleWithMediaState = [NSMutableString string];
305 [titleWithMediaState appendString:newTitle];
306
307 if (media_state_ == TAB_MEDIA_STATE_AUDIO_PLAYING){
Robert Sesek 2015/10/20 13:39:47 nit: extra space after ==
308 [titleWithMediaState appendFormat:@"%s", kWhiteSpaceCharacter];
Robert Sesek 2015/10/20 13:39:47 … and then use %c instead of %s.
309 [titleWithMediaState appendString:@"🔊"];
310 // [titleWithMediaState appendString:l10n_util::GetNSString(
Robert Sesek 2015/10/20 13:39:47 Don't check-in commented code.
311 // IDS_WINDOW_AUDIO_PLAYING_MAC)];
312 }
313 else if (media_state_ == TAB_MEDIA_STATE_AUDIO_MUTING){
Robert Sesek 2015/10/20 13:39:47 nit: this goes on the same line as }
314 [titleWithMediaState appendFormat:@"%s", kWhiteSpaceCharacter];
315 [titleWithMediaState appendString:@"🔇"];
316 // [titleWithMediaState appendString:l10n_util::GetNSString(
317 // IDS_WINDOW_AUDIO_MUTE_MAC)];
318 }
319
302 pending_window_title_.reset( 320 pending_window_title_.reset(
303 [BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get() 321 [BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get()
304 withNewTitle:newTitle 322 withNewTitle:titleWithMediaState
305 forWindow:window()]); 323 forWindow:window()]);
306 } 324 }
307 325
326 void BrowserWindowCocoa::UpdateMediaState(TabMediaState media_state,
327 content::WebContents* contents) {
328 if (media_state_contents_ == nil)
Robert Sesek 2015/10/20 13:39:47 Why only update if |media_state_contents_| is NULL
329 media_state_contents_ = contents;
330
331 if (media_state == TAB_MEDIA_STATE_NONE ||
332 media_state == TAB_MEDIA_STATE_AUDIO_MUTING)
Robert Sesek 2015/10/20 13:39:47 nit: this needs {} since the body spans multiple l
333 if (media_state_contents_ != contents)
334 return;
335
336 if (media_state == TAB_MEDIA_STATE_NONE)
Robert Sesek 2015/10/20 13:39:47 nit: if any branch of an if/else has {}, all do.
337 media_state_ = prev_media_state_;
338 else {
339 prev_media_state_ = media_state_;
340 media_state_ = media_state;
341 media_state_contents_ = contents;
342 }
343 UpdateTitleBar();
344 }
345
308 void BrowserWindowCocoa::BookmarkBarStateChanged( 346 void BrowserWindowCocoa::BookmarkBarStateChanged(
309 BookmarkBar::AnimateChangeType change_type) { 347 BookmarkBar::AnimateChangeType change_type) {
310 [[controller_ bookmarkBarController] 348 [[controller_ bookmarkBarController]
311 updateState:browser_->bookmark_bar_state() 349 updateState:browser_->bookmark_bar_state()
312 changeType:change_type]; 350 changeType:change_type];
313 } 351 }
314 352
315 void BrowserWindowCocoa::UpdateDevTools() { 353 void BrowserWindowCocoa::UpdateDevTools() {
316 [controller_ updateDevToolsForContents: 354 [controller_ updateDevToolsForContents:
317 browser_->tab_strip_model()->GetActiveWebContents()]; 355 browser_->tab_strip_model()->GetActiveWebContents()];
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 void BrowserWindowCocoa::UnhideDownloadShelf() { 892 void BrowserWindowCocoa::UnhideDownloadShelf() {
855 GetDownloadShelf()->Unhide(); 893 GetDownloadShelf()->Unhide();
856 } 894 }
857 895
858 void BrowserWindowCocoa::HideDownloadShelf() { 896 void BrowserWindowCocoa::HideDownloadShelf() {
859 GetDownloadShelf()->Hide(); 897 GetDownloadShelf()->Hide();
860 StatusBubble* statusBubble = GetStatusBubble(); 898 StatusBubble* statusBubble = GetStatusBubble();
861 if (statusBubble) 899 if (statusBubble)
862 statusBubble->Hide(); 900 statusBubble->Hide();
863 } 901 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698