Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/accessibility_events.h" | 5 #include "chrome/browser/accessibility_events.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" | 9 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | |
| 12 #include "chrome/common/chrome_notification_types.h" | |
| 11 #include "content/common/content_notification_types.h" | 13 #include "content/common/content_notification_types.h" |
| 12 #include "content/common/notification_service.h" | 14 #include "content/common/notification_service.h" |
| 13 | 15 |
| 14 namespace keys = extension_accessibility_api_constants; | 16 namespace keys = extension_accessibility_api_constants; |
| 15 | 17 |
| 16 void SendAccessibilityNotification( | 18 void SendAccessibilityNotification( |
| 17 int type, AccessibilityControlInfo* info) { | 19 int type, AccessibilityEventInfo* info) { |
| 18 Profile *profile = info->profile(); | 20 Profile *profile = info->profile(); |
| 19 if (profile->ShouldSendAccessibilityEvents()) { | 21 if (profile->ShouldSendAccessibilityEvents()) { |
| 20 NotificationService::current()->Notify( | 22 NotificationService::current()->Notify( |
| 21 type, | 23 type, |
| 22 Source<Profile>(profile), | 24 Source<Profile>(profile), |
| 23 Details<AccessibilityControlInfo>(info)); | 25 Details<AccessibilityEventInfo>(info)); |
| 24 } | 26 } |
| 25 } | 27 } |
| 26 | 28 |
| 29 void SendAccessibilityVolumeNotification(double volume, bool is_muted) { | |
| 30 Profile *profile = ProfileManager::GetDefaultProfile(); | |
|
Daniel Erat
2011/08/29 15:05:35
nit: Profile* instead of "Profile *"
yoshiki
2011/08/30 06:43:30
Done.
| |
| 31 AccessibilityVolumeInfo info(profile, volume, is_muted); | |
| 32 SendAccessibilityNotification( | |
| 33 chrome::NOTIFICATION_ACCESSIBILITY_VOLUME_CHANGED, &info); | |
| 34 } | |
| 35 | |
| 27 AccessibilityControlInfo::AccessibilityControlInfo( | 36 AccessibilityControlInfo::AccessibilityControlInfo( |
| 28 Profile* profile, const std::string& control_name) | 37 Profile* profile, const std::string& control_name) |
| 29 : profile_(profile), name_(control_name) { | 38 : AccessibilityEventInfo(profile), name_(control_name) { |
| 30 } | 39 } |
| 31 | 40 |
| 32 AccessibilityControlInfo::~AccessibilityControlInfo() { | 41 AccessibilityControlInfo::~AccessibilityControlInfo() { |
| 33 } | 42 } |
| 34 | 43 |
| 35 void AccessibilityControlInfo::SerializeToDict(DictionaryValue *dict) const { | 44 void AccessibilityControlInfo::SerializeToDict(DictionaryValue *dict) const { |
| 36 dict->SetString(keys::kNameKey, name_); | 45 dict->SetString(keys::kNameKey, name_); |
| 37 dict->SetString(keys::kTypeKey, type()); | 46 dict->SetString(keys::kTypeKey, type()); |
| 38 } | 47 } |
| 39 | 48 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 return keys::kTypeListBox; | 190 return keys::kTypeListBox; |
| 182 } | 191 } |
| 183 | 192 |
| 184 void AccessibilityListBoxInfo::SerializeToDict(DictionaryValue *dict) const { | 193 void AccessibilityListBoxInfo::SerializeToDict(DictionaryValue *dict) const { |
| 185 AccessibilityControlInfo::SerializeToDict(dict); | 194 AccessibilityControlInfo::SerializeToDict(dict); |
| 186 dict->SetString(keys::kValueKey, value_); | 195 dict->SetString(keys::kValueKey, value_); |
| 187 dict->SetInteger(keys::kItemIndexKey, item_index_); | 196 dict->SetInteger(keys::kItemIndexKey, item_index_); |
| 188 dict->SetInteger(keys::kItemCountKey, item_count_); | 197 dict->SetInteger(keys::kItemCountKey, item_count_); |
| 189 } | 198 } |
| 190 | 199 |
| 200 AccessibilityVolumeInfo::AccessibilityVolumeInfo(Profile* profile, | |
| 201 double volume, | |
| 202 bool is_muted) | |
| 203 : AccessibilityEventInfo(profile), | |
| 204 volume_(volume), | |
| 205 is_muted_(is_muted) { | |
| 206 DCHECK(profile); | |
| 207 DCHECK_GE(volume, 0); | |
|
Daniel Erat
2011/08/29 15:05:35
does this actually compile in debug mode? i'd exp
yoshiki
2011/08/30 06:43:30
Done.
| |
| 208 DCHECK_LE(volume, 100); | |
| 209 } | |
| 210 | |
| 211 void AccessibilityVolumeInfo::SerializeToDict(DictionaryValue *dict) const { | |
| 212 dict->SetDouble(keys::kVolumeKey, volume_); | |
| 213 dict->SetBoolean(keys::kIsVolumeMutedKey, is_muted_); | |
| 214 } | |
| 215 | |
| 191 AccessibilityMenuInfo::AccessibilityMenuInfo(Profile* profile, | 216 AccessibilityMenuInfo::AccessibilityMenuInfo(Profile* profile, |
| 192 const std::string& menu_name) | 217 const std::string& menu_name) |
| 193 : AccessibilityControlInfo(profile, menu_name) { | 218 : AccessibilityControlInfo(profile, menu_name) { |
| 194 } | 219 } |
| 195 | 220 |
| 196 const char* AccessibilityMenuInfo::type() const { | 221 const char* AccessibilityMenuInfo::type() const { |
| 197 return keys::kTypeMenu; | 222 return keys::kTypeMenu; |
| 198 } | 223 } |
| 199 | 224 |
| 200 AccessibilityMenuItemInfo::AccessibilityMenuItemInfo(Profile* profile, | 225 AccessibilityMenuItemInfo::AccessibilityMenuItemInfo(Profile* profile, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 211 const char* AccessibilityMenuItemInfo::type() const { | 236 const char* AccessibilityMenuItemInfo::type() const { |
| 212 return keys::kTypeMenuItem; | 237 return keys::kTypeMenuItem; |
| 213 } | 238 } |
| 214 | 239 |
| 215 void AccessibilityMenuItemInfo::SerializeToDict(DictionaryValue *dict) const { | 240 void AccessibilityMenuItemInfo::SerializeToDict(DictionaryValue *dict) const { |
| 216 AccessibilityControlInfo::SerializeToDict(dict); | 241 AccessibilityControlInfo::SerializeToDict(dict); |
| 217 dict->SetBoolean(keys::kHasSubmenuKey, has_submenu_); | 242 dict->SetBoolean(keys::kHasSubmenuKey, has_submenu_); |
| 218 dict->SetInteger(keys::kItemIndexKey, item_index_); | 243 dict->SetInteger(keys::kItemIndexKey, item_index_); |
| 219 dict->SetInteger(keys::kItemCountKey, item_count_); | 244 dict->SetInteger(keys::kItemCountKey, item_count_); |
| 220 } | 245 } |
| OLD | NEW |