OLD | NEW |
1 // Copyright (c) 2010 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/chromeos/login/wizard_accessibility_handler.h" | 5 #include "chrome/browser/chromeos/login/wizard_accessibility_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/i18n/char_iterator.h" | 10 #include "base/i18n/char_iterator.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "chrome/browser/accessibility_events.h" | 14 #include "chrome/browser/accessibility_events.h" |
15 #include "chrome/browser/chromeos/cros/cros_library.h" | 15 #include "chrome/browser/chromeos/cros/cros_library.h" |
16 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" | 16 #include "chrome/browser/chromeos/cros/speech_synthesis_library.h" |
17 #include "chrome/browser/extensions/extension_accessibility_api.h" | 17 #include "chrome/browser/extensions/extension_accessibility_api.h" |
18 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" | 18 #include "chrome/browser/extensions/extension_accessibility_api_constants.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/common/notification_details.h" | 20 #include "chrome/common/notification_details.h" |
21 #include "chrome/common/notification_registrar.h" | 21 #include "chrome/common/notification_registrar.h" |
22 #include "chrome/common/notification_source.h" | 22 #include "chrome/common/notification_source.h" |
23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
24 | 24 |
25 namespace keys = extension_accessibility_api_constants; | 25 namespace keys = extension_accessibility_api_constants; |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 static std::string SubstringUTF8(std::string str, int start, int len) { | 29 static std::string SubstringUTF8(std::string str, int start, int len) { |
30 base::UTF8CharIterator iter(&str); | 30 base::i18n::UTF8CharIterator iter(&str); |
31 for (int i = 0; i < start; i++) { | 31 for (int i = 0; i < start; i++) { |
32 if (!iter.Advance()) | 32 if (!iter.Advance()) |
33 return std::string(); | 33 return std::string(); |
34 } | 34 } |
35 | 35 |
36 int byte_start = iter.array_pos(); | 36 int byte_start = iter.array_pos(); |
37 for (int i = 0; i < len; i++) { | 37 for (int i = 0; i < len; i++) { |
38 if (!iter.Advance()) | 38 if (!iter.Advance()) |
39 break; | 39 break; |
40 } | 40 } |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } else { | 293 } else { |
294 DescribeTextContentsChanged(old_value, new_value, | 294 DescribeTextContentsChanged(old_value, new_value, |
295 out_spoken_description); | 295 out_spoken_description); |
296 } | 296 } |
297 } | 297 } |
298 | 298 |
299 std::string WizardAccessibilityHandler::GetTextBoxValue( | 299 std::string WizardAccessibilityHandler::GetTextBoxValue( |
300 const AccessibilityTextBoxInfo* textbox_info) { | 300 const AccessibilityTextBoxInfo* textbox_info) { |
301 std::string value = textbox_info->value(); | 301 std::string value = textbox_info->value(); |
302 if (textbox_info->password()) { | 302 if (textbox_info->password()) { |
303 base::UTF8CharIterator iter(&value); | 303 base::i18n::UTF8CharIterator iter(&value); |
304 std::string obscured; | 304 std::string obscured; |
305 while (!iter.end()) { | 305 while (!iter.end()) { |
306 obscured += "*"; | 306 obscured += "*"; |
307 iter.Advance(); | 307 iter.Advance(); |
308 } | 308 } |
309 return obscured; | 309 return obscured; |
310 } else { | 310 } else { |
311 return value; | 311 return value; |
312 } | 312 } |
313 } | 313 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 const std::string& old_value, | 370 const std::string& old_value, |
371 const std::string& new_value, | 371 const std::string& new_value, |
372 std::string* out_spoken_description) { | 372 std::string* out_spoken_description) { |
373 int old_array_len = old_value.size(); | 373 int old_array_len = old_value.size(); |
374 int new_array_len = new_value.size(); | 374 int new_array_len = new_value.size(); |
375 | 375 |
376 // Get the unicode characters and indices of the start of each | 376 // Get the unicode characters and indices of the start of each |
377 // character's UTF8-encoded representation. | 377 // character's UTF8-encoded representation. |
378 scoped_array<int32> old_chars(new int32[old_array_len]); | 378 scoped_array<int32> old_chars(new int32[old_array_len]); |
379 scoped_array<int> old_indices(new int[old_array_len + 1]); | 379 scoped_array<int> old_indices(new int[old_array_len + 1]); |
380 base::UTF8CharIterator old_iter(&old_value); | 380 base::i18n::UTF8CharIterator old_iter(&old_value); |
381 while (!old_iter.end()) { | 381 while (!old_iter.end()) { |
382 old_chars[old_iter.char_pos()] = old_iter.get(); | 382 old_chars[old_iter.char_pos()] = old_iter.get(); |
383 old_indices[old_iter.char_pos()] = old_iter.array_pos(); | 383 old_indices[old_iter.char_pos()] = old_iter.array_pos(); |
384 old_iter.Advance(); | 384 old_iter.Advance(); |
385 } | 385 } |
386 int old_char_len = old_iter.char_pos(); | 386 int old_char_len = old_iter.char_pos(); |
387 old_indices[old_char_len] = old_iter.array_pos(); | 387 old_indices[old_char_len] = old_iter.array_pos(); |
388 | 388 |
389 scoped_array<int32> new_chars(new int32[new_array_len]); | 389 scoped_array<int32> new_chars(new int32[new_array_len]); |
390 scoped_array<int> new_indices(new int[new_array_len + 1]); | 390 scoped_array<int> new_indices(new int[new_array_len + 1]); |
391 base::UTF8CharIterator new_iter(&new_value); | 391 base::i18n::UTF8CharIterator new_iter(&new_value); |
392 while (!new_iter.end()) { | 392 while (!new_iter.end()) { |
393 new_chars[new_iter.char_pos()] = new_iter.get(); | 393 new_chars[new_iter.char_pos()] = new_iter.get(); |
394 new_indices[new_iter.char_pos()] = new_iter.array_pos(); | 394 new_indices[new_iter.char_pos()] = new_iter.array_pos(); |
395 new_iter.Advance(); | 395 new_iter.Advance(); |
396 } | 396 } |
397 int new_char_len = new_iter.char_pos(); | 397 int new_char_len = new_iter.char_pos(); |
398 new_indices[new_char_len] = new_iter.array_pos(); | 398 new_indices[new_char_len] = new_iter.array_pos(); |
399 | 399 |
400 // Find the common prefix of the two strings. | 400 // Find the common prefix of the two strings. |
401 int prefix_char_len = 0; | 401 int prefix_char_len = 0; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 } else if (inserted.size() > 0) { | 437 } else if (inserted.size() > 0) { |
438 // Speak inserted text. | 438 // Speak inserted text. |
439 AppendUtterance(inserted, out_spoken_description); | 439 AppendUtterance(inserted, out_spoken_description); |
440 } else if (deleted.size() > 0) { | 440 } else if (deleted.size() > 0) { |
441 // Speak deleted text. | 441 // Speak deleted text. |
442 AppendUtterance(deleted, out_spoken_description); | 442 AppendUtterance(deleted, out_spoken_description); |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 } // namespace chromeos | 446 } // namespace chromeos |
OLD | NEW |