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

Unified Diff: services/ui/demo/mus_demo.cc

Issue 2693923004: Mus Demo: Extract code specific to internal mode into a separate class (Closed)
Patch Set: Fix wrong namespace comments Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/demo/mus_demo.h ('k') | services/ui/demo/mus_demo_internal.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/demo/mus_demo.cc
diff --git a/services/ui/demo/mus_demo.cc b/services/ui/demo/mus_demo.cc
index e529794d2f3bcbaab422ebf500ac8a9555f54c16..a4d55b04cd7359c415423627e58d4acfc9399c64 100644
--- a/services/ui/demo/mus_demo.cc
+++ b/services/ui/demo/mus_demo.cc
@@ -6,7 +6,6 @@
#include "base/memory/ptr_util.h"
#include "services/service_manager/public/cpp/connector.h"
-#include "services/service_manager/public/cpp/service_context.h"
#include "services/ui/demo/window_tree_data.h"
#include "services/ui/public/cpp/gpu/gpu.h"
#include "ui/aura/client/default_capture_client.h"
@@ -21,17 +20,26 @@
namespace ui {
namespace demo {
-namespace {
+MusDemo::MusDemo() {}
-// Size of square in pixels to draw.
-const int kSquareSize = 300;
+MusDemo::~MusDemo() {
+ display::Screen::SetScreenInstance(nullptr);
+}
+void MusDemo::AddPrimaryDisplay(const display::Display& display) {
+ screen_->display_list().AddDisplay(display,
+ display::DisplayList::Type::PRIMARY);
}
-MusDemo::MusDemo() {}
+void MusDemo::InitWindowTreeData(
+ std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
+ DCHECK(window_tree_data_);
+ DCHECK(!window_tree_data_->IsInitialized());
+ window_tree_data_->Init(std::move(window_tree_host));
+}
-MusDemo::~MusDemo() {
- display::Screen::SetScreenInstance(nullptr);
+void MusDemo::CleanupWindowTreeData() {
+ window_tree_data_.reset();
}
void MusDemo::OnStart() {
@@ -43,11 +51,7 @@ void MusDemo::OnStart() {
property_converter_ = base::MakeUnique<aura::PropertyConverter>();
wm_state_ = base::MakeUnique<::wm::WMState>();
- window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>(
- context()->connector(), this, this);
- window_tree_client_->ConnectAsWindowManager();
-
- window_tree_data_ = base::MakeUnique<WindowTreeData>(kSquareSize);
+ OnStartImpl(window_tree_client_, window_tree_data_);
env_->SetWindowTreeClient(window_tree_client_.get());
}
@@ -59,7 +63,6 @@ bool MusDemo::OnConnect(const service_manager::ServiceInfo& remote_info,
void MusDemo::OnEmbed(
std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) {
- // Not called for the WindowManager.
NOTREACHED();
}
@@ -68,13 +71,12 @@ void MusDemo::OnUnembed(aura::Window* root) {
}
void MusDemo::OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) {
- // Not called for the WindowManager.
NOTREACHED();
}
void MusDemo::OnLostConnection(aura::WindowTreeClient* client) {
window_tree_client_.reset();
- window_tree_data_.reset();
+ CleanupWindowTreeData();
}
void MusDemo::OnPointerEventObserved(const PointerEvent& event,
@@ -84,72 +86,5 @@ aura::PropertyConverter* MusDemo::GetPropertyConverter() {
return property_converter_.get();
}
-void MusDemo::SetWindowManagerClient(aura::WindowManagerClient* client) {}
-
-bool MusDemo::OnWmSetBounds(aura::Window* window, gfx::Rect* bounds) {
- return true;
-}
-
-bool MusDemo::OnWmSetProperty(aura::Window* window,
- const std::string& name,
- std::unique_ptr<std::vector<uint8_t>>* new_data) {
- return true;
-}
-
-void MusDemo::OnWmSetCanFocus(aura::Window* window, bool can_focus) {}
-
-aura::Window* MusDemo::OnWmCreateTopLevelWindow(
- mojom::WindowType window_type,
- std::map<std::string, std::vector<uint8_t>>* properties) {
- NOTREACHED();
- return nullptr;
-}
-
-void MusDemo::OnWmClientJankinessChanged(
- const std::set<aura::Window*>& client_windows,
- bool janky) {
- // Don't care
-}
-
-void MusDemo::OnWmWillCreateDisplay(const display::Display& display) {
- screen_->display_list().AddDisplay(display,
- display::DisplayList::Type::PRIMARY);
-}
-
-void MusDemo::OnWmNewDisplay(
- std::unique_ptr<aura::WindowTreeHostMus> window_tree_host,
- const display::Display& display) {
- DCHECK(!window_tree_data_->IsInitialized()); // Only support one display.
- window_tree_data_->Init(std::move(window_tree_host));
-}
-
-void MusDemo::OnWmDisplayRemoved(aura::WindowTreeHostMus* window_tree_host) {
- window_tree_data_.reset();
-}
-
-void MusDemo::OnWmDisplayModified(const display::Display& display) {}
-
-mojom::EventResult MusDemo::OnAccelerator(uint32_t id, const Event& event) {
- return mojom::EventResult::UNHANDLED;
-}
-
-void MusDemo::OnWmPerformMoveLoop(aura::Window* window,
- mojom::MoveLoopSource source,
- const gfx::Point& cursor_location,
- const base::Callback<void(bool)>& on_done) {
- // Don't care
-}
-
-void MusDemo::OnWmCancelMoveLoop(aura::Window* window) {}
-
-void MusDemo::OnWmSetClientArea(
- aura::Window* window,
- const gfx::Insets& insets,
- const std::vector<gfx::Rect>& additional_client_areas) {}
-
-bool MusDemo::IsWindowActive(aura::Window* window) { return false; }
-
-void MusDemo::OnWmDeactivateWindow(aura::Window* window) {}
-
} // namespace demo
-} // namespace aura
+} // namespace ui
« no previous file with comments | « services/ui/demo/mus_demo.h ('k') | services/ui/demo/mus_demo_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698