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

Side by Side Diff: chrome/browser/chromeos/extensions/input_method_api.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: iwyu fixes 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/extensions/input_method_api.h" 5 #include "chrome/browser/chromeos/extensions/input_method_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 return RespondNow(OneArgument(new base::StringValue( 95 return RespondNow(OneArgument(new base::StringValue(
96 manager->GetActiveIMEState()->GetCurrentInputMethod().id()))); 96 manager->GetActiveIMEState()->GetCurrentInputMethod().id())));
97 #endif 97 #endif
98 } 98 }
99 99
100 ExtensionFunction::ResponseAction 100 ExtensionFunction::ResponseAction
101 InputMethodPrivateSetCurrentInputMethodFunction::Run() { 101 InputMethodPrivateSetCurrentInputMethodFunction::Run() {
102 #if !defined(OS_CHROMEOS) 102 #if !defined(OS_CHROMEOS)
103 EXTENSION_FUNCTION_VALIDATE(false); 103 EXTENSION_FUNCTION_VALIDATE(false);
104 #else 104 #else
105 scoped_ptr<SetCurrentInputMethod::Params> params( 105 std::unique_ptr<SetCurrentInputMethod::Params> params(
106 SetCurrentInputMethod::Params::Create(*args_)); 106 SetCurrentInputMethod::Params::Create(*args_));
107 EXTENSION_FUNCTION_VALIDATE(params.get()); 107 EXTENSION_FUNCTION_VALIDATE(params.get());
108 scoped_refptr<chromeos::input_method::InputMethodManager::State> ime_state = 108 scoped_refptr<chromeos::input_method::InputMethodManager::State> ime_state =
109 chromeos::input_method::InputMethodManager::Get()->GetActiveIMEState(); 109 chromeos::input_method::InputMethodManager::Get()->GetActiveIMEState();
110 const std::vector<std::string>& input_methods = 110 const std::vector<std::string>& input_methods =
111 ime_state->GetActiveInputMethodIds(); 111 ime_state->GetActiveInputMethodIds();
112 for (size_t i = 0; i < input_methods.size(); ++i) { 112 for (size_t i = 0; i < input_methods.size(); ++i) {
113 const std::string& input_method = input_methods[i]; 113 const std::string& input_method = input_methods[i];
114 if (input_method == params->input_method_id) { 114 if (input_method == params->input_method_id) {
115 ime_state->ChangeInputMethod(params->input_method_id, 115 ime_state->ChangeInputMethod(params->input_method_id,
116 false /* show_message */); 116 false /* show_message */);
117 return RespondNow(NoArguments()); 117 return RespondNow(NoArguments());
118 } 118 }
119 } 119 }
120 return RespondNow(Error("Invalid input method id.")); 120 return RespondNow(Error("Invalid input method id."));
121 #endif 121 #endif
122 } 122 }
123 123
124 ExtensionFunction::ResponseAction 124 ExtensionFunction::ResponseAction
125 InputMethodPrivateGetInputMethodsFunction::Run() { 125 InputMethodPrivateGetInputMethodsFunction::Run() {
126 #if !defined(OS_CHROMEOS) 126 #if !defined(OS_CHROMEOS)
127 EXTENSION_FUNCTION_VALIDATE(false); 127 EXTENSION_FUNCTION_VALIDATE(false);
128 #else 128 #else
129 base::ListValue* output = new base::ListValue(); 129 base::ListValue* output = new base::ListValue();
130 chromeos::input_method::InputMethodManager* manager = 130 chromeos::input_method::InputMethodManager* manager =
131 chromeos::input_method::InputMethodManager::Get(); 131 chromeos::input_method::InputMethodManager::Get();
132 chromeos::input_method::InputMethodUtil* util = manager->GetInputMethodUtil(); 132 chromeos::input_method::InputMethodUtil* util = manager->GetInputMethodUtil();
133 scoped_refptr<chromeos::input_method::InputMethodManager::State> ime_state = 133 scoped_refptr<chromeos::input_method::InputMethodManager::State> ime_state =
134 manager->GetActiveIMEState(); 134 manager->GetActiveIMEState();
135 scoped_ptr<chromeos::input_method::InputMethodDescriptors> input_methods = 135 std::unique_ptr<chromeos::input_method::InputMethodDescriptors>
136 ime_state->GetActiveInputMethods(); 136 input_methods = ime_state->GetActiveInputMethods();
137 for (size_t i = 0; i < input_methods->size(); ++i) { 137 for (size_t i = 0; i < input_methods->size(); ++i) {
138 const chromeos::input_method::InputMethodDescriptor& input_method = 138 const chromeos::input_method::InputMethodDescriptor& input_method =
139 (*input_methods)[i]; 139 (*input_methods)[i];
140 base::DictionaryValue* val = new base::DictionaryValue(); 140 base::DictionaryValue* val = new base::DictionaryValue();
141 val->SetString("id", input_method.id()); 141 val->SetString("id", input_method.id());
142 val->SetString("name", util->GetInputMethodLongName(input_method)); 142 val->SetString("name", util->GetInputMethodLongName(input_method));
143 val->SetString("indicator", util->GetInputMethodShortName(input_method)); 143 val->SetString("indicator", util->GetInputMethodShortName(input_method));
144 output->Append(val); 144 output->Append(val);
145 } 145 }
146 return RespondNow(OneArgument(output)); 146 return RespondNow(OneArgument(output));
(...skipping 22 matching lines...) Expand all
169 } 169 }
170 return RespondNow(OneArgument(output)); 170 return RespondNow(OneArgument(output));
171 #endif 171 #endif
172 } 172 }
173 173
174 ExtensionFunction::ResponseAction 174 ExtensionFunction::ResponseAction
175 InputMethodPrivateAddWordToDictionaryFunction::Run() { 175 InputMethodPrivateAddWordToDictionaryFunction::Run() {
176 #if !defined(OS_CHROMEOS) 176 #if !defined(OS_CHROMEOS)
177 EXTENSION_FUNCTION_VALIDATE(false); 177 EXTENSION_FUNCTION_VALIDATE(false);
178 #else 178 #else
179 scoped_ptr<AddWordToDictionary::Params> params( 179 std::unique_ptr<AddWordToDictionary::Params> params(
180 AddWordToDictionary::Params::Create(*args_)); 180 AddWordToDictionary::Params::Create(*args_));
181 EXTENSION_FUNCTION_VALIDATE(params.get()); 181 EXTENSION_FUNCTION_VALIDATE(params.get());
182 SpellcheckService* spellcheck = SpellcheckServiceFactory::GetForContext( 182 SpellcheckService* spellcheck = SpellcheckServiceFactory::GetForContext(
183 context_); 183 context_);
184 if (!spellcheck) { 184 if (!spellcheck) {
185 return RespondNow(Error("Spellcheck service not available.")); 185 return RespondNow(Error("Spellcheck service not available."));
186 } 186 }
187 SpellcheckCustomDictionary* dictionary = spellcheck->GetCustomDictionary(); 187 SpellcheckCustomDictionary* dictionary = spellcheck->GetCustomDictionary();
188 if (!dictionary->IsLoaded()) { 188 if (!dictionary->IsLoaded()) {
189 return RespondNow(Error("Custom dictionary not loaded yet.")); 189 return RespondNow(Error("Custom dictionary not loaded yet."));
(...skipping 14 matching lines...) Expand all
204 ExtensionFunction::ResponseAction 204 ExtensionFunction::ResponseAction
205 InputMethodPrivateGetEncryptSyncEnabledFunction::Run() { 205 InputMethodPrivateGetEncryptSyncEnabledFunction::Run() {
206 #if !defined(OS_CHROMEOS) 206 #if !defined(OS_CHROMEOS)
207 EXTENSION_FUNCTION_VALIDATE(false); 207 EXTENSION_FUNCTION_VALIDATE(false);
208 #else 208 #else
209 ProfileSyncService* profile_sync_service = 209 ProfileSyncService* profile_sync_service =
210 ProfileSyncServiceFactory::GetForProfile( 210 ProfileSyncServiceFactory::GetForProfile(
211 Profile::FromBrowserContext(browser_context())); 211 Profile::FromBrowserContext(browser_context()));
212 if (!profile_sync_service) 212 if (!profile_sync_service)
213 return RespondNow(Error("Sync service is not ready for current profile.")); 213 return RespondNow(Error("Sync service is not ready for current profile."));
214 scoped_ptr<base::Value> ret(new base::FundamentalValue( 214 std::unique_ptr<base::Value> ret(new base::FundamentalValue(
215 profile_sync_service->IsEncryptEverythingEnabled())); 215 profile_sync_service->IsEncryptEverythingEnabled()));
216 return RespondNow(OneArgument(std::move(ret))); 216 return RespondNow(OneArgument(std::move(ret)));
217 #endif 217 #endif
218 } 218 }
219 219
220 ExtensionFunction::ResponseAction 220 ExtensionFunction::ResponseAction
221 InputMethodPrivateSetXkbLayoutFunction::Run() { 221 InputMethodPrivateSetXkbLayoutFunction::Run() {
222 #if !defined(OS_CHROMEOS) 222 #if !defined(OS_CHROMEOS)
223 EXTENSION_FUNCTION_VALIDATE(false); 223 EXTENSION_FUNCTION_VALIDATE(false);
224 #else 224 #else
225 scoped_ptr<SetXkbLayout::Params> params(SetXkbLayout::Params::Create(*args_)); 225 std::unique_ptr<SetXkbLayout::Params> params(
226 SetXkbLayout::Params::Create(*args_));
226 EXTENSION_FUNCTION_VALIDATE(params.get()); 227 EXTENSION_FUNCTION_VALIDATE(params.get());
227 chromeos::input_method::InputMethodManager* manager = 228 chromeos::input_method::InputMethodManager* manager =
228 chromeos::input_method::InputMethodManager::Get(); 229 chromeos::input_method::InputMethodManager::Get();
229 chromeos::input_method::ImeKeyboard* keyboard = manager->GetImeKeyboard(); 230 chromeos::input_method::ImeKeyboard* keyboard = manager->GetImeKeyboard();
230 keyboard->SetCurrentKeyboardLayoutByName(params->xkb_name); 231 keyboard->SetCurrentKeyboardLayoutByName(params->xkb_name);
231 return RespondNow(NoArguments()); 232 return RespondNow(NoArguments());
232 #endif 233 #endif
233 } 234 }
234 235
235 ExtensionFunction::ResponseAction 236 ExtensionFunction::ResponseAction
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> > 333 static base::LazyInstance<BrowserContextKeyedAPIFactory<InputMethodAPI> >
333 g_factory = LAZY_INSTANCE_INITIALIZER; 334 g_factory = LAZY_INSTANCE_INITIALIZER;
334 335
335 // static 336 // static
336 BrowserContextKeyedAPIFactory<InputMethodAPI>* 337 BrowserContextKeyedAPIFactory<InputMethodAPI>*
337 InputMethodAPI::GetFactoryInstance() { 338 InputMethodAPI::GetFactoryInstance() {
338 return g_factory.Pointer(); 339 return g_factory.Pointer();
339 } 340 }
340 341
341 } // namespace extensions 342 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698