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

Unified Diff: chrome/browser/ui/views/accessibility_event_router_views.cc

Issue 6312160: Map Views to Profiles directly from their window, eliminating the need... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/accessibility_event_router_views.cc
===================================================================
--- chrome/browser/ui/views/accessibility_event_router_views.cc (revision 74020)
+++ chrome/browser/ui/views/accessibility_event_router_views.cc (working copy)
@@ -21,6 +21,7 @@
#include "views/controls/menu/menu_item_view.h"
#include "views/controls/menu/submenu_view.h"
#include "views/view.h"
+#include "views/window/window.h"
#if defined(OS_WIN)
#include "chrome/browser/autocomplete/autocomplete_edit_view_win.h"
@@ -41,35 +42,6 @@
return Singleton<AccessibilityEventRouterViews>::get();
}
-bool AccessibilityEventRouterViews::AddViewTree(
- views::View* view, Profile* profile) {
- if (view_tree_profile_map_[view] != NULL)
- return false;
-
- view_tree_profile_map_[view] = profile;
- return true;
-}
-
-void AccessibilityEventRouterViews::RemoveViewTree(views::View* view) {
- DCHECK(view_tree_profile_map_.find(view) !=
- view_tree_profile_map_.end());
- view_tree_profile_map_.erase(view);
-}
-
-void AccessibilityEventRouterViews::IgnoreView(views::View* view) {
- view_info_map_[view].ignore = true;
-}
-
-void AccessibilityEventRouterViews::SetViewName(
- views::View* view, std::string name) {
- view_info_map_[view].name = name;
-}
-
-void AccessibilityEventRouterViews::RemoveView(views::View* view) {
- DCHECK(view_info_map_.find(view) != view_info_map_.end());
- view_info_map_.erase(view);
-}
-
void AccessibilityEventRouterViews::HandleAccessibilityEvent(
views::View* view, AccessibilityTypes::Event event_type) {
if (!ExtensionAccessibilityEventRouter::GetInstance()->
@@ -115,80 +87,40 @@
// Private methods
//
-void AccessibilityEventRouterViews::FindView(
- views::View* view, Profile** profile, bool* is_accessible) {
- *is_accessible = false;
-
- // First see if it's a descendant of an accessible view.
- for (base::hash_map<views::View*, Profile*>::const_iterator iter =
- view_tree_profile_map_.begin();
- iter != view_tree_profile_map_.end();
- ++iter) {
- if (iter->first->IsParentOf(view)) {
- *is_accessible = true;
- if (profile)
- *profile = iter->second;
- break;
- }
- }
-
- if (!*is_accessible)
- return;
-
- // Now make sure it's not marked as a widget to be ignored.
- base::hash_map<views::View*, ViewInfo>::const_iterator iter =
- view_info_map_.find(view);
- if (iter != view_info_map_.end() && iter->second.ignore)
- *is_accessible = false;
-}
-
std::string AccessibilityEventRouterViews::GetViewName(views::View* view) {
- std::string name;
-
- // First see if we have a name registered for this view.
- base::hash_map<views::View*, ViewInfo>::const_iterator iter =
- view_info_map_.find(view);
- if (iter != view_info_map_.end())
- name = iter->second.name;
-
- // Otherwise ask the view for its accessible name.
- if (name.empty()) {
- string16 wname;
- view->GetAccessibleName(&wname);
- name = UTF16ToUTF8(wname);
- }
-
- return name;
+ string16 wname;
+ view->GetAccessibleName(&wname);
+ return UTF16ToUTF8(wname);
}
void AccessibilityEventRouterViews::DispatchAccessibilityNotification(
views::View* view, NotificationType type) {
+ // Get the profile associated with this view. If it's not found, use
+ // the most recent profile where accessibility events were sent, or
+ // the default profile.
Profile* profile = NULL;
- bool is_accessible;
- FindView(view, &profile, &is_accessible);
-
- // Special case: a menu isn't associated with any particular top-level
- // window, so menu events get routed to the profile of the most recent
- // event that was associated with a window, which should be the window
- // that triggered opening the menu.
- bool is_menu_event = IsMenuEvent(view, type);
- if (is_menu_event && !profile && most_recent_profile_) {
+ views::Window* window = view->GetWindow();
+ if (window) {
+ profile = reinterpret_cast<Profile*>(window->GetNativeWindowProperty(
+ Profile::kProfileKey));
+ }
+ if (!profile)
profile = most_recent_profile_;
- is_accessible = true;
+ if (!profile)
+ profile = g_browser_process->profile_manager()->GetDefaultProfile();
+ if (!profile) {
+ NOTREACHED();
+ return;
}
- if (!is_accessible)
- return;
-
most_recent_profile_ = profile;
std::string class_name = view->GetClassName();
-
if (class_name == views::MenuButton::kViewClassName ||
type == NotificationType::ACCESSIBILITY_MENU_OPENED ||
type == NotificationType::ACCESSIBILITY_MENU_CLOSED) {
SendMenuNotification(view, type, profile);
- } else if (is_menu_event) {
+ } else if (IsMenuEvent(view, type)) {
SendMenuItemNotification(view, type, profile);
} else if (class_name == views::CustomButton::kViewClassName ||
class_name == views::NativeButton::kViewClassName ||
@@ -198,8 +130,6 @@
SendLinkNotification(view, type, profile);
} else if (class_name == LocationBarView::kViewClassName) {
SendLocationBarNotification(view, type, profile);
- } else {
- class_name += " ";
}
}

Powered by Google App Engine
This is Rietveld 408576698