diff options
| author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-14 02:11:30 +0000 |
|---|---|---|
| committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-14 02:11:30 +0000 |
| commit | 28b2c9f571517b8b5e733d08e8245dc04dd7c7b3 (patch) | |
| tree | c17411ea7e7f51d82795833c46c78ef811599df2 /chrome | |
| parent | c0264d4ace26f16fdc216f3a8e533a3387baecb2 (diff) | |
| download | chromium_src-28b2c9f571517b8b5e733d08e8245dc04dd7c7b3.zip chromium_src-28b2c9f571517b8b5e733d08e8245dc04dd7c7b3.tar.gz chromium_src-28b2c9f571517b8b5e733d08e8245dc04dd7c7b3.tar.bz2 | |
Get the new frames to pass the accessibility UI tests.
B=2235
Review URL: http://codereview.chromium.org/3039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
| -rw-r--r-- | chrome/browser/views/frame/opaque_non_client_view.cc | 38 | ||||
| -rw-r--r-- | chrome/browser/views/frame/opaque_non_client_view.h | 6 | ||||
| -rw-r--r-- | chrome/test/accessibility/accessibility_util.cc | 40 | ||||
| -rw-r--r-- | chrome/test/accessibility/constants.h | 14 |
4 files changed, 90 insertions, 8 deletions
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc index 4cefabb..7fdbe04 100644 --- a/chrome/browser/views/frame/opaque_non_client_view.cc +++ b/chrome/browser/views/frame/opaque_non_client_view.cc @@ -10,8 +10,11 @@ #include "chrome/browser/views/window_resources.h" #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/gfx/path.h" +#include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" - +#include "chrome/views/root_view.h" +#include "chromium_strings.h" +#include "generated_resources.h" // An enumeration of bitmap resources used by this window. enum { @@ -404,6 +407,8 @@ OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame, ChromeViews::Button::BS_PUSHED, resources->GetPartBitmap(FRAME_MINIMIZE_BUTTON_ICON_P)); minimize_button_->SetListener(this, -1); + minimize_button_->SetAccessibleName( + l10n_util::GetString(IDS_ACCNAME_MINIMIZE)); AddChildView(minimize_button_); maximize_button_->SetImage( @@ -416,6 +421,8 @@ OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame, ChromeViews::Button::BS_PUSHED, resources->GetPartBitmap(FRAME_MAXIMIZE_BUTTON_ICON_P)); maximize_button_->SetListener(this, -1); + maximize_button_->SetAccessibleName( + l10n_util::GetString(IDS_ACCNAME_MAXIMIZE)); AddChildView(maximize_button_); restore_button_->SetImage( @@ -428,6 +435,8 @@ OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame, ChromeViews::Button::BS_PUSHED, resources->GetPartBitmap(FRAME_RESTORE_BUTTON_ICON_P)); restore_button_->SetListener(this, -1); + restore_button_->SetAccessibleName( + l10n_util::GetString(IDS_ACCNAME_RESTORE)); AddChildView(restore_button_); close_button_->SetImage( @@ -440,6 +449,7 @@ OpaqueNonClientView::OpaqueNonClientView(OpaqueFrame* frame, ChromeViews::Button::BS_PUSHED, resources->GetPartBitmap(FRAME_CLOSE_BUTTON_ICON_P)); close_button_->SetListener(this, -1); + close_button_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_CLOSE)); AddChildView(close_button_); window_icon_->set_is_light(true); @@ -663,9 +673,35 @@ void OpaqueNonClientView::ViewHierarchyChanged(bool is_add, DCHECK(GetViewContainer()); DCHECK(frame_->client_view()->GetParent() != this); AddChildView(frame_->client_view()); + + // The Accessibility glue looks for the product name on these two views to + // determine if this is in fact a Chrome window. + GetRootView()->SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); + SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); } } +bool OpaqueNonClientView::GetAccessibleRole(VARIANT* role) { + DCHECK(role); + // We aren't actually the client area of the window, but we act like it as + // far as MSAA and the UI tests are concerned. + role->vt = VT_I4; + role->lVal = ROLE_SYSTEM_CLIENT; + return true; +} + +bool OpaqueNonClientView::GetAccessibleName(std::wstring* name) { + if (!accessible_name_.empty()) { + *name = accessible_name_; + return true; + } + return false; +} + +void OpaqueNonClientView::SetAccessibleName(const std::wstring& name) { + accessible_name_ = name; +} + /////////////////////////////////////////////////////////////////////////////// // OpaqueNonClientView, private: diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_non_client_view.h index 227baa4..e684d81 100644 --- a/chrome/browser/views/frame/opaque_non_client_view.h +++ b/chrome/browser/views/frame/opaque_non_client_view.h @@ -63,6 +63,9 @@ class OpaqueNonClientView : public ChromeViews::NonClientView, virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child); + virtual bool GetAccessibleRole(VARIANT* role); + virtual bool GetAccessibleName(std::wstring* name); + virtual void SetAccessibleName(const std::wstring& name); private: // Updates the system menu icon button. @@ -122,6 +125,9 @@ class OpaqueNonClientView : public ChromeViews::NonClientView, WindowResources* current_active_resources_; WindowResources* current_inactive_resources_; + // The accessible name of this view. + std::wstring accessible_name_; + static void InitClass(); static SkBitmap distributor_logo_; static WindowResources* active_resources_; diff --git a/chrome/test/accessibility/accessibility_util.cc b/chrome/test/accessibility/accessibility_util.cc index da04bc6..82a4121 100644 --- a/chrome/test/accessibility/accessibility_util.cc +++ b/chrome/test/accessibility/accessibility_util.cc @@ -2,18 +2,36 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "accessibility_util.h" -#include "constants.h" +#include "chrome/test/accessibility/accessibility_util.h" + +#include "base/win_util.h" #include "chrome/common/win_util.h" #include "chrome/common/l10n_util.h" #include "chrome/browser/views/old_frames/xp_frame.h" #include "chrome/browser/views/old_frames/vista_frame.h" +#include "chrome/test/accessibility/constants.h" #include "chromium_strings.h" #include "generated_resources.h" VARIANT g_var_self = {VT_I4, CHILDID_SELF}; +// TODO(beng): clean this up +static const wchar_t* kBrowserWindowKey = L"__BROWSER_WINDOW__"; + +static BOOL CALLBACK WindowEnumProc(HWND hwnd, LPARAM data) { + std::wstring class_name = win_util::GetClassName(hwnd); + if (class_name == L"Chrome_HWNDViewContainer_0") { + HANDLE window_interface = GetProp(hwnd, kBrowserWindowKey); + if (window_interface) { + HWND* out = reinterpret_cast<HWND*>(data); + *out = hwnd; + return FALSE; + } + } + return TRUE; +} + HWND GetChromeBrowserWnd(IAccessible** ppi_access) { HRESULT hr = S_OK; HWND hwnd = NULL; @@ -22,11 +40,15 @@ HWND GetChromeBrowserWnd(IAccessible** ppi_access) { const std::wstring product_name = l10n_util::GetString(IDS_PRODUCT_NAME); - // Get Chrome window handle. - if (win_util::ShouldUseVistaFrame()) { - hwnd = FindWindow(VISTA_FRAME_CLASSNAME, NULL); - } else { - hwnd = FindWindow(XP_FRAME_CLASSNAME, NULL); + EnumWindows(WindowEnumProc, reinterpret_cast<LPARAM>(&hwnd)); + if (!IsWindow(hwnd)) { + // Didn't find the window handle by looking for the new frames, assume the + // old frames are being used instead... + if (win_util::ShouldUseVistaFrame()) { + hwnd = FindWindow(VISTA_FRAME_CLASSNAME, NULL); + } else { + hwnd = FindWindow(XP_FRAME_CLASSNAME, NULL); + } } if (NULL == hwnd) { @@ -199,7 +221,11 @@ HRESULT GetChildWndOf(std::wstring parent_name, unsigned int child_index, } HRESULT GetTabStripWnd(IAccessible** ppi_access) { +#ifdef NEW_FRAMES + return GetChildWndOf(BROWSER_VIEW_STR, TABSTRIP_ACC_INDEX, ppi_access, NULL); +#else return GetChildWndOf(BROWSER_STR, TABSTRIP_ACC_INDEX, ppi_access, NULL); +#endif } HRESULT GetBrowserViewWnd(IAccessible** ppi_access) { diff --git a/chrome/test/accessibility/constants.h b/chrome/test/accessibility/constants.h index 0d86d68c..b265e4b 100644 --- a/chrome/test/accessibility/constants.h +++ b/chrome/test/accessibility/constants.h @@ -35,6 +35,14 @@ #define CHROME_CLIENT_ACC_INDEX (0) // Chrome Client chidren. +#ifdef NEW_FRAMES +#define BROWSER_VIEW_ACC_INDEX (5) +#define TABSTRIP_ACC_INDEX (0) +#define CHROME_MIN_ACC_INDEX (0) +#define CHROME_MAX_ACC_INDEX (1) +#define CHROME_RESTORE_ACC_INDEX (2) +#define CHROME_CLOSE_ACC_INDEX (3) +#else #define BROWSER_VIEW_ACC_INDEX (0) #define TABSTRIP_ACC_INDEX (1) #if defined(GOOGLE_CHROME_BUILD) @@ -48,8 +56,14 @@ #define CHROME_RESTORE_ACC_INDEX (5) #define CHROME_CLOSE_ACC_INDEX (6) #endif +#endif + // Browser View children. +#ifdef NEW_FRAMES +#define TOOLBAR_ACC_INDEX (1) +#else #define TOOLBAR_ACC_INDEX (0) +#endif // Toolbar children. #define BACK_BTN_INDEX (0) |
