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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 028c744d53dd56751ccc7c2e29262a534a056ffc..3d43003dcde84320e84312aa71b7997d1b440211 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -88,6 +88,8 @@ const int kBookmarkAppBubbleViewHeight = 46;
const int kIconPreviewTargetSize = 128;
+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
+
base::string16 TrimText(NSString* controlText) {
base::string16 text = base::SysNSStringToUTF16(controlText);
base::TrimWhitespace(text, base::TRIM_ALL, &text);
@@ -296,15 +298,51 @@ StatusBubble* BrowserWindowCocoa::GetStatusBubble() {
}
void BrowserWindowCocoa::UpdateTitleBar() {
- NSString* newTitle =
+ NSString* newTitle =
Robert Sesek 2015/10/20 13:39:47 nit: over-indented by one space.
base::SysUTF16ToNSString(browser_->GetWindowTitleForCurrentTab());
+ NSMutableString* titleWithMediaState = [NSMutableString string];
+ [titleWithMediaState appendString:newTitle];
+
+ if (media_state_ == TAB_MEDIA_STATE_AUDIO_PLAYING){
Robert Sesek 2015/10/20 13:39:47 nit: extra space after ==
+ [titleWithMediaState appendFormat:@"%s", kWhiteSpaceCharacter];
Robert Sesek 2015/10/20 13:39:47 … and then use %c instead of %s.
+ [titleWithMediaState appendString:@"🔊"];
+ // [titleWithMediaState appendString:l10n_util::GetNSString(
Robert Sesek 2015/10/20 13:39:47 Don't check-in commented code.
+ // IDS_WINDOW_AUDIO_PLAYING_MAC)];
+ }
+ 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 }
+ [titleWithMediaState appendFormat:@"%s", kWhiteSpaceCharacter];
+ [titleWithMediaState appendString:@"🔇"];
+ // [titleWithMediaState appendString:l10n_util::GetNSString(
+ // IDS_WINDOW_AUDIO_MUTE_MAC)];
+ }
+
pending_window_title_.reset(
[BrowserWindowUtils scheduleReplaceOldTitle:pending_window_title_.get()
- withNewTitle:newTitle
+ withNewTitle:titleWithMediaState
forWindow:window()]);
}
+void BrowserWindowCocoa::UpdateMediaState(TabMediaState media_state,
+ content::WebContents* contents) {
+ if (media_state_contents_ == nil)
Robert Sesek 2015/10/20 13:39:47 Why only update if |media_state_contents_| is NULL
+ media_state_contents_ = contents;
+
+ if (media_state == TAB_MEDIA_STATE_NONE ||
+ media_state == TAB_MEDIA_STATE_AUDIO_MUTING)
Robert Sesek 2015/10/20 13:39:47 nit: this needs {} since the body spans multiple l
+ if (media_state_contents_ != contents)
+ return;
+
+ 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.
+ media_state_ = prev_media_state_;
+ else {
+ prev_media_state_ = media_state_;
+ media_state_ = media_state;
+ media_state_contents_ = contents;
+ }
+ UpdateTitleBar();
+}
+
void BrowserWindowCocoa::BookmarkBarStateChanged(
BookmarkBar::AnimateChangeType change_type) {
[[controller_ bookmarkBarController]

Powered by Google App Engine
This is Rietveld 408576698