| 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/ui/ash/ash_util.h" | 5 #include "chrome/browser/ui/ash/ash_util.h" |
| 6 | 6 |
| 7 #include "ash/common/accelerators/accelerator_controller.h" | 7 #include "ash/common/accelerators/accelerator_controller.h" |
| 8 #include "ash/common/mojo_interface_factory.h" | 8 #include "ash/common/mojo_interface_factory.h" |
| 9 #include "ash/public/interfaces/event_properties.mojom.h" | 9 #include "ash/public/interfaces/event_properties.mojom.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/command_line.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "chrome/browser/ui/ash/ash_init.h" | 14 #include "chrome/browser/ui/ash/ash_init.h" |
| 15 #include "chrome/common/chrome_switches.h" |
| 14 #include "content/public/common/service_names.mojom.h" | 16 #include "content/public/common/service_names.mojom.h" |
| 15 #include "services/service_manager/public/cpp/interface_registry.h" | 17 #include "services/service_manager/public/cpp/interface_registry.h" |
| 16 #include "services/service_manager/public/cpp/service.h" | 18 #include "services/service_manager/public/cpp/service.h" |
| 17 #include "services/service_manager/public/interfaces/interface_provider_spec.moj
om.h" | 19 #include "services/service_manager/public/interfaces/interface_provider_spec.moj
om.h" |
| 18 #include "services/service_manager/runner/common/client_util.h" | 20 #include "services/service_manager/runner/common/client_util.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 21 #include "ui/aura/window_event_dispatcher.h" |
| 20 | 22 |
| 21 namespace ash_util { | 23 namespace ash_util { |
| 22 | 24 |
| 23 namespace { | 25 namespace { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 53 std::unique_ptr<service_manager::Service> CreateEmbeddedAshService( | 55 std::unique_ptr<service_manager::Service> CreateEmbeddedAshService( |
| 54 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 56 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
| 55 return base::MakeUnique<EmbeddedAshService>(task_runner); | 57 return base::MakeUnique<EmbeddedAshService>(task_runner); |
| 56 } | 58 } |
| 57 | 59 |
| 58 bool ShouldOpenAshOnStartup() { | 60 bool ShouldOpenAshOnStartup() { |
| 59 return !IsRunningInMash(); | 61 return !IsRunningInMash(); |
| 60 } | 62 } |
| 61 | 63 |
| 62 bool IsRunningInMash() { | 64 bool IsRunningInMash() { |
| 63 return service_manager::ServiceManagerIsRemote(); | 65 return GetConfig() == Config::MASH; |
| 66 } |
| 67 |
| 68 Config GetConfig() { |
| 69 if (!service_manager::ServiceManagerIsRemote()) |
| 70 return Config::CLASSIC; |
| 71 |
| 72 return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 73 switches::kMusConfig) == switches::kMash |
| 74 ? Config::MASH |
| 75 : Config::MUS; |
| 64 } | 76 } |
| 65 | 77 |
| 66 bool IsAcceleratorDeprecated(const ui::Accelerator& accelerator) { | 78 bool IsAcceleratorDeprecated(const ui::Accelerator& accelerator) { |
| 67 // When running in mash the browser doesn't handle ash accelerators. | 79 // When running in mash the browser doesn't handle ash accelerators. |
| 68 if (IsRunningInMash()) | 80 if (IsRunningInMash()) |
| 69 return false; | 81 return false; |
| 70 | 82 |
| 71 return ash::Shell::Get()->accelerator_controller()->IsDeprecated(accelerator); | 83 return ash::Shell::Get()->accelerator_controller()->IsDeprecated(accelerator); |
| 72 } | 84 } |
| 73 | 85 |
| 74 bool WillAshProcessAcceleratorForEvent(const ui::KeyEvent& key_event) { | 86 bool WillAshProcessAcceleratorForEvent(const ui::KeyEvent& key_event) { |
| 75 return key_event.properties() && | 87 return key_event.properties() && |
| 76 key_event.properties()->count( | 88 key_event.properties()->count( |
| 77 ash::mojom::kWillProcessAccelerator_KeyEventProperty); | 89 ash::mojom::kWillProcessAccelerator_KeyEventProperty); |
| 78 } | 90 } |
| 79 | 91 |
| 80 } // namespace ash_util | 92 } // namespace ash_util |
| OLD | NEW |