Skip to content

Commit

Permalink
Reland http://codereview.chromium.org/9121050/ with fix for aura_win
Browse files Browse the repository at this point in the history
Add accessible names to the launcher buttons

BUG=104192
TEST=None

Review URL: https://chromiumcodereview.appspot.com/9307037

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120950 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
zork@chromium.org committed Feb 8, 2012
1 parent 1f9a6d1 commit 2b1fbb9
Show file tree
Hide file tree
Showing 15 changed files with 220 additions and 2 deletions.
1 change: 1 addition & 0 deletions ash/DEPS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include_rules = [
"+grit/ash_strings.h",
"+grit/ui_resources.h",
"+grit/ui_resources_standard.h",
"+grit/ui_resources_large.h",
Expand Down
1 change: 1 addition & 0 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'target_name': 'ash',
'type': '<(component)',
'dependencies': [
'ash_strings.gyp:ash_strings',
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
Expand Down
128 changes: 128 additions & 0 deletions ash/ash_strings.grd
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
This file contains the strings for ash.
-->

<grit base_dir="." latest_public_release="0" current_release="1"
source_lang_id="en" enc_check="möl">
<outputs>
<output filename="grit/ash_strings.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="ash_strings_am.pak" type="data_package" lang="am" />
<output filename="ash_strings_ar.pak" type="data_package" lang="ar" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_ast.pak" type="data_package" lang="ast" />
</if>
<output filename="ash_strings_bg.pak" type="data_package" lang="bg" />
<output filename="ash_strings_bn.pak" type="data_package" lang="bn" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_bs.pak" type="data_package" lang="bs" />
</if>
<output filename="ash_strings_ca.pak" type="data_package" lang="ca" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_ca@valencia.pak" type="data_package" lang="ca@valencia" />
</if>
<output filename="ash_strings_cs.pak" type="data_package" lang="cs" />
<output filename="ash_strings_da.pak" type="data_package" lang="da" />
<output filename="ash_strings_de.pak" type="data_package" lang="de" />
<output filename="ash_strings_el.pak" type="data_package" lang="el" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_en-AU.pak" type="data_package" lang="en-AU" />
</if>
<output filename="ash_strings_en-GB.pak" type="data_package" lang="en-GB" />
<output filename="ash_strings_en-US.pak" type="data_package" lang="en" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_eo.pak" type="data_package" lang="eo" />
</if>
<output filename="ash_strings_es.pak" type="data_package" lang="es" />
<output filename="ash_strings_es-419.pak" type="data_package" lang="es-419" />
<output filename="ash_strings_et.pak" type="data_package" lang="et" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_eu.pak" type="data_package" lang="eu" />
</if>
<output filename="ash_strings_fa.pak" type="data_package" lang="fa" />
<output filename="ash_strings_fake-bidi.pak" type="data_package" lang="fake-bidi" />
<output filename="ash_strings_fi.pak" type="data_package" lang="fi" />
<output filename="ash_strings_fil.pak" type="data_package" lang="fil" />
<output filename="ash_strings_fr.pak" type="data_package" lang="fr" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_gl.pak" type="data_package" lang="gl" />
</if>
<output filename="ash_strings_gu.pak" type="data_package" lang="gu" />
<output filename="ash_strings_he.pak" type="data_package" lang="he" />
<output filename="ash_strings_hi.pak" type="data_package" lang="hi" />
<output filename="ash_strings_hr.pak" type="data_package" lang="hr" />
<output filename="ash_strings_hu.pak" type="data_package" lang="hu" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_hy.pak" type="data_package" lang="hy" />
<output filename="ash_strings_ia.pak" type="data_package" lang="ia" />
</if>
<output filename="ash_strings_id.pak" type="data_package" lang="id" />
<output filename="ash_strings_it.pak" type="data_package" lang="it" />
<output filename="ash_strings_ja.pak" type="data_package" lang="ja" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_ka.pak" type="data_package" lang="ka" />
</if>
<output filename="ash_strings_kn.pak" type="data_package" lang="kn" />
<output filename="ash_strings_ko.pak" type="data_package" lang="ko" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_ku.pak" type="data_package" lang="ku" />
<output filename="ash_strings_kw.pak" type="data_package" lang="kw" />
</if>
<output filename="ash_strings_lt.pak" type="data_package" lang="lt" />
<output filename="ash_strings_lv.pak" type="data_package" lang="lv" />
<output filename="ash_strings_ml.pak" type="data_package" lang="ml" />
<output filename="ash_strings_mr.pak" type="data_package" lang="mr" />
<output filename="ash_strings_ms.pak" type="data_package" lang="ms" />
<output filename="ash_strings_nl.pak" type="data_package" lang="nl" />
<!-- The translation console uses 'no' for Norwegian Bokmål. It should
be 'nb'. -->
<output filename="ash_strings_nb.pak" type="data_package" lang="no" />
<output filename="ash_strings_pl.pak" type="data_package" lang="pl" />
<output filename="ash_strings_pt-BR.pak" type="data_package" lang="pt-BR" />
<output filename="ash_strings_pt-PT.pak" type="data_package" lang="pt-PT" />
<output filename="ash_strings_ro.pak" type="data_package" lang="ro" />
<output filename="ash_strings_ru.pak" type="data_package" lang="ru" />
<output filename="ash_strings_sk.pak" type="data_package" lang="sk" />
<output filename="ash_strings_sl.pak" type="data_package" lang="sl" />
<output filename="ash_strings_sr.pak" type="data_package" lang="sr" />
<output filename="ash_strings_sv.pak" type="data_package" lang="sv" />
<output filename="ash_strings_sw.pak" type="data_package" lang="sw" />
<output filename="ash_strings_ta.pak" type="data_package" lang="ta" />
<output filename="ash_strings_te.pak" type="data_package" lang="te" />
<output filename="ash_strings_th.pak" type="data_package" lang="th" />
<output filename="ash_strings_tr.pak" type="data_package" lang="tr" />
<if expr="pp_ifdef('use_third_party_translations')">
<output filename="ash_strings_ug.pak" type="data_package" lang="ug" />
</if>
<output filename="ash_strings_uk.pak" type="data_package" lang="uk" />
<output filename="ash_strings_vi.pak" type="data_package" lang="vi" />
<output filename="ash_strings_zh-CN.pak" type="data_package" lang="zh-CN" />
<output filename="ash_strings_zh-TW.pak" type="data_package" lang="zh-TW" />
</outputs>
<translations>
<!-- TODO(zork): Add Placeholder translations. See:
http://crosbug.com/25682 -->
</translations>
<release seq="1" allow_pseudo="false">
<messages fallback_to_english="true">
<!-- TODO add all of your "string table" messages here. Remember to
change nontranslateable parts of the messages into placeholders (using the
<ph> element). You can also use the 'grit add' tool to help you identify
nontranslateable parts and create placeholders for them. -->
<!-- TODO(zork): Only include these in Aura builds -->
<message name="IDS_AURA_APP_LIST_TITLE" desc="The title used for the Aura app list in the launcher">
Applications
</message>
<message name="IDS_AURA_CYCLER_TITLE" desc="The title used for the Aura window cycler in the launcher">
Window Cycler
</message>
<message name="IDS_AURA_LAUNCHER_OVERFLOW_NAME" desc="The title used for the Aura overflow button in the launcher">
Overflow Button
</message>
</messages>
</release>
</grit>

32 changes: 32 additions & 0 deletions ash/ash_strings.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

{
'variables': {
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome',
},

'targets': [
{
'target_name': 'ash_strings',
'type': 'none',
'actions': [
# Localizable resources.
{
'action_name': 'ash_strings',
'variables': {
'grit_grd_file': 'ash_strings.grd',
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/ash_strings',
},
'includes': [ '../build/grit_action.gypi' ],
},
],
'direct_dependent_settings': {
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/ash_strings',
],
},
},
],
}
6 changes: 6 additions & 0 deletions ash/launcher/app_launcher_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <algorithm>

#include "ash/launcher/launcher_button_host.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/gfx/canvas_skia.h"

namespace ash {
Expand Down Expand Up @@ -81,5 +82,10 @@ void AppLauncherButton::OnMouseExited(const views::MouseEvent& event) {
host_->MouseExitedButton(this);
}

void AppLauncherButton::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
state->name = host_->GetAccessibleName(this);
}

} // namespace internal
} // namespace ash
1 change: 1 addition & 0 deletions ash/launcher/app_launcher_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class AppLauncherButton : public views::ImageButton {
virtual void OnMouseCaptureLost() OVERRIDE;
virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;

private:
LauncherButtonHost* host_;
Expand Down
5 changes: 5 additions & 0 deletions ash/launcher/launcher_button_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#define ASH_LAUNCHER_LAUNCHER_BUTTON_HOST_H_
#pragma once

#include "base/string16.h"

namespace views {
class MouseEvent;
class View;
Expand Down Expand Up @@ -33,6 +35,9 @@ class LauncherButtonHost {
// Invoked when the mouse exits the item.
virtual void MouseExitedButton(views::View* view) = 0;

// Invoked to get the accessible name of the item.
virtual string16 GetAccessibleName(views::View* view) = 0;

protected:
virtual ~LauncherButtonHost() {}
};
Expand Down
25 changes: 25 additions & 0 deletions ash/launcher/launcher_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "base/utf_string_conversions.h"
#include "grit/ash_strings.h"
#include "grit/ui_resources.h"
#include "ui/aura/window.h"
#include "ui/base/animation/animation.h"
#include "ui/base/animation/throb_animation.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/compositor/layer.h"
Expand Down Expand Up @@ -643,5 +645,28 @@ void LauncherView::ButtonPressed(views::Button* sender,
}
}

string16 LauncherView::GetAccessibleName(views::View* view) {
ShellDelegate* delegate = Shell::GetInstance()->delegate();
if (!delegate)
return string16();
int view_index = view_model_->GetIndexOfView(view);
// May be -1 while in the process of animating closed.
if (view_index == -1)
return string16();

switch (model_->items()[view_index].type) {
case TYPE_TABBED:
case TYPE_APP:
return delegate->GetLauncherItemTitle(model_->items()[view_index]);

case TYPE_APP_LIST:
return l10n_util::GetStringUTF16(IDS_AURA_APP_LIST_TITLE);

case TYPE_BROWSER_SHORTCUT:
return l10n_util::GetStringUTF16(IDS_AURA_CYCLER_TITLE);
}
return string16();
}

} // namespace internal
} // namespace ash
1 change: 1 addition & 0 deletions ash/launcher/launcher_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class LauncherView : public views::WidgetDelegateView,
virtual void MouseReleasedOnButton(views::View* view,
bool canceled) OVERRIDE;
virtual void MouseExitedButton(views::View* view) OVERRIDE;
virtual string16 GetAccessibleName(views::View* view) OVERRIDE;

