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

Side by Side Diff: extensions/shell/browser/shell_desktop_controller_aura.cc

Issue 2872343003: Remove InputMethodEventHandler. (Closed)
Patch Set: addressed feedback. Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/shell/browser/shell_desktop_controller_aura.h" 5 #include "extensions/shell/browser/shell_desktop_controller_aura.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "extensions/browser/app_window/app_window.h" 19 #include "extensions/browser/app_window/app_window.h"
20 #include "extensions/browser/app_window/native_app_window.h" 20 #include "extensions/browser/app_window/native_app_window.h"
21 #include "extensions/shell/browser/input_method_event_handler.h"
22 #include "extensions/shell/browser/shell_app_delegate.h" 21 #include "extensions/shell/browser/shell_app_delegate.h"
23 #include "extensions/shell/browser/shell_app_window_client.h" 22 #include "extensions/shell/browser/shell_app_window_client.h"
24 #include "extensions/shell/browser/shell_screen.h" 23 #include "extensions/shell/browser/shell_screen.h"
25 #include "extensions/shell/common/switches.h" 24 #include "extensions/shell/common/switches.h"
26 #include "ui/aura/client/cursor_client.h" 25 #include "ui/aura/client/cursor_client.h"
27 #include "ui/aura/client/default_capture_client.h" 26 #include "ui/aura/client/default_capture_client.h"
28 #include "ui/aura/layout_manager.h" 27 #include "ui/aura/layout_manager.h"
29 #include "ui/aura/window.h" 28 #include "ui/aura/window.h"
30 #include "ui/aura/window_tree_host.h" 29 #include "ui/aura/window_tree_host.h"
31 #include "ui/base/cursor/cursor.h" 30 #include "ui/base/cursor/cursor.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 void ShellDesktopControllerAura::OnHostCloseRequested( 267 void ShellDesktopControllerAura::OnHostCloseRequested(
269 const aura::WindowTreeHost* host) { 268 const aura::WindowTreeHost* host) {
270 DCHECK_EQ(host_.get(), host); 269 DCHECK_EQ(host_.get(), host);
271 CloseAppWindows(); 270 CloseAppWindows();
272 base::ThreadTaskRunnerHandle::Get()->PostTask( 271 base::ThreadTaskRunnerHandle::Get()->PostTask(
273 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 272 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
274 } 273 }
275 274
276 ui::EventDispatchDetails ShellDesktopControllerAura::DispatchKeyEventPostIME( 275 ui::EventDispatchDetails ShellDesktopControllerAura::DispatchKeyEventPostIME(
277 ui::KeyEvent* key_event) { 276 ui::KeyEvent* key_event) {
278 // The input method has processed this event, so prevent the handler from 277 return host_->DispatchKeyEventPostIME(key_event);
279 // dispatching it again.
280 input_method_event_handler_->set_post_ime(true);
281
282 // Send the event on to the host.
283 ui::EventDispatchDetails details =
284 host_->event_sink()->OnEventFromSource(key_event);
285
286 // Clear the handler's PostIME flag for the next event.
287 if (!details.dispatcher_destroyed)
288 input_method_event_handler_->set_post_ime(false);
289
290 return details;
291 } 278 }
292 279
293 void ShellDesktopControllerAura::InitWindowManager() { 280 void ShellDesktopControllerAura::InitWindowManager() {
294 wm::FocusController* focus_controller = 281 wm::FocusController* focus_controller =
295 new wm::FocusController(new AppsFocusRules()); 282 new wm::FocusController(new AppsFocusRules());
296 aura::client::SetFocusClient(host_->window(), focus_controller); 283 aura::client::SetFocusClient(host_->window(), focus_controller);
297 host_->window()->AddPreTargetHandler(focus_controller); 284 host_->window()->AddPreTargetHandler(focus_controller);
298 aura::client::SetActivationClient(host_->window(), focus_controller); 285 aura::client::SetActivationClient(host_->window(), focus_controller);
299 focus_client_.reset(focus_controller); 286 focus_client_.reset(focus_controller);
300 287
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 display::Screen::SetScreenInstance(screen_.get()); 326 display::Screen::SetScreenInstance(screen_.get());
340 327
341 host_.reset(screen_->CreateHostForPrimaryDisplay()); 328 host_.reset(screen_->CreateHostForPrimaryDisplay());
342 aura::client::SetWindowParentingClient(host_->window(), this); 329 aura::client::SetWindowParentingClient(host_->window(), this);
343 root_window_event_filter_.reset(new wm::CompoundEventFilter); 330 root_window_event_filter_.reset(new wm::CompoundEventFilter);
344 host_->window()->AddPreTargetHandler(root_window_event_filter_.get()); 331 host_->window()->AddPreTargetHandler(root_window_event_filter_.get());
345 332
346 // Trigger creation of an input method and become its delegate. 333 // Trigger creation of an input method and become its delegate.
347 ui::InputMethod* input_method = host_->GetInputMethod(); 334 ui::InputMethod* input_method = host_->GetInputMethod();
348 input_method->SetDelegate(this); 335 input_method->SetDelegate(this);
349 input_method_event_handler_.reset(new InputMethodEventHandler(input_method));
350 host_->window()->AddPreTargetHandler(input_method_event_handler_.get());
351 336
352 InitWindowManager(); 337 InitWindowManager();
353 338
354 host_->AddObserver(this); 339 host_->AddObserver(this);
355 340
356 // Ensure the X window gets mapped. 341 // Ensure the X window gets mapped.
357 host_->Show(); 342 host_->Show();
358 } 343 }
359 344
360 void ShellDesktopControllerAura::DestroyRootWindow() { 345 void ShellDesktopControllerAura::DestroyRootWindow() {
361 host_->RemoveObserver(this); 346 host_->RemoveObserver(this);
362 wm::FocusController* focus_controller = 347 wm::FocusController* focus_controller =
363 static_cast<wm::FocusController*>(focus_client_.get()); 348 static_cast<wm::FocusController*>(focus_client_.get());
364 if (focus_controller) { 349 if (focus_controller) {
365 host_->window()->RemovePreTargetHandler(focus_controller); 350 host_->window()->RemovePreTargetHandler(focus_controller);
366 aura::client::SetActivationClient(host_->window(), NULL); 351 aura::client::SetActivationClient(host_->window(), NULL);
367 } 352 }
368 353
369 host_->window()->RemovePreTargetHandler(input_method_event_handler_.get());
370 input_method_event_handler_.reset();
371
372 host_->window()->RemovePreTargetHandler(root_window_event_filter_.get()); 354 host_->window()->RemovePreTargetHandler(root_window_event_filter_.get());
373 root_window_event_filter_.reset(); 355 root_window_event_filter_.reset();
374 356
375 capture_client_.reset(); 357 capture_client_.reset();
376 focus_client_.reset(); 358 focus_client_.reset();
377 cursor_manager_.reset(); 359 cursor_manager_.reset();
378 #if defined(OS_CHROMEOS) 360 #if defined(OS_CHROMEOS)
379 user_activity_notifier_.reset(); 361 user_activity_notifier_.reset();
380 #endif 362 #endif
381 user_activity_detector_.reset(); 363 user_activity_detector_.reset();
382 host_.reset(); 364 host_.reset();
383 display::Screen::SetScreenInstance(nullptr); 365 display::Screen::SetScreenInstance(nullptr);
384 screen_.reset(); 366 screen_.reset();
385 } 367 }
386 368
387 gfx::Size ShellDesktopControllerAura::GetPrimaryDisplaySize() { 369 gfx::Size ShellDesktopControllerAura::GetPrimaryDisplaySize() {
388 #if defined(OS_CHROMEOS) 370 #if defined(OS_CHROMEOS)
389 const display::DisplayConfigurator::DisplayStateList& displays = 371 const display::DisplayConfigurator::DisplayStateList& displays =
390 display_configurator_->cached_displays(); 372 display_configurator_->cached_displays();
391 if (displays.empty()) 373 if (displays.empty())
392 return gfx::Size(); 374 return gfx::Size();
393 const display::DisplayMode* mode = displays[0]->current_mode(); 375 const display::DisplayMode* mode = displays[0]->current_mode();
394 return mode ? mode->size() : gfx::Size(); 376 return mode ? mode->size() : gfx::Size();
395 #else 377 #else
396 return gfx::Size(); 378 return gfx::Size();
397 #endif 379 #endif
398 } 380 }
399 381
400 } // namespace extensions 382 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/shell/browser/shell_desktop_controller_aura.h ('k') | ui/aura/test/aura_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698