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

Side by Side Diff: chrome/browser/ui/views/accessible_view_helper.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/accessible_view_helper.h"
6
7 #include "chrome/browser/accessibility_events.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/views/accessibility_event_router_views.h"
10 #include "chrome/common/notification_service.h"
11 #include "ui/base/l10n/l10n_util.h"
12 #include "views/controls/native/native_view_host.h"
13 #include "views/widget/widget.h"
14 #include "views/view.h"
15
16 AccessibleViewHelper::AccessibleViewHelper(
17 views::View* view_tree, Profile* profile)
18 : accessibility_event_router_(AccessibilityEventRouterViews::GetInstance()),
19 profile_(profile),
20 view_tree_(view_tree) {
21 if (!accessibility_event_router_->AddViewTree(view_tree_, profile))
22 view_tree_ = NULL;
23
24 #if defined(OS_LINUX)
25 GtkWidget* widget = view_tree->GetWidget()->GetNativeView();
26 widget_helper_.reset(new AccessibleWidgetHelper(widget, profile));
27 #endif
28 }
29
30 AccessibleViewHelper::~AccessibleViewHelper() {
31 if (!window_title_.empty()) {
32 AccessibilityWindowInfo info(profile_, window_title_);
33 NotificationService::current()->Notify(
34 NotificationType::ACCESSIBILITY_WINDOW_CLOSED,
35 Source<Profile>(profile_),
36 Details<AccessibilityWindowInfo>(&info));
37 }
38
39 if (view_tree_) {
40 accessibility_event_router_->RemoveViewTree(view_tree_);
41 for (std::vector<views::View*>::iterator iter = managed_views_.begin();
42 iter != managed_views_.end();
43 ++iter) {
44 accessibility_event_router_->RemoveView(*iter);
45 }
46 }
47 }
48
49 void AccessibleViewHelper::SendOpenWindowNotification(
50 const std::string& window_title) {
51 window_title_ = window_title;
52 AccessibilityWindowInfo info(profile_, window_title);
53 NotificationService::current()->Notify(
54 NotificationType::ACCESSIBILITY_WINDOW_OPENED,
55 Source<Profile>(profile_),
56 Details<AccessibilityWindowInfo>(&info));
57 }
58
59 void AccessibleViewHelper::SetViewName(views::View* view, std::string name) {
60 if (!view_tree_)
61 return;
62
63 accessibility_event_router_->SetViewName(view, name);
64 managed_views_.push_back(view);
65
66 #if defined(OS_LINUX)
67 gfx::NativeView native_view = GetNativeView(view);
68 if (native_view)
69 widget_helper_->SetWidgetName(native_view, name);
70 #endif
71 }
72
73 void AccessibleViewHelper::SetViewName(views::View* view, int string_id) {
74 const std::string name = l10n_util::GetStringUTF8(string_id);
75 SetViewName(view, name);
76 }
77
78 gfx::NativeView AccessibleViewHelper::GetNativeView(views::View* view) const {
79 if (view->GetClassName() == views::NativeViewHost::kViewClassName)
80 return static_cast<views::NativeViewHost*>(view)->native_view();
81
82 for (int i = 0; i < view->GetChildViewCount(); i++) {
83 gfx::NativeView native_view = GetNativeView(view->GetChildViewAt(i));
84 if (native_view)
85 return native_view;
86 }
87
88 return NULL;
89 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/accessible_view_helper.h ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698