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

Side by Side Diff: chrome/browser/ui/tabs/tab_utils.cc

Issue 2497373003: Add tab status to accessibility labels (Closed)
Patch Set: Created 4 years, 1 month 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/tabs/tab_utils.h" 5 #include "chrome/browser/ui/tabs/tab_utils.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // the usual 60 FPS because a trade-off must be made between tab UI animation 52 // the usual 60 FPS because a trade-off must be made between tab UI animation
53 // smoothness and media recording/playback performance on low-end hardware. 53 // smoothness and media recording/playback performance on low-end hardware.
54 const int kIndicatorFrameIntervalMs = 50; // 20 FPS 54 const int kIndicatorFrameIntervalMs = 50; // 20 FPS
55 55
56 // Fade-in/out duration for the tab indicator animations. Fade-in is quick to 56 // Fade-in/out duration for the tab indicator animations. Fade-in is quick to
57 // immediately notify the user. Fade-out is more gradual, so that the user has 57 // immediately notify the user. Fade-out is more gradual, so that the user has
58 // a chance of finding a tab that has quickly "blipped" on and off. 58 // a chance of finding a tab that has quickly "blipped" on and off.
59 const int kIndicatorFadeInDurationMs = 200; 59 const int kIndicatorFadeInDurationMs = 200;
60 const int kIndicatorFadeOutDurationMs = 1000; 60 const int kIndicatorFadeOutDurationMs = 1000;
61 61
62 // Network state indicating an error.
63 const int kNetworkStateError = 3;
dmazzoni 2016/11/14 21:59:02 Can you use TabRendererData::NetworkState? Maybe
edwardjung 2016/11/24 11:36:43 Makes sense, separating this tooltip change into a
64
62 // Animation that throbs in (towards 1.0) and out (towards 0.0), and ends in the 65 // Animation that throbs in (towards 1.0) and out (towards 0.0), and ends in the
63 // "in" state. 66 // "in" state.
64 class TabRecordingIndicatorAnimation : public gfx::MultiAnimation { 67 class TabRecordingIndicatorAnimation : public gfx::MultiAnimation {
65 public: 68 public:
66 ~TabRecordingIndicatorAnimation() override {} 69 ~TabRecordingIndicatorAnimation() override {}
67 70
68 // Overridden to provide alternating "towards in" and "towards out" behavior. 71 // Overridden to provide alternating "towards in" and "towards out" behavior.
69 double GetCurrentValue() const override; 72 double GetCurrentValue() const override;
70 73
71 static std::unique_ptr<TabRecordingIndicatorAnimation> Create(); 74 static std::unique_ptr<TabRecordingIndicatorAnimation> Create();
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 gfx::Tween::EASE_IN)); 246 gfx::Tween::EASE_IN));
244 const base::TimeDelta interval = 247 const base::TimeDelta interval =
245 base::TimeDelta::FromMilliseconds(kIndicatorFrameIntervalMs); 248 base::TimeDelta::FromMilliseconds(kIndicatorFrameIntervalMs);
246 std::unique_ptr<gfx::MultiAnimation> animation( 249 std::unique_ptr<gfx::MultiAnimation> animation(
247 new gfx::MultiAnimation(parts, interval)); 250 new gfx::MultiAnimation(parts, interval));
248 animation->set_continuous(false); 251 animation->set_continuous(false);
249 return std::move(animation); 252 return std::move(animation);
250 } 253 }
251 254
252 base::string16 AssembleTabTooltipText(const base::string16& title, 255 base::string16 AssembleTabTooltipText(const base::string16& title,
253 TabAlertState alert_state) { 256 TabAlertState alert_state,
257 int network_state) {
258 base::string16 result = title;
259 if (!result.empty())
260 result.append(1, '\n');
261
262 if (network_state == kNetworkStateError) {
263 result.append(
264 l10n_util::GetStringUTF16(IDS_TAB_AX_LABEL_NETWORK_ERROR));
265 return result;
266 }
254 if (alert_state == TabAlertState::NONE) 267 if (alert_state == TabAlertState::NONE)
255 return title; 268 return title;
256 269
257 base::string16 result = title;
258 if (!result.empty())
259 result.append(1, '\n');
260 switch (alert_state) { 270 switch (alert_state) {
261 case TabAlertState::AUDIO_PLAYING: 271 case TabAlertState::AUDIO_PLAYING:
262 result.append( 272 result.append(
263 l10n_util::GetStringUTF16(IDS_TOOLTIP_TAB_ALERT_STATE_AUDIO_PLAYING)); 273 l10n_util::GetStringUTF16(IDS_TOOLTIP_TAB_ALERT_STATE_AUDIO_PLAYING));
264 break; 274 break;
265 case TabAlertState::AUDIO_MUTING: 275 case TabAlertState::AUDIO_MUTING:
266 result.append( 276 result.append(
267 l10n_util::GetStringUTF16(IDS_TOOLTIP_TAB_ALERT_STATE_AUDIO_MUTING)); 277 l10n_util::GetStringUTF16(IDS_TOOLTIP_TAB_ALERT_STATE_AUDIO_MUTING));
268 break; 278 break;
269 case TabAlertState::MEDIA_RECORDING: 279 case TabAlertState::MEDIA_RECORDING:
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 const std::vector<int>& indices) { 384 const std::vector<int>& indices) {
375 for (std::vector<int>::const_iterator i = indices.begin(); i != indices.end(); 385 for (std::vector<int>::const_iterator i = indices.begin(); i != indices.end();
376 ++i) { 386 ++i) {
377 if (!tab_strip.GetWebContentsAt(*i)->IsAudioMuted()) 387 if (!tab_strip.GetWebContentsAt(*i)->IsAudioMuted())
378 return false; 388 return false;
379 } 389 }
380 return true; 390 return true;
381 } 391 }
382 392
383 } // namespace chrome 393 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698