summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorchaitanyag@chromium.org <chaitanyag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-09 00:46:08 +0000
committerchaitanyag@chromium.org <chaitanyag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-09 00:46:08 +0000
commit503f1c9a018588a18084e22f7d290c733dffa8a4 (patch)
tree211212b0720b95a51cf7093effa32ee06b3ad78a /chrome/browser
parent700d076a71e1be3352552ab5968d00bb2732bfa1 (diff)
downloadchromium_src-503f1c9a018588a18084e22f7d290c733dffa8a4.zip
chromium_src-503f1c9a018588a18084e22f7d290c733dffa8a4.tar.gz
chromium_src-503f1c9a018588a18084e22f7d290c733dffa8a4.tar.bz2
Move registration of notifications from constructor to a private method
Review URL: http://codereview.chromium.org/3602011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62052 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/login/wizard_accessibility_helper.cc49
-rw-r--r--chrome/browser/chromeos/login/wizard_accessibility_helper.h7
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc2
3 files changed, 37 insertions, 21 deletions
diff --git a/chrome/browser/chromeos/login/wizard_accessibility_helper.cc b/chrome/browser/chromeos/login/wizard_accessibility_helper.cc
index 91f3fb2..77089a7 100644
--- a/chrome/browser/chromeos/login/wizard_accessibility_helper.cc
+++ b/chrome/browser/chromeos/login/wizard_accessibility_helper.cc
@@ -37,28 +37,33 @@ WizardAccessibilityHelper* WizardAccessibilityHelper::GetInstance() {
WizardAccessibilityHelper::WizardAccessibilityHelper() {
accessibility_handler_.reset(new WizardAccessibilityHandler());
profile_ = ProfileManager::GetDefaultProfile();
+ registered_notifications_ = false;
+}
+
+void WizardAccessibilityHelper::RegisterNotifications() {
+ registrar_.Add(accessibility_handler_.get(),
+ NotificationType::ACCESSIBILITY_CONTROL_FOCUSED,
+ NotificationService::AllSources());
+ registrar_.Add(accessibility_handler_.get(),
+ NotificationType::ACCESSIBILITY_CONTROL_ACTION,
+ NotificationService::AllSources());
+ registrar_.Add(accessibility_handler_.get(),
+ NotificationType::ACCESSIBILITY_TEXT_CHANGED,
+ NotificationService::AllSources());
+ registrar_.Add(accessibility_handler_.get(),
+ NotificationType::ACCESSIBILITY_MENU_OPENED,
+ NotificationService::AllSources());
+ registrar_.Add(accessibility_handler_.get(),
+ NotificationType::ACCESSIBILITY_MENU_CLOSED,
+ NotificationService::AllSources());
+ registered_notifications_ = true;
+}
- // http://crosbug.com/7238
- // TODO(dmazzoni), TODO(chaitanyag)
- // Commented out to disable trapping handling and responding to
- // accessibility notifications until the root cause of this bug has
- // been determined.
- //
- //registrar_.Add(accessibility_handler_.get(),
- // NotificationType::ACCESSIBILITY_CONTROL_FOCUSED,
- // NotificationService::AllSources());
- //registrar_.Add(accessibility_handler_.get(),
- // NotificationType::ACCESSIBILITY_CONTROL_ACTION,
- // NotificationService::AllSources());
- //registrar_.Add(accessibility_handler_.get(),
- // NotificationType::ACCESSIBILITY_TEXT_CHANGED,
- // NotificationService::AllSources());
- //registrar_.Add(accessibility_handler_.get(),
- // NotificationType::ACCESSIBILITY_MENU_OPENED,
- // NotificationService::AllSources());
- //registrar_.Add(accessibility_handler_.get(),
- // NotificationType::ACCESSIBILITY_MENU_CLOSED,
- // NotificationService::AllSources());
+void WizardAccessibilityHelper::UnregisterNotifications() {
+ if (!registered_notifications_)
+ return;
+ registrar_.RemoveAll();
+ registered_notifications_ = false;
}
void WizardAccessibilityHelper::MaybeEnableAccessibility(
@@ -83,6 +88,8 @@ void WizardAccessibilityHelper::MaybeSpeak(const char* str, bool queue,
void WizardAccessibilityHelper::EnableAccessibility(views::View* view_tree) {
LOG(INFO) << "Enabling accessibility.";
+ if (!registered_notifications_)
+ RegisterNotifications();
if (g_browser_process) {
PrefService* prefService = g_browser_process->local_state();
if (!prefService->GetBoolean(prefs::kAccessibilityEnabled)) {
diff --git a/chrome/browser/chromeos/login/wizard_accessibility_helper.h b/chrome/browser/chromeos/login/wizard_accessibility_helper.h
index 27c9a9b..f3b2963 100644
--- a/chrome/browser/chromeos/login/wizard_accessibility_helper.h
+++ b/chrome/browser/chromeos/login/wizard_accessibility_helper.h
@@ -51,6 +51,9 @@ class WizardAccessibilityHelper {
// subsequent utterance.
void MaybeSpeak(const char* str, bool queue, bool interruptible);
+ // Unregisters all accessibility notifications
+ void UnregisterNotifications();
+
private:
friend struct DefaultSingletonTraits<WizardAccessibilityHelper>;
@@ -58,6 +61,8 @@ class WizardAccessibilityHelper {
virtual ~WizardAccessibilityHelper() {}
+ void RegisterNotifications();
+
static scoped_ptr<views::Accelerator> accelerator_;
void AddViewToBuffer(views::View* view_tree);
@@ -73,6 +78,8 @@ class WizardAccessibilityHelper {
// Used for tracking registrations to accessibility notifications.
NotificationRegistrar registrar_;
+ bool registered_notifications_;
+
DISALLOW_COPY_AND_ASSIGN(WizardAccessibilityHelper);
};
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index 738a4c2..9401a39 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -251,6 +251,8 @@ WizardController::~WizardController() {
widget_->Close();
default_controller_ = NULL;
+ chromeos::WizardAccessibilityHelper::GetInstance()->
+ UnregisterNotifications();
}
void WizardController::Init(const std::string& first_screen_name,