| OLD | NEW |
| 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/candidate_window_controller_impl.
h" | 5 #include "chrome/browser/chromeos/input_method/candidate_window_controller_impl.
h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 candidate_window_view_ = | 48 candidate_window_view_ = |
| 49 new ui::ime::CandidateWindowView(ash::Shell::GetContainer( | 49 new ui::ime::CandidateWindowView(ash::Shell::GetContainer( |
| 50 active_window ? active_window->GetRootWindow() | 50 active_window ? active_window->GetRootWindow() |
| 51 : ash::Shell::GetTargetRootWindow(), | 51 : ash::Shell::GetTargetRootWindow(), |
| 52 ash::kShellWindowId_SettingBubbleContainer)); | 52 ash::kShellWindowId_SettingBubbleContainer)); |
| 53 candidate_window_view_->AddObserver(this); | 53 candidate_window_view_->AddObserver(this); |
| 54 candidate_window_view_->SetCursorBounds(cursor_bounds_, composition_head_); | 54 candidate_window_view_->SetCursorBounds(cursor_bounds_, composition_head_); |
| 55 views::Widget* widget = candidate_window_view_->InitWidget(); | 55 views::Widget* widget = candidate_window_view_->InitWidget(); |
| 56 widget->AddObserver(this); | 56 widget->AddObserver(this); |
| 57 widget->Show(); | 57 widget->Show(); |
| 58 FOR_EACH_OBSERVER(CandidateWindowController::Observer, observers_, | 58 for (auto& observer : observers_) |
| 59 CandidateWindowOpened()); | 59 observer.CandidateWindowOpened(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void CandidateWindowControllerImpl::Hide() { | 62 void CandidateWindowControllerImpl::Hide() { |
| 63 if (candidate_window_view_) | 63 if (candidate_window_view_) |
| 64 candidate_window_view_->GetWidget()->Close(); | 64 candidate_window_view_->GetWidget()->Close(); |
| 65 if (infolist_window_) | 65 if (infolist_window_) |
| 66 infolist_window_->HideImmediately(); | 66 infolist_window_->HideImmediately(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void CandidateWindowControllerImpl::SetCursorBounds( | 69 void CandidateWindowControllerImpl::SetCursorBounds( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 candidate_window_view_->HidePreeditText(); | 161 candidate_window_view_->HidePreeditText(); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 if (!candidate_window_view_) | 164 if (!candidate_window_view_) |
| 165 InitCandidateWindowView(); | 165 InitCandidateWindowView(); |
| 166 candidate_window_view_->UpdatePreeditText(text); | 166 candidate_window_view_->UpdatePreeditText(text); |
| 167 candidate_window_view_->ShowPreeditText(); | 167 candidate_window_view_->ShowPreeditText(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void CandidateWindowControllerImpl::OnCandidateCommitted(int index) { | 170 void CandidateWindowControllerImpl::OnCandidateCommitted(int index) { |
| 171 FOR_EACH_OBSERVER(CandidateWindowController::Observer, observers_, | 171 for (auto& observer : observers_) |
| 172 CandidateClicked(index)); | 172 observer.CandidateClicked(index); |
| 173 } | 173 } |
| 174 | 174 |
| 175 void CandidateWindowControllerImpl::OnWidgetClosing(views::Widget* widget) { | 175 void CandidateWindowControllerImpl::OnWidgetClosing(views::Widget* widget) { |
| 176 if (infolist_window_ && widget == infolist_window_->GetWidget()) { | 176 if (infolist_window_ && widget == infolist_window_->GetWidget()) { |
| 177 widget->RemoveObserver(this); | 177 widget->RemoveObserver(this); |
| 178 infolist_window_ = NULL; | 178 infolist_window_ = NULL; |
| 179 } else if (candidate_window_view_ && | 179 } else if (candidate_window_view_ && |
| 180 widget == candidate_window_view_->GetWidget()) { | 180 widget == candidate_window_view_->GetWidget()) { |
| 181 widget->RemoveObserver(this); | 181 widget->RemoveObserver(this); |
| 182 candidate_window_view_->RemoveObserver(this); | 182 candidate_window_view_->RemoveObserver(this); |
| 183 candidate_window_view_ = NULL; | 183 candidate_window_view_ = NULL; |
| 184 FOR_EACH_OBSERVER(CandidateWindowController::Observer, observers_, | 184 for (auto& observer : observers_) |
| 185 CandidateWindowClosed()); | 185 observer.CandidateWindowClosed(); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 void CandidateWindowControllerImpl::AddObserver( | 189 void CandidateWindowControllerImpl::AddObserver( |
| 190 CandidateWindowController::Observer* observer) { | 190 CandidateWindowController::Observer* observer) { |
| 191 observers_.AddObserver(observer); | 191 observers_.AddObserver(observer); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void CandidateWindowControllerImpl::RemoveObserver( | 194 void CandidateWindowControllerImpl::RemoveObserver( |
| 195 CandidateWindowController::Observer* observer) { | 195 CandidateWindowController::Observer* observer) { |
| 196 observers_.RemoveObserver(observer); | 196 observers_.RemoveObserver(observer); |
| 197 } | 197 } |
| 198 | 198 |
| 199 } // namespace input_method | 199 } // namespace input_method |
| 200 } // namespace chromeos | 200 } // namespace chromeos |
| OLD | NEW |