summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/views/browser_actions_container.cc38
-rw-r--r--chrome/browser/views/browser_actions_container.h6
-rw-r--r--views/controls/resize_gripper.cc21
-rw-r--r--views/controls/resize_gripper.h6
5 files changed, 75 insertions, 2 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 02486fd..59a7674 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -3701,6 +3701,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_ACCNAME_EXTENSIONS" desc="The accessible name for the Extensions toolbar.">
Extensions
</message>
+ <message name="IDS_ACCNAME_EXTENSIONS_BROWSER_ACTION" desc="The accessible name for a browser action.">
+ Browser Action
+ </message>
+ <message name="IDS_ACCNAME_EXTENSIONS_CHEVRON" desc="The accessible name for the chevron visible if not all the extension buttons fit.">
+ Menu containing hidden extensions
+ </message>
<message name="IDS_ACCNAME_NEWTAB" desc="The accessible name for the New Tab (+) button.">
New Tab
</message>
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc
index acf06c2..9634c93 100644
--- a/chrome/browser/views/browser_actions_container.cc
+++ b/chrome/browser/views/browser_actions_container.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/views/browser_actions_container.h"
#include "app/gfx/canvas.h"
+#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "app/slide_animation.h"
#include "base/stl_util-inl.h"
@@ -28,6 +29,7 @@
#include "chrome/common/notification_type.h"
#include "chrome/common/pref_names.h"
#include "grit/app_resources.h"
+#include "grit/generated_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkTypeface.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -163,7 +165,12 @@ void BrowserActionButton::UpdateState() {
else if (!default_icon_.isNull())
SetIcon(default_icon_);
- SetTooltipText(UTF8ToWide(browser_action()->GetTitle(tab_id)));
+ // If the browser action name is empty, show the extension name instead.
+ std::wstring name = UTF8ToWide(browser_action()->GetTitle(tab_id));
+ if (name.empty())
+ name = UTF8ToWide(extension()->name());
+ SetTooltipText(name);
+ SetAccessibleName(name);
GetParent()->SchedulePaint();
}
@@ -307,6 +314,18 @@ gfx::Canvas* BrowserActionView::GetIconWithBadge() {
return canvas;
}
+bool BrowserActionView::GetAccessibleRole(AccessibilityTypes::Role* role) {
+ DCHECK(role);
+ *role = AccessibilityTypes::ROLE_GROUPING;
+ return true;
+}
+
+bool BrowserActionView::GetAccessibleName(std::wstring* name) {
+ DCHECK(name);
+ *name = l10n_util::GetString(IDS_ACCNAME_EXTENSIONS_BROWSER_ACTION);
+ return true;
+}
+
void BrowserActionView::Layout() {
button_->SetBounds(0, kControlVertOffset, width(), kButtonSize);
}
@@ -348,6 +367,8 @@ BrowserActionsContainer::BrowserActionsContainer(
resize_animation_.reset(new SlideAnimation(this));
resize_gripper_ = new views::ResizeGripper(this);
+ resize_gripper_->SetAccessibleName(
+ l10n_util::GetString(IDS_ACCNAME_SEPARATOR));
resize_gripper_->SetVisible(false);
AddChildView(resize_gripper_);
@@ -357,6 +378,8 @@ BrowserActionsContainer::BrowserActionsContainer(
chevron_ = new views::MenuButton(NULL, std::wstring(), this, false);
chevron_->SetVisible(false);
chevron_->SetIcon(*chevron_image);
+ chevron_->SetAccessibleName(
+ l10n_util::GetString(IDS_ACCNAME_EXTENSIONS_CHEVRON));
// Chevron contains >> that should point left in LTR locales.
chevron_->EnableCanvasFlippingForRTLUI(true);
AddChildView(chevron_);
@@ -779,6 +802,19 @@ int BrowserActionsContainer::OnPerformDrop(
return DragDropTypes::DRAG_MOVE;
}
+bool BrowserActionsContainer::GetAccessibleRole(
+ AccessibilityTypes::Role* role) {
+ DCHECK(role);
+ *role = AccessibilityTypes::ROLE_GROUPING;
+ return true;
+}
+
+bool BrowserActionsContainer::GetAccessibleName(std::wstring* name) {
+ DCHECK(name);
+ *name = l10n_util::GetString(IDS_ACCNAME_EXTENSIONS);
+ return !name->empty();
+}
+
void BrowserActionsContainer::MoveBrowserAction(
const std::string& extension_id, size_t new_index) {
ExtensionsService* service = profile_->GetExtensionsService();
diff --git a/chrome/browser/views/browser_actions_container.h b/chrome/browser/views/browser_actions_container.h
index cb73ccb..6b4f123 100644
--- a/chrome/browser/views/browser_actions_container.h
+++ b/chrome/browser/views/browser_actions_container.h
@@ -144,6 +144,10 @@ class BrowserActionView : public views::View {
// returned object.
gfx::Canvas* GetIconWithBadge();
+ // Accessibility accessors, overridden from View.
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
+ virtual bool GetAccessibleName(std::wstring* name);
+
private:
virtual void Layout();
@@ -310,6 +314,8 @@ class BrowserActionsContainer
virtual int OnDragUpdated(const views::DropTargetEvent& event);
virtual void OnDragExited();
virtual int OnPerformDrop(const views::DropTargetEvent& event);
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
+ virtual bool GetAccessibleName(std::wstring* name);
// Overridden from views::ViewMenuDelegate:
virtual void RunMenu(View* source, const gfx::Point& pt);
diff --git a/views/controls/resize_gripper.cc b/views/controls/resize_gripper.cc
index 59a93ab..b4fd55f 100644
--- a/views/controls/resize_gripper.cc
+++ b/views/controls/resize_gripper.cc
@@ -4,8 +4,8 @@
#include "views/controls/resize_gripper.h"
-#include "base/logging.h"
#include "app/resource_bundle.h"
+#include "base/logging.h"
#include "grit/app_resources.h"
namespace views {
@@ -76,6 +76,25 @@ void ResizeGripper::OnMouseReleased(const views::MouseEvent& event,
ReportResizeAmount(event.x(), true);
}
+bool ResizeGripper::GetAccessibleRole(AccessibilityTypes::Role* role) {
+ DCHECK(role);
+ *role = AccessibilityTypes::ROLE_SEPARATOR;
+ return true;
+}
+
+bool ResizeGripper::GetAccessibleName(std::wstring* name) {
+ DCHECK(name);
+ if (!accessible_name_.empty()) {
+ *name = accessible_name_;
+ return true;
+ }
+ return false;
+}
+
+void ResizeGripper::SetAccessibleName(const std::wstring& name) {
+ accessible_name_.assign(name);
+}
+
void ResizeGripper::ReportResizeAmount(int resize_amount, bool last_update) {
gfx::Point point(resize_amount, 0);
View::ConvertPointToScreen(this, &point);
diff --git a/views/controls/resize_gripper.h b/views/controls/resize_gripper.h
index 588b01d..8586a22 100644
--- a/views/controls/resize_gripper.h
+++ b/views/controls/resize_gripper.h
@@ -44,6 +44,9 @@ class ResizeGripper : public ImageView {
virtual bool OnMousePressed(const views::MouseEvent& event);
virtual bool OnMouseDragged(const views::MouseEvent& event);
virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
+ virtual bool GetAccessibleName(std::wstring* name);
+ virtual void SetAccessibleName(const std::wstring& name);
static const char kViewClassName[];
@@ -58,6 +61,9 @@ class ResizeGripper : public ImageView {
// The mouse position at start (in screen coordinates).
int initial_position_;
+ // The storage string for the accessibility name associated with this control.
+ std::wstring accessible_name_;
+
DISALLOW_COPY_AND_ASSIGN(ResizeGripper);
};