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

Side by Side Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 2579893002: Revert "Add tab status to accessibility labels". (Closed)
Patch Set: Created 4 years 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/views/tabs/tab.h" 5 #include "chrome/browser/ui/views/tabs/tab.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/debug/alias.h" 12 #include "base/debug/alias.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/browser/themes/theme_properties.h" 16 #include "chrome/browser/themes/theme_properties.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/layout_constants.h" 18 #include "chrome/browser/ui/layout_constants.h"
19 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 19 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
20 #include "chrome/browser/ui/tabs/tab_utils.h" 20 #include "chrome/browser/ui/tabs/tab_utils.h"
21 #include "chrome/browser/ui/view_ids.h" 21 #include "chrome/browser/ui/view_ids.h"
22 #include "chrome/browser/ui/views/frame/browser_view.h"
23 #include "chrome/browser/ui/views/tabs/alert_indicator_button.h" 22 #include "chrome/browser/ui/views/tabs/alert_indicator_button.h"
24 #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
25 #include "chrome/browser/ui/views/tabs/tab_controller.h" 23 #include "chrome/browser/ui/views/tabs/tab_controller.h"
26 #include "chrome/browser/ui/views/tabs/tab_strip.h"
27 #include "chrome/browser/ui/views/touch_uma/touch_uma.h" 24 #include "chrome/browser/ui/views/touch_uma/touch_uma.h"
28 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
30 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
31 #include "chrome/grit/theme_resources.h" 28 #include "chrome/grit/theme_resources.h"
32 #include "components/grit/components_scaled_resources.h" 29 #include "components/grit/components_scaled_resources.h"
33 #include "components/strings/grit/components_strings.h" 30 #include "components/strings/grit/components_strings.h"
34 #include "content/public/browser/user_metrics.h" 31 #include "content/public/browser/user_metrics.h"
35 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
36 #include "third_party/skia/include/effects/SkGradientShader.h" 33 #include "third_party/skia/include/effects/SkGradientShader.h"
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 loading_start_time_ = base::TimeTicks(); 487 loading_start_time_ = base::TimeTicks();
491 waiting_state_ = gfx::ThrobberWaitingState(); 488 waiting_state_ = gfx::ThrobberWaitingState();
492 } 489 }
493 490
494 bool Tab::ThrobberView::CanProcessEventsWithinSubtree() const { 491 bool Tab::ThrobberView::CanProcessEventsWithinSubtree() const {
495 return false; 492 return false;
496 } 493 }
497 494
498 void Tab::ThrobberView::OnPaint(gfx::Canvas* canvas) { 495 void Tab::ThrobberView::OnPaint(gfx::Canvas* canvas) {
499 const TabRendererData::NetworkState state = owner_->data().network_state; 496 const TabRendererData::NetworkState state = owner_->data().network_state;
500 if (state == TabRendererData::NETWORK_STATE_NONE || 497 if (state == TabRendererData::NETWORK_STATE_NONE)
501 state == TabRendererData::NETWORK_STATE_ERROR)
502 return; 498 return;
503 499
504 const ui::ThemeProvider* tp = GetThemeProvider(); 500 const ui::ThemeProvider* tp = GetThemeProvider();
505 const gfx::Rect bounds = GetLocalBounds(); 501 const gfx::Rect bounds = GetLocalBounds();
506 if (state == TabRendererData::NETWORK_STATE_WAITING) { 502 if (state == TabRendererData::NETWORK_STATE_WAITING) {
507 if (waiting_start_time_ == base::TimeTicks()) 503 if (waiting_start_time_ == base::TimeTicks())
508 waiting_start_time_ = base::TimeTicks::Now(); 504 waiting_start_time_ = base::TimeTicks::Now();
509 505
510 waiting_state_.elapsed_time = base::TimeTicks::Now() - waiting_start_time_; 506 waiting_state_.elapsed_time = base::TimeTicks::Now() - waiting_start_time_;
511 gfx::PaintThrobberWaiting( 507 gfx::PaintThrobberWaiting(
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 showing_pinned_tab_title_changed_indicator_ = false; 667 showing_pinned_tab_title_changed_indicator_ = false;
672 668
673 DataChanged(old); 669 DataChanged(old);
674 670
675 Layout(); 671 Layout();
676 SchedulePaint(); 672 SchedulePaint();
677 } 673 }
678 674
679 void Tab::UpdateLoadingAnimation(TabRendererData::NetworkState state) { 675 void Tab::UpdateLoadingAnimation(TabRendererData::NetworkState state) {
680 if (state == data_.network_state && 676 if (state == data_.network_state &&
681 (state == TabRendererData::NETWORK_STATE_NONE || 677 state == TabRendererData::NETWORK_STATE_NONE) {
682 state == TabRendererData::NETWORK_STATE_ERROR)) { 678 // If the network state is none and hasn't changed, do nothing. Otherwise we
683 // If the network state is none or is a network error and hasn't changed, 679 // need to advance the animation frame.
684 // do nothing. Otherwise we need to advance the animation frame.
685 return; 680 return;
686 } 681 }
687 682
688 data_.network_state = state; 683 data_.network_state = state;
689 AdvanceLoadingAnimation(); 684 AdvanceLoadingAnimation();
690 } 685 }
691 686
692 void Tab::StartPulse() { 687 void Tab::StartPulse() {
693 pulse_animation_->StartThrobbing(std::numeric_limits<int>::max()); 688 pulse_animation_->StartThrobbing(std::numeric_limits<int>::max());
694 } 689 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 break; 1092 break;
1098 1093
1099 default: 1094 default:
1100 break; 1095 break;
1101 } 1096 }
1102 event->SetHandled(); 1097 event->SetHandled();
1103 } 1098 }
1104 1099
1105 void Tab::GetAccessibleNodeData(ui::AXNodeData* node_data) { 1100 void Tab::GetAccessibleNodeData(ui::AXNodeData* node_data) {
1106 node_data->role = ui::AX_ROLE_TAB; 1101 node_data->role = ui::AX_ROLE_TAB;
1107 node_data->SetName(controller_->GetAccessibleTabName()); 1102 node_data->SetName(data_.title);
1108 node_data->AddStateFlag(ui::AX_STATE_MULTISELECTABLE); 1103 node_data->AddStateFlag(ui::AX_STATE_MULTISELECTABLE);
1109 node_data->AddStateFlag(ui::AX_STATE_SELECTABLE); 1104 node_data->AddStateFlag(ui::AX_STATE_SELECTABLE);
1110 controller_->UpdateTabAccessibilityState(this, node_data); 1105 controller_->UpdateTabAccessibilityState(this, node_data);
1111 if (IsSelected()) 1106 if (IsSelected())
1112 node_data->AddStateFlag(ui::AX_STATE_SELECTED); 1107 node_data->AddStateFlag(ui::AX_STATE_SELECTED);
1113 } 1108 }
1114 1109
1115 //////////////////////////////////////////////////////////////////////////////// 1110 ////////////////////////////////////////////////////////////////////////////////
1116 // Tab, private 1111 // Tab, private
1117 1112
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 // Draw a gray rectangle to represent the tab. This works for pinned tabs as 1177 // Draw a gray rectangle to represent the tab. This works for pinned tabs as
1183 // well as regular ones. The active tab has a brigher bar. 1178 // well as regular ones. The active tab has a brigher bar.
1184 SkColor color = 1179 SkColor color =
1185 IsActive() ? kImmersiveActiveTabColor : kImmersiveInactiveTabColor; 1180 IsActive() ? kImmersiveActiveTabColor : kImmersiveInactiveTabColor;
1186 gfx::Rect bar_rect = GetImmersiveBarRect(); 1181 gfx::Rect bar_rect = GetImmersiveBarRect();
1187 canvas->FillRect(bar_rect, SkColorSetA(color, alpha)); 1182 canvas->FillRect(bar_rect, SkColorSetA(color, alpha));
1188 1183
1189 // Paint network activity indicator. 1184 // Paint network activity indicator.
1190 // TODO(jamescook): Replace this placeholder animation with a real one. 1185 // TODO(jamescook): Replace this placeholder animation with a real one.
1191 // For now, let's go with a Cylon eye effect, but in blue. 1186 // For now, let's go with a Cylon eye effect, but in blue.
1192 if (data().network_state != TabRendererData::NETWORK_STATE_NONE && 1187 if (data().network_state != TabRendererData::NETWORK_STATE_NONE) {
1193 data().network_state != TabRendererData::NETWORK_STATE_ERROR) {
1194 const SkColor kEyeColor = SkColorSetARGB(alpha, 71, 138, 217); 1188 const SkColor kEyeColor = SkColorSetARGB(alpha, 71, 138, 217);
1195 int eye_width = bar_rect.width() / 3; 1189 int eye_width = bar_rect.width() / 3;
1196 int eye_offset = bar_rect.width() * immersive_loading_step_ / 1190 int eye_offset = bar_rect.width() * immersive_loading_step_ /
1197 kImmersiveLoadingStepCount; 1191 kImmersiveLoadingStepCount;
1198 if (eye_offset + eye_width < bar_rect.width()) { 1192 if (eye_offset + eye_width < bar_rect.width()) {
1199 // Draw a single indicator strip because it fits inside |bar_rect|. 1193 // Draw a single indicator strip because it fits inside |bar_rect|.
1200 gfx::Rect eye_rect( 1194 gfx::Rect eye_rect(
1201 bar_rect.x() + eye_offset, 0, eye_width, kImmersiveBarHeight); 1195 bar_rect.x() + eye_offset, 0, eye_width, kImmersiveBarHeight);
1202 canvas->FillRect(eye_rect, kEyeColor); 1196 canvas->FillRect(eye_rect, kEyeColor);
1203 } else { 1197 } else {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 1382
1389 void Tab::PaintIcon(gfx::Canvas* canvas) { 1383 void Tab::PaintIcon(gfx::Canvas* canvas) {
1390 gfx::Rect bounds = favicon_bounds_; 1384 gfx::Rect bounds = favicon_bounds_;
1391 bounds.set_x(GetMirroredXForRect(bounds)); 1385 bounds.set_x(GetMirroredXForRect(bounds));
1392 bounds.Offset(0, favicon_hiding_offset_); 1386 bounds.Offset(0, favicon_hiding_offset_);
1393 bounds.Intersect(GetContentsBounds()); 1387 bounds.Intersect(GetContentsBounds());
1394 if (bounds.IsEmpty()) 1388 if (bounds.IsEmpty())
1395 return; 1389 return;
1396 1390
1397 // Throbber will do its own painting. 1391 // Throbber will do its own painting.
1398 if (data().network_state != TabRendererData::NETWORK_STATE_NONE && 1392 if (data().network_state != TabRendererData::NETWORK_STATE_NONE)
1399 data().network_state != TabRendererData::NETWORK_STATE_ERROR) {
1400 return; 1393 return;
1401 } 1394
1402 // Ensure that |favicon_| is created. 1395 // Ensure that |favicon_| is created.
1403 if (favicon_.isNull()) { 1396 if (favicon_.isNull()) {
1404 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1397 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1405 favicon_ = should_display_crashed_favicon_ 1398 favicon_ = should_display_crashed_favicon_
1406 ? *rb->GetImageSkiaNamed(IDR_CRASH_SAD_FAVICON) 1399 ? *rb->GetImageSkiaNamed(IDR_CRASH_SAD_FAVICON)
1407 : data().favicon; 1400 : data().favicon;
1408 // Themify the icon if it's a chrome:// page or if it's the sadtab favicon. 1401 // Themify the icon if it's a chrome:// page or if it's the sadtab favicon.
1409 // This ensures chrome:// pages are visible over the tab background. This is 1402 // This ensures chrome:// pages are visible over the tab background. This is
1410 // similar to code in the bookmarks bar. 1403 // similar to code in the bookmarks bar.
1411 if (!favicon_.isNull() && 1404 if (!favicon_.isNull() &&
(...skipping 29 matching lines...) Expand all
1441 immersive_loading_step_ = 1434 immersive_loading_step_ =
1442 (immersive_loading_step_ + 1) % kImmersiveLoadingStepCount; 1435 (immersive_loading_step_ + 1) % kImmersiveLoadingStepCount;
1443 } else { 1436 } else {
1444 immersive_loading_step_ = 0; 1437 immersive_loading_step_ = 0;
1445 } 1438 }
1446 1439
1447 SchedulePaintInRect(GetImmersiveBarRect()); 1440 SchedulePaintInRect(GetImmersiveBarRect());
1448 return; 1441 return;
1449 } 1442 }
1450 1443
1451 if (state == TabRendererData::NETWORK_STATE_NONE || 1444 if (state == TabRendererData::NETWORK_STATE_NONE) {
1452 state == TabRendererData::NETWORK_STATE_ERROR) {
1453 throbber_->ResetStartTimes(); 1445 throbber_->ResetStartTimes();
1454 throbber_->SetVisible(false); 1446 throbber_->SetVisible(false);
1455 ScheduleIconPaint(); 1447 ScheduleIconPaint();
1456 return; 1448 return;
1457 } 1449 }
1458 1450
1459 // Since the throbber can animate for a long time, paint to a separate layer 1451 // Since the throbber can animate for a long time, paint to a separate layer
1460 // when possible to reduce repaint overhead. 1452 // when possible to reduce repaint overhead.
1461 const bool paint_to_layer = controller_->CanPaintThrobberToLayer(); 1453 const bool paint_to_layer = controller_->CanPaintThrobberToLayer();
1462 if (paint_to_layer != !!throbber_->layer()) { 1454 if (paint_to_layer != !!throbber_->layer()) {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 SchedulePaintInRect(bounds); 1576 SchedulePaintInRect(bounds);
1585 } 1577 }
1586 1578
1587 gfx::Rect Tab::GetImmersiveBarRect() const { 1579 gfx::Rect Tab::GetImmersiveBarRect() const {
1588 // The main bar is as wide as the normal tab's horizontal top line. 1580 // The main bar is as wide as the normal tab's horizontal top line.
1589 gfx::Rect contents = GetContentsBounds(); 1581 gfx::Rect contents = GetContentsBounds();
1590 contents.set_y(0); 1582 contents.set_y(0);
1591 contents.set_height(kImmersiveBarHeight); 1583 contents.set_height(kImmersiveBarHeight);
1592 return contents; 1584 return contents;
1593 } 1585 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/fake_base_tab_strip_controller.cc ('k') | chrome/browser/ui/views/tabs/tab_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698