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

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

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
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_manager_impl.h" 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8
8 #include <algorithm> // std::find 9 #include <algorithm> // std::find
10 #include <memory>
9 #include <sstream> 11 #include <sstream>
10 #include <utility> 12 #include <utility>
11 13
12 #include "base/bind.h" 14 #include "base/bind.h"
13 #include "base/hash.h" 15 #include "base/hash.h"
14 #include "base/location.h" 16 #include "base/location.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
17 #include "base/metrics/sparse_histogram.h" 18 #include "base/metrics/sparse_histogram.h"
18 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
19 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
21 #include "base/sys_info.h" 22 #include "base/sys_info.h"
22 #include "chrome/browser/browser_process.h" 23 #include "chrome/browser/browser_process.h"
23 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h" 24 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
24 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_i mpl.h" 25 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_i mpl.h"
25 #include "chrome/browser/chromeos/input_method/input_method_switch_recorder.h" 26 #include "chrome/browser/chromeos/input_method/input_method_switch_recorder.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return os.str(); 167 return os.str();
167 } 168 }
168 169
169 scoped_refptr<InputMethodManager::State> 170 scoped_refptr<InputMethodManager::State>
170 InputMethodManagerImpl::StateImpl::Clone() const { 171 InputMethodManagerImpl::StateImpl::Clone() const {
171 scoped_refptr<StateImpl> new_state(new StateImpl(this->manager_, profile)); 172 scoped_refptr<StateImpl> new_state(new StateImpl(this->manager_, profile));
172 new_state->InitFrom(*this); 173 new_state->InitFrom(*this);
173 return scoped_refptr<InputMethodManager::State>(new_state.get()); 174 return scoped_refptr<InputMethodManager::State>(new_state.get());
174 } 175 }
175 176
176 scoped_ptr<InputMethodDescriptors> 177 std::unique_ptr<InputMethodDescriptors>
177 InputMethodManagerImpl::StateImpl::GetActiveInputMethods() const { 178 InputMethodManagerImpl::StateImpl::GetActiveInputMethods() const {
178 scoped_ptr<InputMethodDescriptors> result(new InputMethodDescriptors); 179 std::unique_ptr<InputMethodDescriptors> result(new InputMethodDescriptors);
179 // Build the active input method descriptors from the active input 180 // Build the active input method descriptors from the active input
180 // methods cache |active_input_method_ids|. 181 // methods cache |active_input_method_ids|.
181 for (size_t i = 0; i < active_input_method_ids.size(); ++i) { 182 for (size_t i = 0; i < active_input_method_ids.size(); ++i) {
182 const std::string& input_method_id = active_input_method_ids[i]; 183 const std::string& input_method_id = active_input_method_ids[i];
183 const InputMethodDescriptor* descriptor = 184 const InputMethodDescriptor* descriptor =
184 manager_->util_.GetInputMethodDescriptorFromId(input_method_id); 185 manager_->util_.GetInputMethodDescriptorFromId(input_method_id);
185 if (descriptor) { 186 if (descriptor) {
186 result->push_back(*descriptor); 187 result->push_back(*descriptor);
187 } else { 188 } else {
188 std::map<std::string, InputMethodDescriptor>::const_iterator ix = 189 std::map<std::string, InputMethodDescriptor>::const_iterator ix =
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 false /* show_message */, true /* notify_menu */); 839 false /* show_message */, true /* notify_menu */);
839 } 840 }
840 } 841 }
841 842
842 scoped_refptr<InputMethodManager::State> 843 scoped_refptr<InputMethodManager::State>
843 InputMethodManagerImpl::GetActiveIMEState() { 844 InputMethodManagerImpl::GetActiveIMEState() {
844 return scoped_refptr<InputMethodManager::State>(state_.get()); 845 return scoped_refptr<InputMethodManager::State>(state_.get());
845 } 846 }
846 847
847 InputMethodManagerImpl::InputMethodManagerImpl( 848 InputMethodManagerImpl::InputMethodManagerImpl(
848 scoped_ptr<InputMethodDelegate> delegate, 849 std::unique_ptr<InputMethodDelegate> delegate,
849 bool enable_extension_loading) 850 bool enable_extension_loading)
850 : delegate_(std::move(delegate)), 851 : delegate_(std::move(delegate)),
851 ui_session_(STATE_LOGIN_SCREEN), 852 ui_session_(STATE_LOGIN_SCREEN),
852 state_(NULL), 853 state_(NULL),
853 util_(delegate_.get()), 854 util_(delegate_.get()),
854 component_extension_ime_manager_(new ComponentExtensionIMEManager()), 855 component_extension_ime_manager_(new ComponentExtensionIMEManager()),
855 enable_extension_loading_(enable_extension_loading), 856 enable_extension_loading_(enable_extension_loading),
856 is_ime_menu_activated_(false) { 857 is_ime_menu_activated_(false) {
857 if (base::SysInfo::IsRunningOnChromeOS()) 858 if (base::SysInfo::IsRunningOnChromeOS())
858 keyboard_.reset(ImeKeyboard::Create()); 859 keyboard_.reset(ImeKeyboard::Create());
859 else 860 else
860 keyboard_.reset(new FakeImeKeyboard()); 861 keyboard_.reset(new FakeImeKeyboard());
861 862
862 // Initializes the system IME list. 863 // Initializes the system IME list.
863 scoped_ptr<ComponentExtensionIMEManagerDelegate> comp_delegate( 864 std::unique_ptr<ComponentExtensionIMEManagerDelegate> comp_delegate(
864 new ComponentExtensionIMEManagerImpl()); 865 new ComponentExtensionIMEManagerImpl());
865 component_extension_ime_manager_->Initialize(std::move(comp_delegate)); 866 component_extension_ime_manager_->Initialize(std::move(comp_delegate));
866 const InputMethodDescriptors& descriptors = 867 const InputMethodDescriptors& descriptors =
867 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor(); 868 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor();
868 util_.ResetInputMethods(descriptors); 869 util_.ResetInputMethods(descriptors);
869 chromeos::UserAddingScreen::Get()->AddObserver(this); 870 chromeos::UserAddingScreen::Get()->AddObserver(this);
870 } 871 }
871 872
872 InputMethodManagerImpl::~InputMethodManagerImpl() { 873 InputMethodManagerImpl::~InputMethodManagerImpl() {
873 if (candidate_window_controller_.get()) 874 if (candidate_window_controller_.get())
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 void InputMethodManagerImpl::OnUserAddingStarted() { 937 void InputMethodManagerImpl::OnUserAddingStarted() {
937 if (ui_session_ == STATE_BROWSER_SCREEN) 938 if (ui_session_ == STATE_BROWSER_SCREEN)
938 SetUISessionState(STATE_SECONDARY_LOGIN_SCREEN); 939 SetUISessionState(STATE_SECONDARY_LOGIN_SCREEN);
939 } 940 }
940 941
941 void InputMethodManagerImpl::OnUserAddingFinished() { 942 void InputMethodManagerImpl::OnUserAddingFinished() {
942 if (ui_session_ == STATE_SECONDARY_LOGIN_SCREEN) 943 if (ui_session_ == STATE_SECONDARY_LOGIN_SCREEN)
943 SetUISessionState(STATE_BROWSER_SCREEN); 944 SetUISessionState(STATE_BROWSER_SCREEN);
944 } 945 }
945 946
946 scoped_ptr<InputMethodDescriptors> 947 std::unique_ptr<InputMethodDescriptors>
947 InputMethodManagerImpl::GetSupportedInputMethods() const { 948 InputMethodManagerImpl::GetSupportedInputMethods() const {
948 return scoped_ptr<InputMethodDescriptors>(new InputMethodDescriptors); 949 return std::unique_ptr<InputMethodDescriptors>(new InputMethodDescriptors);
949 } 950 }
950 951
951 const InputMethodDescriptor* InputMethodManagerImpl::LookupInputMethod( 952 const InputMethodDescriptor* InputMethodManagerImpl::LookupInputMethod(
952 const std::string& input_method_id, 953 const std::string& input_method_id,
953 InputMethodManagerImpl::StateImpl* state) { 954 InputMethodManagerImpl::StateImpl* state) {
954 DCHECK(state); 955 DCHECK(state);
955 956
956 std::string input_method_id_to_switch = input_method_id; 957 std::string input_method_id_to_switch = input_method_id;
957 958
958 // Sanity check 959 // Sanity check
959 if (!state->InputMethodIsActivated(input_method_id)) { 960 if (!state->InputMethodIsActivated(input_method_id)) {
960 scoped_ptr<InputMethodDescriptors> input_methods( 961 std::unique_ptr<InputMethodDescriptors> input_methods(
961 state->GetActiveInputMethods()); 962 state->GetActiveInputMethods());
962 DCHECK(!input_methods->empty()); 963 DCHECK(!input_methods->empty());
963 input_method_id_to_switch = input_methods->at(0).id(); 964 input_method_id_to_switch = input_methods->at(0).id();
964 if (!input_method_id.empty()) { 965 if (!input_method_id.empty()) {
965 DVLOG(1) << "Can't change the current input method to " 966 DVLOG(1) << "Can't change the current input method to "
966 << input_method_id << " since the engine is not enabled. " 967 << input_method_id << " since the engine is not enabled. "
967 << "Switch to " << input_method_id_to_switch << " instead."; 968 << "Switch to " << input_method_id_to_switch << " instead.";
968 } 969 }
969 } 970 }
970 971
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 CandidateWindowController* candidate_window_controller) { 1147 CandidateWindowController* candidate_window_controller) {
1147 candidate_window_controller_.reset(candidate_window_controller); 1148 candidate_window_controller_.reset(candidate_window_controller);
1148 candidate_window_controller_->AddObserver(this); 1149 candidate_window_controller_->AddObserver(this);
1149 } 1150 }
1150 1151
1151 void InputMethodManagerImpl::SetImeKeyboardForTesting(ImeKeyboard* keyboard) { 1152 void InputMethodManagerImpl::SetImeKeyboardForTesting(ImeKeyboard* keyboard) {
1152 keyboard_.reset(keyboard); 1153 keyboard_.reset(keyboard);
1153 } 1154 }
1154 1155
1155 void InputMethodManagerImpl::InitializeComponentExtensionForTesting( 1156 void InputMethodManagerImpl::InitializeComponentExtensionForTesting(
1156 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate) { 1157 std::unique_ptr<ComponentExtensionIMEManagerDelegate> delegate) {
1157 component_extension_ime_manager_->Initialize(std::move(delegate)); 1158 component_extension_ime_manager_->Initialize(std::move(delegate));
1158 util_.ResetInputMethods( 1159 util_.ResetInputMethods(
1159 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor()); 1160 component_extension_ime_manager_->GetAllIMEAsInputMethodDescriptor());
1160 } 1161 }
1161 1162
1162 void InputMethodManagerImpl::CandidateClicked(int index) { 1163 void InputMethodManagerImpl::CandidateClicked(int index) {
1163 ui::IMEEngineHandlerInterface* engine = 1164 ui::IMEEngineHandlerInterface* engine =
1164 ui::IMEBridge::Get()->GetCurrentEngineHandler(); 1165 ui::IMEBridge::Get()->GetCurrentEngineHandler();
1165 if (engine) 1166 if (engine)
1166 engine->CandidateClicked(index); 1167 engine->CandidateClicked(index);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 1203
1203 void InputMethodManagerImpl::NotifyImeMenuItemsChanged( 1204 void InputMethodManagerImpl::NotifyImeMenuItemsChanged(
1204 const std::string& engine_id, 1205 const std::string& engine_id,
1205 const std::vector<InputMethodManager::MenuItem>& items) { 1206 const std::vector<InputMethodManager::MenuItem>& items) {
1206 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, 1207 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_,
1207 ImeMenuItemsChanged(engine_id, items)); 1208 ImeMenuItemsChanged(engine_id, items));
1208 } 1209 }
1209 1210
1210 } // namespace input_method 1211 } // namespace input_method
1211 } // namespace chromeos 1212 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698