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

Unified Diff: mojo/aura/window_tree_host_mojo.cc

Issue 314113011: Moves common view_manager related aura files to mojo/aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweaks Created 6 years, 6 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 | « mojo/aura/window_tree_host_mojo.h ('k') | mojo/aura/window_tree_host_mojo_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/aura/window_tree_host_mojo.cc
diff --git a/mojo/aura/window_tree_host_mojo.cc b/mojo/aura/window_tree_host_mojo.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9a51f2eb456233d5bcab6a991c78eadf2410a926
--- /dev/null
+++ b/mojo/aura/window_tree_host_mojo.cc
@@ -0,0 +1,161 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/aura/window_tree_host_mojo.h"
+
+#include <vector>
+
+#include "mojo/aura/window_tree_host_mojo_delegate.h"
+#include "ui/aura/env.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_event_dispatcher.h"
+#include "ui/events/event.h"
+#include "ui/events/event_constants.h"
+
+namespace mojo {
+namespace {
+
+const char kTreeHostsKey[] = "tree_hosts";
+
+typedef std::vector<WindowTreeHostMojo*> Managers;
+
+class TreeHosts : public base::SupportsUserData::Data {
+ public:
+ TreeHosts() {}
+ virtual ~TreeHosts() {}
+
+ static TreeHosts* Get() {
+ TreeHosts* hosts = static_cast<TreeHosts*>(
+ aura::Env::GetInstance()->GetUserData(kTreeHostsKey));
+ if (!hosts) {
+ hosts = new TreeHosts;
+ aura::Env::GetInstance()->SetUserData(kTreeHostsKey, hosts);
+ }
+ return hosts;
+ }
+
+ void Add(WindowTreeHostMojo* manager) {
+ managers_.push_back(manager);
+ }
+
+ void Remove(WindowTreeHostMojo* manager) {
+ Managers::iterator i = std::find(managers_.begin(), managers_.end(),
+ manager);
+ DCHECK(i != managers_.end());
+ managers_.erase(i);
+ }
+
+ const std::vector<WindowTreeHostMojo*> managers() const {
+ return managers_;
+ }
+
+ private:
+ Managers managers_;
+
+ DISALLOW_COPY_AND_ASSIGN(TreeHosts);
+};
+
+} // namespace
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowTreeHostMojo, public:
+
+WindowTreeHostMojo::WindowTreeHostMojo(const gfx::Rect& bounds,
+ WindowTreeHostMojoDelegate* delegate)
+ : bounds_(bounds),
+ delegate_(delegate) {
+ CreateCompositor(GetAcceleratedWidget());
+
+ TreeHosts::Get()->Add(this);
+}
+
+WindowTreeHostMojo::~WindowTreeHostMojo() {
+ TreeHosts::Get()->Remove(this);
+ DestroyCompositor();
+ DestroyDispatcher();
+}
+
+// static
+WindowTreeHostMojo* WindowTreeHostMojo::ForCompositor(
+ ui::Compositor* compositor) {
+ const Managers& managers = TreeHosts::Get()->managers();
+ for (size_t i = 0; i < managers.size(); ++i) {
+ if (managers[i]->compositor() == compositor)
+ return managers[i];
+ }
+ return NULL;
+}
+
+void WindowTreeHostMojo::SetContents(const SkBitmap& contents) {
+ delegate_->CompositorContentsChanged(contents);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowTreeHostMojo, aura::WindowTreeHost implementation:
+
+ui::EventSource* WindowTreeHostMojo::GetEventSource() {
+ return this;
+}
+
+gfx::AcceleratedWidget WindowTreeHostMojo::GetAcceleratedWidget() {
+ NOTIMPLEMENTED() << "GetAcceleratedWidget";
+ return gfx::kNullAcceleratedWidget;
+}
+
+void WindowTreeHostMojo::Show() {
+ window()->Show();
+}
+
+void WindowTreeHostMojo::Hide() {
+}
+
+gfx::Rect WindowTreeHostMojo::GetBounds() const {
+ return bounds_;
+}
+
+void WindowTreeHostMojo::SetBounds(const gfx::Rect& bounds) {
+}
+
+gfx::Point WindowTreeHostMojo::GetLocationOnNativeScreen() const {
+ return gfx::Point(0, 0);
+}
+
+void WindowTreeHostMojo::SetCapture() {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::ReleaseCapture() {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::PostNativeEvent(
+ const base::NativeEvent& native_event) {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::OnDeviceScaleFactorChanged(
+ float device_scale_factor) {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::SetCursorNative(gfx::NativeCursor cursor) {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::MoveCursorToNative(const gfx::Point& location) {
+ NOTIMPLEMENTED();
+}
+
+void WindowTreeHostMojo::OnCursorVisibilityChangedNative(bool show) {
+ NOTIMPLEMENTED();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// WindowTreeHostMojo, ui::EventSource implementation:
+
+ui::EventProcessor* WindowTreeHostMojo::GetEventProcessor() {
+ return dispatcher();
+}
+
+} // namespace mojo
« no previous file with comments | « mojo/aura/window_tree_host_mojo.h ('k') | mojo/aura/window_tree_host_mojo_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698