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

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_util.cc

Issue 10109001: Replace all LOGs in input_method/, except two user-facing errors, to DVLOG(1). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 8 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/input_method/input_method_util.h" 5 #include "chrome/browser/chromeos/input_method/input_method_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 language_code_to_ids.equal_range(normalized_language_code); 525 language_code_to_ids.equal_range(normalized_language_code);
526 for (LanguageCodeToIdsMap::const_iterator iter = range.first; 526 for (LanguageCodeToIdsMap::const_iterator iter = range.first;
527 iter != range.second; ++iter) { 527 iter != range.second; ++iter) {
528 const std::string& input_method_id = iter->second; 528 const std::string& input_method_id = iter->second;
529 if ((type == kAllInputMethods) || IsKeyboardLayout(input_method_id)) { 529 if ((type == kAllInputMethods) || IsKeyboardLayout(input_method_id)) {
530 out_input_method_ids->push_back(input_method_id); 530 out_input_method_ids->push_back(input_method_id);
531 result = true; 531 result = true;
532 } 532 }
533 } 533 }
534 if ((type == kAllInputMethods) && !result) { 534 if ((type == kAllInputMethods) && !result) {
535 LOG(ERROR) << "Unknown language code: " << normalized_language_code; 535 DVLOG(1) << "Unknown language code: " << normalized_language_code;
536 } 536 }
537 return result; 537 return result;
538 } 538 }
539 539
540 void InputMethodUtil::GetFirstLoginInputMethodIds( 540 void InputMethodUtil::GetFirstLoginInputMethodIds(
541 const std::string& language_code, 541 const std::string& language_code,
542 const InputMethodDescriptor& current_input_method, 542 const InputMethodDescriptor& current_input_method,
543 std::vector<std::string>* out_input_method_ids) const { 543 std::vector<std::string>* out_input_method_ids) const {
544 out_input_method_ids->clear(); 544 out_input_method_ids->clear();
545 545
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 void InputMethodUtil::GetLanguageCodesFromInputMethodIds( 589 void InputMethodUtil::GetLanguageCodesFromInputMethodIds(
590 const std::vector<std::string>& input_method_ids, 590 const std::vector<std::string>& input_method_ids,
591 std::vector<std::string>* out_language_codes) const { 591 std::vector<std::string>* out_language_codes) const {
592 out_language_codes->clear(); 592 out_language_codes->clear();
593 593
594 for (size_t i = 0; i < input_method_ids.size(); ++i) { 594 for (size_t i = 0; i < input_method_ids.size(); ++i) {
595 const std::string& input_method_id = input_method_ids[i]; 595 const std::string& input_method_id = input_method_ids[i];
596 const InputMethodDescriptor* input_method = 596 const InputMethodDescriptor* input_method =
597 GetInputMethodDescriptorFromId(input_method_id); 597 GetInputMethodDescriptorFromId(input_method_id);
598 if (!input_method) { 598 if (!input_method) {
599 LOG(ERROR) << "Unknown input method ID: " << input_method_ids[i]; 599 DVLOG(1) << "Unknown input method ID: " << input_method_ids[i];
600 continue; 600 continue;
601 } 601 }
602 const std::string language_code = input_method->language_code(); 602 const std::string language_code = input_method->language_code();
603 // Add it if it's not already present. 603 // Add it if it's not already present.
604 if (std::count(out_language_codes->begin(), out_language_codes->end(), 604 if (std::count(out_language_codes->begin(), out_language_codes->end(),
605 language_code) == 0) { 605 language_code) == 0) {
606 out_language_codes->push_back(language_code); 606 out_language_codes->push_back(language_code);
607 } 607 }
608 } 608 }
609 } 609 }
610 610
611 std::string InputMethodUtil::GetHardwareInputMethodId() const { 611 std::string InputMethodUtil::GetHardwareInputMethodId() const {
612 if (!hardware_input_method_id_for_testing_.empty()) { 612 if (!hardware_input_method_id_for_testing_.empty()) {
613 return hardware_input_method_id_for_testing_; 613 return hardware_input_method_id_for_testing_;
614 } 614 }
615 615
616 if (!(g_browser_process && g_browser_process->local_state())) { 616 if (!(g_browser_process && g_browser_process->local_state())) {
617 // This shouldn't happen but just in case. 617 // This shouldn't happen but just in case.
618 VLOG(1) << "Local state is not yet ready"; 618 DVLOG(1) << "Local state is not yet ready";
619 return InputMethodDescriptor::GetFallbackInputMethodDescriptor().id(); 619 return InputMethodDescriptor::GetFallbackInputMethodDescriptor().id();
620 } 620 }
621 621
622 PrefService* local_state = g_browser_process->local_state(); 622 PrefService* local_state = g_browser_process->local_state();
623 if (!local_state->FindPreference(prefs::kHardwareKeyboardLayout)) { 623 if (!local_state->FindPreference(prefs::kHardwareKeyboardLayout)) {
624 // This could happen in unittests. We register the preference in 624 // This could happen in unittests. We register the preference in
625 // BrowserMain::InitializeLocalState and that method is not called during 625 // BrowserMain::InitializeLocalState and that method is not called during
626 // unittests. 626 // unittests.
627 LOG(ERROR) << prefs::kHardwareKeyboardLayout << " is not registered"; 627 DVLOG(1) << prefs::kHardwareKeyboardLayout << " is not registered";
628 return InputMethodDescriptor::GetFallbackInputMethodDescriptor().id(); 628 return InputMethodDescriptor::GetFallbackInputMethodDescriptor().id();
629 } 629 }
630 630
631 const std::string input_method_id = 631 const std::string input_method_id =
632 local_state->GetString(prefs::kHardwareKeyboardLayout); 632 local_state->GetString(prefs::kHardwareKeyboardLayout);
633 if (input_method_id.empty()) { 633 if (input_method_id.empty()) {
634 // This is totally fine if it's empty. The hardware keyboard layout is 634 // This is totally fine if it's empty. The hardware keyboard layout is
635 // not stored if startup_manifest.json (OEM customization data) is not 635 // not stored if startup_manifest.json (OEM customization data) is not
636 // present (ex. Cr48 doen't have that file). 636 // present (ex. Cr48 doen't have that file).
637 return InputMethodDescriptor::GetFallbackInputMethodDescriptor().id(); 637 return InputMethodDescriptor::GetFallbackInputMethodDescriptor().id();
638 } 638 }
639 return input_method_id; 639 return input_method_id;
640 } 640 }
641 641
642 void InputMethodUtil::ReloadInternalMaps() { 642 void InputMethodUtil::ReloadInternalMaps() {
643 if (supported_input_methods_->size() <= 1) { 643 if (supported_input_methods_->size() <= 1) {
644 LOG(ERROR) << "GetSupportedInputMethods returned a fallback ID"; 644 DVLOG(1) << "GetSupportedInputMethods returned a fallback ID";
645 // TODO(yusukes): Handle this error in nicer way. 645 // TODO(yusukes): Handle this error in nicer way.
646 } 646 }
647 647
648 // Clear the existing maps. 648 // Clear the existing maps.
649 language_code_to_ids_.clear(); 649 language_code_to_ids_.clear();
650 id_to_language_code_.clear(); 650 id_to_language_code_.clear();
651 id_to_descriptor_.clear(); 651 id_to_descriptor_.clear();
652 xkb_id_to_descriptor_.clear(); 652 xkb_id_to_descriptor_.clear();
653 653
654 for (size_t i = 0; i < supported_input_methods_->size(); ++i) { 654 for (size_t i = 0; i < supported_input_methods_->size(); ++i) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 ReloadInternalMaps(); 688 ReloadInternalMaps();
689 } 689 }
690 690
691 void InputMethodUtil::SetHardwareInputMethodIdForTesting( 691 void InputMethodUtil::SetHardwareInputMethodIdForTesting(
692 const std::string& input_method_id) { 692 const std::string& input_method_id) {
693 hardware_input_method_id_for_testing_ = input_method_id; 693 hardware_input_method_id_for_testing_ = input_method_id;
694 } 694 }
695 695
696 } // namespace input_method 696 } // namespace input_method
697 } // namespace chromeos 697 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698