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

Side by Side Diff: components/arc/window_manager/arc_window_manager_bridge.cc

Issue 2133503002: arc: Revamp the ArcBridgeService interface (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: More rebasing Created 4 years, 5 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 | « components/arc/window_manager/arc_window_manager_bridge.h ('k') | ui/arc/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/arc/window_manager/arc_window_manager_bridge.h" 5 #include "components/arc/window_manager/arc_window_manager_bridge.h"
6 6
7 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 7 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "components/arc/arc_bridge_service.h" 10 #include "components/arc/arc_bridge_service.h"
11 11
12 namespace arc { 12 namespace arc {
13 13
14 ArcWindowManagerBridge::ArcWindowManagerBridge(ArcBridgeService* bridge_service) 14 ArcWindowManagerBridge::ArcWindowManagerBridge(ArcBridgeService* bridge_service)
15 : ArcService(bridge_service), 15 : ArcService(bridge_service),
16 current_mode_(mojom::WindowManagerMode::MODE_NORMAL) { 16 current_mode_(mojom::WindowManagerMode::MODE_NORMAL) {
17 arc_bridge_service()->AddObserver(this); 17 arc_bridge_service()->window_manager()->AddObserver(this);
18 if (!ash::WmShell::HasInstance()) { 18 if (!ash::WmShell::HasInstance()) {
19 // The shell gets always loaded before ARC. If there is no shell it can only 19 // The shell gets always loaded before ARC. If there is no shell it can only
20 // mean that a unit test is running. 20 // mean that a unit test is running.
21 return; 21 return;
22 } 22 }
23 // Monitor any mode changes from now on. 23 // Monitor any mode changes from now on.
24 ash::WmShell::Get()->AddShellObserver(this); 24 ash::WmShell::Get()->AddShellObserver(this);
25 } 25 }
26 26
27 void ArcWindowManagerBridge::OnWindowManagerInstanceReady() { 27 void ArcWindowManagerBridge::OnInstanceReady() {
28 if (!ash::WmShell::HasInstance()) { 28 if (!ash::WmShell::HasInstance()) {
29 // The shell gets always loaded before ARC. If there is no shell it can only 29 // The shell gets always loaded before ARC. If there is no shell it can only
30 // mean that a unit test is running. 30 // mean that a unit test is running.
31 return; 31 return;
32 } 32 }
33 ash::MaximizeModeController* controller = 33 ash::MaximizeModeController* controller =
34 ash::WmShell::Get()->maximize_mode_controller(); 34 ash::WmShell::Get()->maximize_mode_controller();
35 if (!controller) 35 if (!controller)
36 return; 36 return;
37 37
38 // Set the initial mode configuration. 38 // Set the initial mode configuration.
39 SendWindowManagerModeChange(controller->IsMaximizeModeWindowManagerEnabled()); 39 SendWindowManagerModeChange(controller->IsMaximizeModeWindowManagerEnabled());
40 } 40 }
41 41
42 ArcWindowManagerBridge::~ArcWindowManagerBridge() { 42 ArcWindowManagerBridge::~ArcWindowManagerBridge() {
43 if (ash::WmShell::HasInstance()) 43 if (ash::WmShell::HasInstance())
44 ash::WmShell::Get()->RemoveShellObserver(this); 44 ash::WmShell::Get()->RemoveShellObserver(this);
45 arc_bridge_service()->RemoveObserver(this); 45 arc_bridge_service()->window_manager()->RemoveObserver(this);
46 } 46 }
47 47
48 void ArcWindowManagerBridge::OnMaximizeModeStarted() { 48 void ArcWindowManagerBridge::OnMaximizeModeStarted() {
49 SendWindowManagerModeChange(true); 49 SendWindowManagerModeChange(true);
50 } 50 }
51 51
52 void ArcWindowManagerBridge::OnMaximizeModeEnded() { 52 void ArcWindowManagerBridge::OnMaximizeModeEnded() {
53 SendWindowManagerModeChange(false); 53 SendWindowManagerModeChange(false);
54 } 54 }
55 55
56 void ArcWindowManagerBridge::SendWindowManagerModeChange( 56 void ArcWindowManagerBridge::SendWindowManagerModeChange(
57 bool touch_view_enabled) { 57 bool touch_view_enabled) {
58 // We let the ArcBridgeService check that we are calling on the right thread. 58 // We let the ArcBridgeService check that we are calling on the right thread.
59 DCHECK(ArcBridgeService::Get() != nullptr); 59 DCHECK(ArcBridgeService::Get() != nullptr);
60 mojom::WindowManagerMode wm_mode = touch_view_enabled ? 60 mojom::WindowManagerMode wm_mode =
61 mojom::WindowManagerMode::MODE_TOUCH_VIEW : 61 touch_view_enabled ? mojom::WindowManagerMode::MODE_TOUCH_VIEW
62 mojom::WindowManagerMode::MODE_NORMAL; 62 : mojom::WindowManagerMode::MODE_NORMAL;
63 63
64 mojom::WindowManagerInstance* wm_instance = 64 mojom::WindowManagerInstance* wm_instance =
65 arc_bridge_service()->window_manager_instance(); 65 arc_bridge_service()->window_manager()->instance();
66 if (!wm_instance || wm_mode == current_mode_) { 66 if (!wm_instance || wm_mode == current_mode_) {
67 return; 67 return;
68 } 68 }
69 VLOG(1) << "Sending window manager mode change to " << wm_mode; 69 VLOG(1) << "Sending window manager mode change to " << wm_mode;
70 wm_instance->OnWindowManagerModeChange(wm_mode); 70 wm_instance->OnWindowManagerModeChange(wm_mode);
71 current_mode_ = wm_mode; 71 current_mode_ = wm_mode;
72 } 72 }
73 73
74 } // namespace arc 74 } // namespace arc
OLDNEW
« no previous file with comments | « components/arc/window_manager/arc_window_manager_bridge.h ('k') | ui/arc/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698