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

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

Issue 2651733002: IME for Mus: Avoid crash in InitWindowCandidateView(). (Closed)
Patch Set: addressed feedback. Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/wm/window_util.h" 12 #include "ash/wm/window_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h" 14 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h"
15 #include "chrome/browser/ui/ash/ash_util.h"
15 #include "ui/base/ime/ime_bridge.h" 16 #include "ui/base/ime/ime_bridge.h"
16 #include "ui/chromeos/ime/infolist_window.h" 17 #include "ui/chromeos/ime/infolist_window.h"
17 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
18 19
19 namespace chromeos { 20 namespace chromeos {
20 namespace input_method { 21 namespace input_method {
21 22
22 namespace { 23 namespace {
23 24
24 } // namespace 25 } // namespace
(...skipping 12 matching lines...) Expand all
37 if (candidate_window_view_) { 38 if (candidate_window_view_) {
38 candidate_window_view_->RemoveObserver(this); 39 candidate_window_view_->RemoveObserver(this);
39 candidate_window_view_->GetWidget()->RemoveObserver(this); 40 candidate_window_view_->GetWidget()->RemoveObserver(this);
40 } 41 }
41 } 42 }
42 43
43 void CandidateWindowControllerImpl::InitCandidateWindowView() { 44 void CandidateWindowControllerImpl::InitCandidateWindowView() {
44 if (candidate_window_view_) 45 if (candidate_window_view_)
45 return; 46 return;
46 47
47 aura::Window* active_window = ash::wm::GetActiveWindow(); 48 // TODO(moshayedi): crbug.com/684658. Setting parent is nullptr in mash is
48 candidate_window_view_ = 49 // just for the sake of not crashing. It doesn't provide the same behaviour
49 new ui::ime::CandidateWindowView(ash::Shell::GetContainer( 50 // as we have in ChromeOS. For example, candidate pop-up disappears when
50 active_window ? active_window->GetRootWindow() 51 // dragging the window in mash, but it shouldn't.
51 : ash::Shell::GetTargetRootWindow(), 52 gfx::NativeView parent = nullptr;
52 ash::kShellWindowId_SettingBubbleContainer)); 53 if (!chrome::IsRunningInMash()) {
54 aura::Window* active_window = ash::wm::GetActiveWindow();
55 parent = ash::Shell::GetContainer(
56 active_window ? active_window->GetRootWindow()
57 : ash::Shell::GetTargetRootWindow(),
58 ash::kShellWindowId_SettingBubbleContainer);
59 }
60 candidate_window_view_ = new ui::ime::CandidateWindowView(parent);
53 candidate_window_view_->AddObserver(this); 61 candidate_window_view_->AddObserver(this);
54 candidate_window_view_->SetCursorBounds(cursor_bounds_, composition_head_); 62 candidate_window_view_->SetCursorBounds(cursor_bounds_, composition_head_);
55 views::Widget* widget = candidate_window_view_->InitWidget(); 63 views::Widget* widget = candidate_window_view_->InitWidget();
56 widget->AddObserver(this); 64 widget->AddObserver(this);
57 widget->Show(); 65 widget->Show();
58 for (auto& observer : observers_) 66 for (auto& observer : observers_)
59 observer.CandidateWindowOpened(); 67 observer.CandidateWindowOpened();
60 } 68 }
61 69
62 void CandidateWindowControllerImpl::Hide() { 70 void CandidateWindowControllerImpl::Hide() {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 observers_.AddObserver(observer); 199 observers_.AddObserver(observer);
192 } 200 }
193 201
194 void CandidateWindowControllerImpl::RemoveObserver( 202 void CandidateWindowControllerImpl::RemoveObserver(
195 CandidateWindowController::Observer* observer) { 203 CandidateWindowController::Observer* observer) {
196 observers_.RemoveObserver(observer); 204 observers_.RemoveObserver(observer);
197 } 205 }
198 206
199 } // namespace input_method 207 } // namespace input_method
200 } // namespace chromeos 208 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698