| Index: ui/chromeos/ime/candidate_window_view.cc
|
| diff --git a/ui/chromeos/ime/candidate_window_view.cc b/ui/chromeos/ime/candidate_window_view.cc
|
| index dcfd35893f39218af53bce378c8ecccd5dba4483..7182c361c2791c1a37d076c1557f3b8c2433827c 100644
|
| --- a/ui/chromeos/ime/candidate_window_view.cc
|
| +++ b/ui/chromeos/ime/candidate_window_view.cc
|
| @@ -9,6 +9,7 @@
|
| #include <string>
|
|
|
| #include "base/macros.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "ui/chromeos/ime/candidate_view.h"
|
| #include "ui/chromeos/ime/candidate_window_constants.h"
|
| @@ -280,7 +281,7 @@ void CandidateWindowView::UpdateCandidates(
|
| for (size_t i = 0; i < candidate_views_.size(); ++i) {
|
| const size_t index_in_page = i;
|
| const size_t candidate_index = start_from + index_in_page;
|
| - CandidateView* candidate_view = candidate_views_[index_in_page];
|
| + CandidateView* candidate_view = candidate_views_[index_in_page].get();
|
| // Set the candidate text.
|
| if (candidate_index < new_candidate_window.candidates().size()) {
|
| const ui::CandidateWindow::Entry& entry =
|
| @@ -304,8 +305,8 @@ void CandidateWindowView::UpdateCandidates(
|
| }
|
| }
|
| if (new_candidate_window.orientation() == ui::CandidateWindow::VERTICAL) {
|
| - for (size_t i = 0; i < candidate_views_.size(); ++i)
|
| - candidate_views_[i]->SetWidths(max_shortcut_width, max_candidate_width);
|
| + for (const auto& view : candidate_views_)
|
| + view->SetWidths(max_shortcut_width, max_candidate_width);
|
| }
|
|
|
| CandidateWindowBorder* border = static_cast<CandidateWindowBorder*>(
|
| @@ -359,16 +360,16 @@ void CandidateWindowView::MaybeInitializeCandidateViews(
|
|
|
| // Reset all candidate_views_ when orientation changes.
|
| if (orientation != candidate_window_.orientation())
|
| - base::STLDeleteElements(&candidate_views_);
|
| + candidate_views_.clear();
|
|
|
| - while (page_size < candidate_views_.size()) {
|
| - delete candidate_views_.back();
|
| + while (page_size < candidate_views_.size())
|
| candidate_views_.pop_back();
|
| - }
|
| +
|
| while (page_size > candidate_views_.size()) {
|
| - CandidateView* new_candidate = new CandidateView(this, orientation);
|
| - candidate_area_->AddChildView(new_candidate);
|
| - candidate_views_.push_back(new_candidate);
|
| + std::unique_ptr<CandidateView> new_candidate =
|
| + base::MakeUnique<CandidateView>(this, orientation);
|
| + candidate_area_->AddChildView(new_candidate.get());
|
| + candidate_views_.push_back(std::move(new_candidate));
|
| }
|
| }
|
|
|
| @@ -408,7 +409,7 @@ int CandidateWindowView::GetDialogButtons() const {
|
| void CandidateWindowView::ButtonPressed(views::Button* sender,
|
| const ui::Event& event) {
|
| for (size_t i = 0; i < candidate_views_.size(); ++i) {
|
| - if (sender == candidate_views_[i]) {
|
| + if (sender == candidate_views_[i].get()) {
|
| for (Observer& observer : observers_)
|
| observer.OnCandidateCommitted(i);
|
| return;
|
|
|