| 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 "ash/host/window_tree_host_factory.h" | 5 #include "ash/host/window_tree_host_factory.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "ui/aura/remote_window_tree_host_win.h" | 10 #include "ui/aura/remote_window_tree_host_win.h" |
| 11 #include "ui/aura/window_tree_host.h" | 11 #include "ui/aura/window_tree_host.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class WindowTreeHostFactoryImpl : public ash::WindowTreeHostFactory { | 15 class WindowTreeHostFactoryImpl : public ash::WindowTreeHostFactory { |
| 16 public: | 16 public: |
| 17 WindowTreeHostFactoryImpl() {} | 17 explicit WindowTreeHostFactoryImpl(bool test_mode) : test_mode_(test_mode) { |
| 18 } |
| 18 | 19 |
| 19 // Overridden from WindowTreeHostFactory: | |
| 20 virtual aura::WindowTreeHost* CreateWindowTreeHost( | 20 virtual aura::WindowTreeHost* CreateWindowTreeHost( |
| 21 const gfx::Rect& initial_bounds) OVERRIDE { | 21 const gfx::Rect& initial_bounds) OVERRIDE { |
| 22 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | 22 if (test_mode_) |
| 23 !CommandLine::ForCurrentProcess()->HasSwitch( | 23 return aura::WindowTreeHost::Create(initial_bounds); |
| 24 ash::switches::kForceAshToDesktop)) | 24 else |
| 25 return aura::RemoteWindowTreeHostWin::Create(initial_bounds); | 25 return aura::RemoteWindowTreeHostWin::Create(initial_bounds); |
| 26 } |
| 26 | 27 |
| 27 return aura::WindowTreeHost::Create(initial_bounds); | 28 private: |
| 28 } | 29 bool test_mode_; |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 } | 32 } |
| 32 | 33 |
| 33 namespace ash { | 34 namespace ash { |
| 35 // static |
| 36 WindowTreeHostFactory* WindowTreeHostFactory::CreateForTest() { |
| 37 return new WindowTreeHostFactoryImpl(true); |
| 38 } |
| 34 | 39 |
| 35 // static | 40 // static |
| 36 WindowTreeHostFactory* WindowTreeHostFactory::Create() { | 41 WindowTreeHostFactory* WindowTreeHostFactory::Create() { |
| 37 return new WindowTreeHostFactoryImpl; | 42 return new WindowTreeHostFactoryImpl(false); |
| 38 } | 43 } |
| 39 | 44 |
| 40 } // namespace ash | 45 } // namespace ash |
| OLD | NEW |