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

Side by Side Diff: chrome/browser/extensions/api/input_ime/input_ime_api_nonchromeos.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This file is for non-chromeos (win & linux) functions, such as 5 // This file is for non-chromeos (win & linux) functions, such as
6 // chrome.input.ime.activate, chrome.input.ime.createWindow and 6 // chrome.input.ime.activate, chrome.input.ime.createWindow and
7 // chrome.input.ime.onSelectionChanged. 7 // chrome.input.ime.onSelectionChanged.
8 // TODO(azurewei): May refactor the code structure by using delegate or 8 // TODO(azurewei): May refactor the code structure by using delegate or
9 // redesign the API to remove this platform-specific file in the future. 9 // redesign the API to remove this platform-specific file in the future.
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 std::vector<input_ime::Bounds> bounds_list; 71 std::vector<input_ime::Bounds> bounds_list;
72 for (const auto& bound : bounds) { 72 for (const auto& bound : bounds) {
73 input_ime::Bounds bounds_value; 73 input_ime::Bounds bounds_value;
74 bounds_value.left = bound.x(); 74 bounds_value.left = bound.x();
75 bounds_value.top = bound.y(); 75 bounds_value.top = bound.y();
76 bounds_value.width = bound.width(); 76 bounds_value.width = bound.width();
77 bounds_value.height = bound.height(); 77 bounds_value.height = bound.height();
78 bounds_list.push_back(std::move(bounds_value)); 78 bounds_list.push_back(std::move(bounds_value));
79 } 79 }
80 80
81 scoped_ptr<base::ListValue> args( 81 std::unique_ptr<base::ListValue> args(
82 OnCompositionBoundsChanged::Create(bounds_list)); 82 OnCompositionBoundsChanged::Create(bounds_list));
83 83
84 DispatchEventToExtension( 84 DispatchEventToExtension(
85 extensions::events::INPUT_IME_ON_COMPOSITION_BOUNDS_CHANGED, 85 extensions::events::INPUT_IME_ON_COMPOSITION_BOUNDS_CHANGED,
86 OnCompositionBoundsChanged::kEventName, std::move(args)); 86 OnCompositionBoundsChanged::kEventName, std::move(args));
87 } 87 }
88 88
89 private: 89 private:
90 // ImeObserver overrides. 90 // ImeObserver overrides.
91 void DispatchEventToExtension( 91 void DispatchEventToExtension(
92 extensions::events::HistogramValue histogram_value, 92 extensions::events::HistogramValue histogram_value,
93 const std::string& event_name, 93 const std::string& event_name,
94 scoped_ptr<base::ListValue> args) override { 94 std::unique_ptr<base::ListValue> args) override {
95 if (!IsInputImeEnabled()) { 95 if (!IsInputImeEnabled()) {
96 return; 96 return;
97 } 97 }
98 98
99 scoped_ptr<extensions::Event> event( 99 std::unique_ptr<extensions::Event> event(
100 new extensions::Event(histogram_value, event_name, std::move(args))); 100 new extensions::Event(histogram_value, event_name, std::move(args)));
101 event->restrict_to_browser_context = profile_; 101 event->restrict_to_browser_context = profile_;
102 extensions::EventRouter::Get(profile_) 102 extensions::EventRouter::Get(profile_)
103 ->DispatchEventToExtension(extension_id_, std::move(event)); 103 ->DispatchEventToExtension(extension_id_, std::move(event));
104 } 104 }
105 105
106 std::string GetCurrentScreenType() override { return "normal"; } 106 std::string GetCurrentScreenType() override { return "normal"; }
107 107
108 DISALLOW_COPY_AND_ASSIGN(ImeObserverNonChromeOS); 108 DISALLOW_COPY_AND_ASSIGN(ImeObserverNonChromeOS);
109 }; 109 };
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 void InputImeEventRouter::SetActiveEngine(const std::string& extension_id) { 164 void InputImeEventRouter::SetActiveEngine(const std::string& extension_id) {
165 if (active_engine_) { 165 if (active_engine_) {
166 if (active_engine_->GetExtensionId() == extension_id) { 166 if (active_engine_->GetExtensionId() == extension_id) {
167 active_engine_->Enable(std::string()); 167 active_engine_->Enable(std::string());
168 ui::IMEBridge::Get()->SetCurrentEngineHandler(active_engine_); 168 ui::IMEBridge::Get()->SetCurrentEngineHandler(active_engine_);
169 return; 169 return;
170 } 170 }
171 DeleteInputMethodEngine(active_engine_->GetExtensionId()); 171 DeleteInputMethodEngine(active_engine_->GetExtensionId());
172 } 172 }
173 173
174 scoped_ptr<input_method::InputMethodEngine> engine( 174 std::unique_ptr<input_method::InputMethodEngine> engine(
175 new input_method::InputMethodEngine()); 175 new input_method::InputMethodEngine());
176 scoped_ptr<InputMethodEngineBase::Observer> observer( 176 std::unique_ptr<InputMethodEngineBase::Observer> observer(
177 new ImeObserverNonChromeOS(extension_id, GetProfile())); 177 new ImeObserverNonChromeOS(extension_id, GetProfile()));
178 engine->Initialize(std::move(observer), extension_id.c_str(), GetProfile()); 178 engine->Initialize(std::move(observer), extension_id.c_str(), GetProfile());
179 engine->Enable(std::string()); 179 engine->Enable(std::string());
180 active_engine_ = engine.release(); 180 active_engine_ = engine.release();
181 ui::IMEBridge::Get()->SetCurrentEngineHandler(active_engine_); 181 ui::IMEBridge::Get()->SetCurrentEngineHandler(active_engine_);
182 } 182 }
183 183
184 void InputImeEventRouter::DeleteInputMethodEngine( 184 void InputImeEventRouter::DeleteInputMethodEngine(
185 const std::string& extension_id) { 185 const std::string& extension_id) {
186 if (active_engine_ && active_engine_->GetExtensionId() == extension_id) { 186 if (active_engine_ && active_engine_->GetExtensionId() == extension_id) {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 int frame_id = engine->CreateImeWindow( 332 int frame_id = engine->CreateImeWindow(
333 extension(), render_frame_host(), 333 extension(), render_frame_host(),
334 options.url.get() ? *options.url : url::kAboutBlankURL, 334 options.url.get() ? *options.url : url::kAboutBlankURL,
335 options.window_type == input_ime::WINDOW_TYPE_FOLLOWCURSOR 335 options.window_type == input_ime::WINDOW_TYPE_FOLLOWCURSOR
336 ? ui::ImeWindow::FOLLOW_CURSOR 336 ? ui::ImeWindow::FOLLOW_CURSOR
337 : ui::ImeWindow::NORMAL, 337 : ui::ImeWindow::NORMAL,
338 bounds, &error_); 338 bounds, &error_);
339 if (!frame_id) 339 if (!frame_id)
340 return RespondNow(Error(error_)); 340 return RespondNow(Error(error_));
341 341
342 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 342 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
343 result->Set("frameId", new base::FundamentalValue(frame_id)); 343 result->Set("frameId", new base::FundamentalValue(frame_id));
344 344
345 return RespondNow(OneArgument(std::move(result))); 345 return RespondNow(OneArgument(std::move(result)));
346 } 346 }
347 347
348 ExtensionFunction::ResponseAction InputImeShowWindowFunction::Run() { 348 ExtensionFunction::ResponseAction InputImeShowWindowFunction::Run() {
349 if (!IsInputImeEnabled()) 349 if (!IsInputImeEnabled())
350 return RespondNow(Error(kErrorAPIDisabled)); 350 return RespondNow(Error(kErrorAPIDisabled));
351 351
352 InputMethodEngine* engine = 352 InputMethodEngine* engine =
353 GetActiveEngine(browser_context(), extension_id()); 353 GetActiveEngine(browser_context(), extension_id());
354 if (!engine) 354 if (!engine)
355 return RespondNow(Error(kErrorNoActiveEngine)); 355 return RespondNow(Error(kErrorNoActiveEngine));
356 356
357 scoped_ptr<api::input_ime::ShowWindow::Params> params( 357 std::unique_ptr<api::input_ime::ShowWindow::Params> params(
358 api::input_ime::ShowWindow::Params::Create(*args_)); 358 api::input_ime::ShowWindow::Params::Create(*args_));
359 EXTENSION_FUNCTION_VALIDATE(params.get()); 359 EXTENSION_FUNCTION_VALIDATE(params.get());
360 engine->ShowImeWindow(params->window_id); 360 engine->ShowImeWindow(params->window_id);
361 return RespondNow(NoArguments()); 361 return RespondNow(NoArguments());
362 } 362 }
363 363
364 ExtensionFunction::ResponseAction InputImeHideWindowFunction::Run() { 364 ExtensionFunction::ResponseAction InputImeHideWindowFunction::Run() {
365 if (!IsInputImeEnabled()) 365 if (!IsInputImeEnabled())
366 return RespondNow(Error(kErrorAPIDisabled)); 366 return RespondNow(Error(kErrorAPIDisabled));
367 367
368 InputMethodEngine* engine = 368 InputMethodEngine* engine =
369 GetActiveEngine(browser_context(), extension_id()); 369 GetActiveEngine(browser_context(), extension_id());
370 if (!engine) 370 if (!engine)
371 return RespondNow(Error(kErrorNoActiveEngine)); 371 return RespondNow(Error(kErrorNoActiveEngine));
372 372
373 scoped_ptr<api::input_ime::HideWindow::Params> params( 373 std::unique_ptr<api::input_ime::HideWindow::Params> params(
374 api::input_ime::HideWindow::Params::Create(*args_)); 374 api::input_ime::HideWindow::Params::Create(*args_));
375 EXTENSION_FUNCTION_VALIDATE(params.get()); 375 EXTENSION_FUNCTION_VALIDATE(params.get());
376 engine->HideImeWindow(params->window_id); 376 engine->HideImeWindow(params->window_id);
377 return RespondNow(NoArguments()); 377 return RespondNow(NoArguments());
378 } 378 }
379 379
380 } // namespace extensions 380 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698