// Overriden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender,
Expand Down
6 changes: 6 additions & 0 deletions ash/launcher/tabbed_launcher_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "ash/launcher/launcher_button_host.h"
#include "grit/ui_resources.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/base/animation/multi_animation.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
Expand Down Expand Up @@ -162,6 +163,11 @@ void TabbedLauncherButton::OnMouseExited(const views::MouseEvent& event) {
hover_controller_.Hide();
}

void TabbedLauncherButton::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = ui::AccessibilityTypes::ROLE_PUSHBUTTON;
state->name = host_->GetAccessibleName(this);
}

// static
TabbedLauncherButton::ImageSet* TabbedLauncherButton::CreateImageSet(
int normal_id,
Expand Down
1 change: 1 addition & 0 deletions ash/launcher/tabbed_launcher_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class TabbedLauncherButton : public views::ImageButton {
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseMoved(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;

private:
// Used as the delegate for |animation_|. TabbedLauncherButton doesn't
Expand Down
2 changes: 2 additions & 0 deletions chrome/chrome_resources.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@
'chrome_strings',
'platform_locale_settings',
'theme_resources',
# TODO(zork): Protect this with if use_aura==1
'<(DEPTH)/ash/ash_strings.gyp:ash_strings',
'<(DEPTH)/content/content_resources.gyp:content_resources',
'<(DEPTH)/net/net.gyp:net_resources',
'<(DEPTH)/ui/base/strings/ui_strings.gyp:ui_strings',
Expand Down
6 changes: 5 additions & 1 deletion chrome/tools/build/repack_locales.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand Down Expand Up @@ -72,6 +72,10 @@ def calc_inputs(locale):
inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'ui_strings',
'ui_strings_%s.pak' % locale))

#e.g. '<(SHARED_INTERMEDIATE_DIR)/ash_strings/ash_strings_da.pak',
inputs.append(os.path.join(SHARE_INT_DIR, 'ash_strings',
'ash_strings_%s.pak' % locale))

#e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings_da.pak',
inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'app_locale_settings',
'app_locale_settings_%s.pak' % locale))
Expand Down
4 changes: 3 additions & 1 deletion chrome/tools/check_grd_for_unused_strings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand Down Expand Up @@ -126,11 +126,13 @@ def main():

# If no GRD files were given, default them:
if len(grd_files) == 0:
ash_base_dir = os.path.join(src_dir, 'ash')
chrome_dir = os.path.join(src_dir, 'chrome')
chrome_app_dir = os.path.join(chrome_dir, 'app')
chrome_app_res_dir = os.path.join(chrome_app_dir, 'resources')
ui_base_dir = os.path.join(src_dir, 'ui', 'base', 'strings')
grd_files = [
os.path.join(ash_base_dir, 'ash_strings.grd'),
os.path.join(chrome_app_dir, 'chromium_strings.grd'),
os.path.join(chrome_app_dir, 'generated_resources.grd'),
os.path.join(chrome_app_dir, 'google_chrome_strings.grd'),
Expand Down
3 changes: 3 additions & 0 deletions tools/gritsettings/resource_ids
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,7 @@
"content/shell/shell_resources.grd": {
"includes": [25000],
},
"ash/ash_strings.grd": {
"messages": [25500],
},
}

0 comments on commit 2b1fbb9

Please sign in to comment.