diff options
author | yoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-27 21:07:11 +0000 |
---|---|---|
committer | yoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-27 21:07:11 +0000 |
commit | 7da9a823b8f64e7502e83ca0fc2c1cb68e63cdc4 (patch) | |
tree | 7c3586db16e97868451cd245849972f22fd14188 /chrome/browser/ui | |
parent | 6bb26a170b75285b9256ab8987fd26a8b57a6a6e (diff) | |
download | chromium_src-7da9a823b8f64e7502e83ca0fc2c1cb68e63cdc4.zip chromium_src-7da9a823b8f64e7502e83ca0fc2c1cb68e63cdc4.tar.gz chromium_src-7da9a823b8f64e7502e83ca0fc2c1cb68e63cdc4.tar.bz2 |
Revert "Change event routers from singletons to being owned by the ExtensionService."
This breaks, among other things, multi-profile and the first run dialog.
Reverting at least for M13.
This reverts commit 45758c29485736d7164085e6b7f8bf0999df1c4f.
BUG=81745
TEST=none
Review URL: http://codereview.chromium.org/7084006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87083 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
3 files changed, 18 insertions, 49 deletions
diff --git a/chrome/browser/ui/views/accessibility_event_router_views.cc b/chrome/browser/ui/views/accessibility_event_router_views.cc index 58aa6aa..34fb85e 100644 --- a/chrome/browser/ui/views/accessibility_event_router_views.cc +++ b/chrome/browser/ui/views/accessibility_event_router_views.cc @@ -10,7 +10,6 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/extensions/extension_accessibility_api.h" -#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/views/location_bar/location_bar_view.h" @@ -35,9 +34,7 @@ using views::FocusManager; AccessibilityEventRouterViews::AccessibilityEventRouterViews() : most_recent_profile_(NULL), - ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), - accessibility_enabled_overridden_for_testing_(false), - accessibility_enabled_override_value_(false) { + ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { } AccessibilityEventRouterViews::~AccessibilityEventRouterViews() { @@ -50,6 +47,11 @@ AccessibilityEventRouterViews* AccessibilityEventRouterViews::GetInstance() { void AccessibilityEventRouterViews::HandleAccessibilityEvent( views::View* view, ui::AccessibilityTypes::Event event_type) { + if (!ExtensionAccessibilityEventRouter::GetInstance()-> + IsAccessibilityEnabled()) { + return; + } + switch (event_type) { case ui::AccessibilityTypes::EVENT_FOCUS: DispatchAccessibilityNotification( @@ -90,12 +92,13 @@ void AccessibilityEventRouterViews::HandleMenuItemFocused( int item_index, int item_count, bool has_submenu) { - if (!most_recent_profile_) + if (!ExtensionAccessibilityEventRouter::GetInstance()-> + IsAccessibilityEnabled()) { return; + } - if (!IsAccessibilityEnabled(most_recent_profile_)) { + if (!most_recent_profile_) return; - } AccessibilityMenuItemInfo info( most_recent_profile_, @@ -111,15 +114,6 @@ void AccessibilityEventRouterViews::HandleMenuItemFocused( // Private methods // -bool AccessibilityEventRouterViews::IsAccessibilityEnabled(Profile* profile) { - if (accessibility_enabled_overridden_for_testing_) { - return accessibility_enabled_override_value_; - } - DCHECK(profile); - return profile->GetExtensionService()->accessibility_event_router()-> - IsAccessibilityEnabled(); -} - std::string AccessibilityEventRouterViews::GetViewName(views::View* view) { ui::AccessibleViewState state; view->GetAccessibleState(&state); @@ -147,10 +141,6 @@ void AccessibilityEventRouterViews::DispatchAccessibilityNotification( return; } - if (!IsAccessibilityEnabled(profile)) { - return; - } - most_recent_profile_ = profile; std::string class_name = view->GetClassName(); @@ -305,8 +295,3 @@ void AccessibilityEventRouterViews::SendCheckboxNotification( SendAccessibilityNotification(type, &info); } -void AccessibilityEventRouterViews::SetAccessibilityEnabledForTesting( - bool enabled) { - accessibility_enabled_overridden_for_testing_ = true; - accessibility_enabled_override_value_ = enabled; -} diff --git a/chrome/browser/ui/views/accessibility_event_router_views.h b/chrome/browser/ui/views/accessibility_event_router_views.h index 7039a8b..44908bd 100644 --- a/chrome/browser/ui/views/accessibility_event_router_views.h +++ b/chrome/browser/ui/views/accessibility_event_router_views.h @@ -73,8 +73,6 @@ class AccessibilityEventRouterViews { FRIEND_TEST_ALL_PREFIXES(AccessibilityEventRouterViewsTest, TestFocusNotification); - bool IsAccessibilityEnabled(Profile* profile); - // Checks the type of the view and calls one of the more specific // Send*Notification methods, below. void DispatchAccessibilityNotification( @@ -113,11 +111,6 @@ class AccessibilityEventRouterViews { void RecursiveGetMenuItemIndexAndCount( views::View* menu, views::View* item, int* index, int* count); - // Used for testing only. Overrides the accessibility enabled setting - // so the test doesn't depend directly on the ExtensionService and - // ExtensionAccessibilityEventRouter. - void SetAccessibilityEnabledForTesting(bool enabled); - // The profile associated with the most recent window event - used to // figure out where to route a few events that can't be directly traced // to a window with a profile (like menu events). @@ -126,10 +119,6 @@ class AccessibilityEventRouterViews { // Used to defer handling of some events until the next time // through the event loop. ScopedRunnableMethodFactory<AccessibilityEventRouterViews> method_factory_; - - // Used for testing only, with SetAccessibilityEnabledForTesting. - bool accessibility_enabled_overridden_for_testing_; - bool accessibility_enabled_override_value_; }; #endif // CHROME_BROWSER_UI_VIEWS_ACCESSIBILITY_EVENT_ROUTER_VIEWS_H_ diff --git a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc index 3dee35fb..3ca6466 100644 --- a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc +++ b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc @@ -8,8 +8,6 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extension_accessibility_api.h" -#include "chrome/browser/extensions/extension_service.h" -#include "chrome/browser/extensions/test_extension_service.h" #include "chrome/browser/ui/views/accessibility_event_router_views.h" #include "chrome/test/testing_profile.h" #include "content/common/notification_registrar.h" @@ -149,15 +147,6 @@ TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { // Put the view in a window. views::Window* window = CreateWindowWithContents(contents); - // Create a profile and associate it with this window. - TestingProfile profile; - window->AsWidget()->native_widget()->SetNativeWindowProperty( - Profile::kProfileKey, &profile); - - // To begin with, accessibility event notifications are off. - AccessibilityEventRouterViews::GetInstance()-> - SetAccessibilityEnabledForTesting(false); - // Set focus to the first button initially. button1->RequestFocus(); @@ -168,8 +157,14 @@ TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) { NotificationService::AllSources()); // Switch on accessibility event notifications. - AccessibilityEventRouterViews::GetInstance()-> - SetAccessibilityEnabledForTesting(true); + ExtensionAccessibilityEventRouter* accessibility_event_router = + ExtensionAccessibilityEventRouter::GetInstance(); + accessibility_event_router->SetAccessibilityEnabled(true); + + // Create a profile and associate it with this window. + TestingProfile profile; + window->AsWidget()->native_widget()->SetNativeWindowProperty( + Profile::kProfileKey, &profile); // Change the accessible name of button3. button3->SetAccessibleName(ASCIIToUTF16(kButton3NewASCII)); |