Move services code brought in from Mojo to live under //third_party.
This CL moves services code that is brought in from the Mojo repo and currently
living in //mojo/services to instead live in //third_party/mojo_services/src.
It fixes up include paths, buildfile references, and DEPS entries to account
for the new state of the world.
Review URL: https://codereview.chromium.org/861683003
Cr-Commit-Position: refs/heads/master@{#313876}
CrOS-Libchrome-Original-Commit: 33cb04550654d68c74f84d445eed184663bb15ab
diff --git a/mojo/cc/output_surface_mojo.h b/mojo/cc/output_surface_mojo.h
index 445d1ab..a34193e 100644
--- a/mojo/cc/output_surface_mojo.h
+++ b/mojo/cc/output_surface_mojo.h
@@ -8,7 +8,7 @@
#include "base/macros.h"
#include "cc/output/output_surface.h"
#include "cc/surfaces/surface_id.h"
-#include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h"
+#include "third_party/mojo_services/src/surfaces/public/interfaces/surfaces.mojom.h"
namespace mojo {
diff --git a/mojo/converters/geometry/geometry_type_converters.h b/mojo/converters/geometry/geometry_type_converters.h
index ff55fc4..59d3552 100644
--- a/mojo/converters/geometry/geometry_type_converters.h
+++ b/mojo/converters/geometry/geometry_type_converters.h
@@ -6,7 +6,7 @@
#define MOJO_CONVERTERS_GEOMETRY_GEOMETRY_TYPE_CONVERTERS_H_
#include "mojo/converters/geometry/mojo_geometry_export.h"
-#include "mojo/services/geometry/public/interfaces/geometry.mojom.h"
+#include "third_party/mojo_services/src/geometry/public/interfaces/geometry.mojom.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/mojo/converters/input_events/input_events_type_converters.cc b/mojo/converters/input_events/input_events_type_converters.cc
index cd78386..f6be2f1 100644
--- a/mojo/converters/input_events/input_events_type_converters.cc
+++ b/mojo/converters/input_events/input_events_type_converters.cc
@@ -11,7 +11,7 @@
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/input_events/mojo_extended_key_event_data.h"
-#include "mojo/services/input_events/public/interfaces/input_events.mojom.h"
+#include "third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h"
diff --git a/mojo/converters/input_events/input_events_type_converters.h b/mojo/converters/input_events/input_events_type_converters.h
index 96cb264..d520006 100644
--- a/mojo/converters/input_events/input_events_type_converters.h
+++ b/mojo/converters/input_events/input_events_type_converters.h
@@ -7,7 +7,7 @@
#include "base/memory/scoped_ptr.h"
#include "mojo/converters/input_events/mojo_input_events_export.h"
-#include "mojo/services/input_events/public/interfaces/input_events.mojom.h"
+#include "third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom.h"
#include "ui/events/event.h"
namespace mojo {
diff --git a/mojo/converters/surfaces/surfaces_type_converters.h b/mojo/converters/surfaces/surfaces_type_converters.h
index 3d01b79..f41af6d 100644
--- a/mojo/converters/surfaces/surfaces_type_converters.h
+++ b/mojo/converters/surfaces/surfaces_type_converters.h
@@ -12,9 +12,9 @@
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/mailbox_holder.h"
#include "mojo/converters/surfaces/mojo_surfaces_export.h"
-#include "mojo/services/surfaces/public/interfaces/quads.mojom.h"
-#include "mojo/services/surfaces/public/interfaces/surface_id.mojom.h"
-#include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h"
+#include "third_party/mojo_services/src/surfaces/public/interfaces/quads.mojom.h"
+#include "third_party/mojo_services/src/surfaces/public/interfaces/surface_id.mojom.h"
+#include "third_party/mojo_services/src/surfaces/public/interfaces/surfaces.mojom.h"
#include "third_party/skia/include/core/SkColor.h"
namespace cc {
diff --git a/mojo/converters/surfaces/surfaces_utils.h b/mojo/converters/surfaces/surfaces_utils.h
index a4f57f3..ef5b91e 100644
--- a/mojo/converters/surfaces/surfaces_utils.h
+++ b/mojo/converters/surfaces/surfaces_utils.h
@@ -6,7 +6,7 @@
#define MOJO_CONVERTERS_SURFACES_SURFACES_UTILS_H_
#include "mojo/converters/surfaces/mojo_surfaces_export.h"
-#include "mojo/services/surfaces/public/interfaces/quads.mojom.h"
+#include "third_party/mojo_services/src/surfaces/public/interfaces/quads.mojom.h"
namespace gfx {
class Rect;
diff --git a/mojo/services/accessibility/public/interfaces/accessibility.mojom b/mojo/services/accessibility/public/interfaces/accessibility.mojom
deleted file mode 100644
index 3958388..0000000
--- a/mojo/services/accessibility/public/interfaces/accessibility.mojom
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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.
-
-module mojo;
-
-import "geometry/public/interfaces/geometry.mojom";
-
-interface AxProvider {
- GetTree() => (array<AxNode> nodes);
-};
-
-struct AxNode {
- // Must be non-zero.
- uint32 id;
-
- // Can be zero if the node has no parent or next sibling.
- uint32 parent_id;
- uint32 next_sibling_id;
-
- mojo.Rect bounds;
-
- // At most one of the below will be present.
- // TODO(aa): These should become a union.
- AxLink? link;
- AxText? text;
-};
-
-struct AxLink {
- string url;
-};
-
-struct AxText {
- string content;
-};
diff --git a/mojo/services/clipboard/public/interfaces/clipboard.mojom b/mojo/services/clipboard/public/interfaces/clipboard.mojom
deleted file mode 100644
index ca4d6b1..0000000
--- a/mojo/services/clipboard/public/interfaces/clipboard.mojom
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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.
-
-module mojo;
-
-interface Clipboard {
- enum Type {
- COPY_PASTE = 0,
- SELECTION = 1,
- DRAG = 2
- };
-
- // Mime type constants
- const string MIME_TYPE_TEXT = "text/plain";
- const string MIME_TYPE_HTML = "text/html";
- const string MIME_TYPE_URL = "text/url";
-
- // Returns a sequence number which uniquely identifies clipboard state.
- // Clients are able to assume that the clipboard contents are unchanged as
- // long as this number has not changed. This number is monotonically
- // increasing, is increased when the clipboard state changes, and is
- // provided by Windows, Linux, and Mac.
- GetSequenceNumber(Type clipboard_type) => (uint64 sequence);
-
- // Returns the available mime types. (Note: the chrome interface has a
- // |contains_filenames| parameter here, but it appears to always be set
- // to false.)
- GetAvailableMimeTypes(Type clipboard_types) => (array<string> types);
-
- // Returns the data associated with a Mime type, returning NULL if that data
- // doesn't exist. Note: because of the inherit raciness of clipboard access,
- // this may return NULL even if you just verified that it exists with
- // GetAvailableFormatMimeTypes(). We don't want to provide one API to return
- // the entire clipboard state because the combined size of the clipboard can
- // be megabytes, especially when image data is involved.
- ReadMimeType(Type clipboard_type, string mime_type) => (array<uint8>? data);
-
- // Writes a set of mime types to the clipboard. This will increment the
- // sequence number. In the case of an empty or null map, this will just
- // clear the clipboard.
- WriteClipboardData(Type clipboard_type, map<string, array<uint8>>? data);
-};
diff --git a/mojo/services/content_handler/public/interfaces/content_handler.mojom b/mojo/services/content_handler/public/interfaces/content_handler.mojom
deleted file mode 100644
index 39ddfea..0000000
--- a/mojo/services/content_handler/public/interfaces/content_handler.mojom
+++ /dev/null
@@ -1,12 +0,0 @@
-// 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.
-
-module mojo;
-
-import "mojo/public/interfaces/application/application.mojom";
-import "network/public/interfaces/url_loader.mojom";
-
-interface ContentHandler {
- StartApplication(Application& application, URLResponse response);
-};
diff --git a/mojo/services/geometry/public/cpp/geometry_util.h b/mojo/services/geometry/public/cpp/geometry_util.h
deleted file mode 100644
index f69fac3..0000000
--- a/mojo/services/geometry/public/cpp/geometry_util.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_GEOMETRY_PUBLIC_CPP_GEOMETRY_UTIL_H_
-#define MOJO_SERVICES_GEOMETRY_PUBLIC_CPP_GEOMETRY_UTIL_H_
-
-#include "geometry/public/interfaces/geometry.mojom.h"
-
-namespace mojo {
-
-inline bool operator==(const Rect& lhs, const Rect& rhs) {
- return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width &&
- lhs.height == lhs.height;
-}
-
-inline bool operator!=(const Rect& lhs, const Rect& rhs) {
- return !(lhs == rhs);
-}
-
-inline bool operator==(const Size& lhs, const Size& rhs) {
- return lhs.width == rhs.width && lhs.height == rhs.height;
-}
-
-inline bool operator!=(const Size& lhs, const Size& rhs) {
- return !(lhs == rhs);
-}
-
-inline bool operator==(const Point& lhs, const Point& rhs) {
- return lhs.x == rhs.x && lhs.y == rhs.y;
-}
-
-inline bool operator!=(const Point& lhs, const Point& rhs) {
- return !(lhs == rhs);
-}
-
-}
-
-#endif // MOJO_SERVICES_GEOMETRY_PUBLIC_CPP_GEOMETRY_UTIL_H_
diff --git a/mojo/services/geometry/public/interfaces/geometry.mojom b/mojo/services/geometry/public/interfaces/geometry.mojom
deleted file mode 100644
index 62bc6c8..0000000
--- a/mojo/services/geometry/public/interfaces/geometry.mojom
+++ /dev/null
@@ -1,39 +0,0 @@
-// 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.
-
-module mojo;
-
-struct Point {
- int32 x;
- int32 y;
-};
-
-struct PointF {
- float x;
- float y;
-};
-
-struct Size {
- int32 width;
- int32 height;
-};
-
-struct Rect {
- int32 x;
- int32 y;
- int32 width;
- int32 height;
-};
-
-struct RectF {
- float x;
- float y;
- float width;
- float height;
-};
-
-struct Transform {
- // Row major order.
- array<float, 16> matrix;
-};
diff --git a/mojo/services/gpu/public/interfaces/command_buffer.mojom b/mojo/services/gpu/public/interfaces/command_buffer.mojom
deleted file mode 100644
index a31b3dd..0000000
--- a/mojo/services/gpu/public/interfaces/command_buffer.mojom
+++ /dev/null
@@ -1,53 +0,0 @@
-// 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.
-
-module mojo;
-
-import "gpu/public/interfaces/gpu_capabilities.mojom";
-
-struct CommandBufferState {
- int32 num_entries;
- int32 get_offset;
- int32 put_offset;
- int32 token;
- int32 error; // TODO(piman): enum
- int32 context_lost_reason; // TODO(piman): enum
- uint32 generation;
-};
-
-interface CommandBufferSyncClient {
- DidInitialize(bool success, GpuCapabilities capabilities);
- DidMakeProgress(CommandBufferState state);
-};
-
-interface CommandBufferSyncPointClient {
- DidInsertSyncPoint(uint32 sync_point);
-};
-
-[Client=CommandBufferClient]
-interface CommandBuffer {
- Initialize(CommandBufferSyncClient sync_client,
- CommandBufferSyncPointClient sync_point_client,
- handle<shared_buffer> shared_state);
- SetGetBuffer(int32 buffer);
- Flush(int32 put_offset);
- MakeProgress(int32 last_get_offset);
- RegisterTransferBuffer(
- int32 id, handle<shared_buffer> transfer_buffer, uint32 size);
- DestroyTransferBuffer(int32 id);
-
- // InsertSyncPoint returns the sync point returned via DidInsertSyncPoint.
- // If |retire| is true, the sync point is retired on insertion. Otherwise,
- // explicitly call RetireSyncPoint to retire it.
- InsertSyncPoint(bool retire);
- RetireSyncPoint(uint32 sync_point);
- Echo() => ();
-
- // TODO(piman): sync points
-};
-
-interface CommandBufferClient {
- DidDestroy();
- LostContext(int32 lost_reason); // TODO(piman): enum
-};
diff --git a/mojo/services/gpu/public/interfaces/gpu.mojom b/mojo/services/gpu/public/interfaces/gpu.mojom
deleted file mode 100644
index c61869c..0000000
--- a/mojo/services/gpu/public/interfaces/gpu.mojom
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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.
-
-module mojo;
-
-import "geometry/public/interfaces/geometry.mojom";
-import "gpu/public/interfaces/command_buffer.mojom";
-import "gpu/public/interfaces/viewport_parameter_listener.mojom";
-
-interface Gpu {
- CreateOnscreenGLES2Context(uint64 native_viewport_id,
- Size size,
- CommandBuffer& gles2_client,
- ViewportParameterListener? listener);
- CreateOffscreenGLES2Context(CommandBuffer& gles2_client);
-};
diff --git a/mojo/services/gpu/public/interfaces/gpu_capabilities.mojom b/mojo/services/gpu/public/interfaces/gpu_capabilities.mojom
deleted file mode 100644
index 2450139..0000000
--- a/mojo/services/gpu/public/interfaces/gpu_capabilities.mojom
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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.
-
-module mojo;
-
-struct GpuShaderPrecision {
- int32 min_range;
- int32 max_range;
- int32 precision;
-};
-
-struct GpuPerStagePrecisions {
- GpuShaderPrecision low_int;
- GpuShaderPrecision medium_int;
- GpuShaderPrecision high_int;
- GpuShaderPrecision low_float;
- GpuShaderPrecision medium_float;
- GpuShaderPrecision high_float;
-};
-
-struct GpuCapabilities {
- GpuPerStagePrecisions vertex_shader_precisions;
- GpuPerStagePrecisions fragment_shader_precisions;
- int32 max_combined_texture_image_units;
- int32 max_cube_map_texture_size;
- int32 max_fragment_uniform_vectors;
- int32 max_renderbuffer_size;
- int32 max_texture_image_units;
- int32 max_texture_size;
- int32 max_varying_vectors;
- int32 max_vertex_attribs;
- int32 max_vertex_texture_image_units;
- int32 max_vertex_uniform_vectors;
- int32 num_compressed_texture_formats;
- int32 num_shader_binary_formats;
- int32 bind_generates_resource_chromium;
-
- bool post_sub_buffer;
- bool egl_image_external;
- bool texture_format_bgra8888;
- bool texture_format_etc1;
- bool texture_format_etc1_npot;
- bool texture_rectangle;
- bool iosurface;
- bool texture_usage;
- bool texture_storage;
- bool discard_framebuffer;
- bool sync_query;
- bool image;
- bool future_sync_points;
- bool blend_equation_advanced;
- bool blend_equation_advanced_coherent;
-};
diff --git a/mojo/services/gpu/public/interfaces/viewport_parameter_listener.mojom b/mojo/services/gpu/public/interfaces/viewport_parameter_listener.mojom
deleted file mode 100644
index 5afa931..0000000
--- a/mojo/services/gpu/public/interfaces/viewport_parameter_listener.mojom
+++ /dev/null
@@ -1,12 +0,0 @@
-// 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.
-
-module mojo;
-
-interface ViewportParameterListener {
- // These parameters describe the refresh rate of the viewport. The viewport
- // refreshes every |interval| time ticks. The phase of the refresh is
- // indicated by |timebase|, which is synchronized with MojoGetTimeTicksNow.
- OnVSyncParametersUpdated(int64 timebase, int64 interval);
-};
diff --git a/mojo/services/html_viewer/ax_provider_impl.h b/mojo/services/html_viewer/ax_provider_impl.h
index fba6be4..ec6c8de 100644
--- a/mojo/services/html_viewer/ax_provider_impl.h
+++ b/mojo/services/html_viewer/ax_provider_impl.h
@@ -5,8 +5,8 @@
#ifndef MOJO_SERVICES_HTML_VIEWER_AX_PROVIDER_IMPL_H_
#define MOJO_SERVICES_HTML_VIEWER_AX_PROVIDER_IMPL_H_
-#include "mojo/services/accessibility/public/interfaces/accessibility.mojom.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
+#include "third_party/mojo_services/src/accessibility/public/interfaces/accessibility.mojom.h"
namespace blink {
class WebAXObject;
diff --git a/mojo/services/html_viewer/blink_basic_type_converters.h b/mojo/services/html_viewer/blink_basic_type_converters.h
index 65f0681..eb762a8 100644
--- a/mojo/services/html_viewer/blink_basic_type_converters.h
+++ b/mojo/services/html_viewer/blink_basic_type_converters.h
@@ -7,9 +7,9 @@
#include "third_party/mojo/src/mojo/public/cpp/bindings/type_converter.h"
-#include "mojo/services/geometry/public/interfaces/geometry.mojom.h"
#include "third_party/WebKit/public/platform/WebVector.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/array.h"
+#include "third_party/mojo_services/src/geometry/public/interfaces/geometry.mojom.h"
namespace blink {
struct WebRect;
diff --git a/mojo/services/html_viewer/blink_input_events_type_converters.cc b/mojo/services/html_viewer/blink_input_events_type_converters.cc
index 0f6f6c1..11434b5 100644
--- a/mojo/services/html_viewer/blink_input_events_type_converters.cc
+++ b/mojo/services/html_viewer/blink_input_events_type_converters.cc
@@ -6,8 +6,8 @@
#include "base/logging.h"
#include "base/time/time.h"
-#include "mojo/services/input_events/public/interfaces/input_event_constants.mojom.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
+#include "third_party/mojo_services/src/input_events/public/interfaces/input_event_constants.mojom.h"
namespace mojo {
namespace {
diff --git a/mojo/services/html_viewer/blink_input_events_type_converters.h b/mojo/services/html_viewer/blink_input_events_type_converters.h
index 9e3e9ae..442239c 100644
--- a/mojo/services/html_viewer/blink_input_events_type_converters.h
+++ b/mojo/services/html_viewer/blink_input_events_type_converters.h
@@ -6,7 +6,7 @@
#define MOJO_SERVICES_HTML_VIEWER_BLINK_INPUT_EVENTS_TYPE_CONVERTERS_H_
#include "base/memory/scoped_ptr.h"
-#include "mojo/services/input_events/public/interfaces/input_events.mojom.h"
+#include "third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom.h"
namespace blink {
class WebInputEvent;
diff --git a/mojo/services/html_viewer/html_document.cc b/mojo/services/html_viewer/html_document.cc
index de6e178..701860a 100644
--- a/mojo/services/html_viewer/html_document.cc
+++ b/mojo/services/html_viewer/html_document.cc
@@ -20,8 +20,6 @@
#include "mojo/services/html_viewer/webmediaplayer_factory.h"
#include "mojo/services/html_viewer/webstoragenamespace_impl.h"
#include "mojo/services/html_viewer/weburlloader_impl.h"
-#include "mojo/services/surfaces/public/interfaces/surfaces_service.mojom.h"
-#include "mojo/services/view_manager/public/cpp/view.h"
#include "skia/ext/refptr.h"
#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/WebHTTPHeaderVisitor.h"
@@ -37,6 +35,8 @@
#include "third_party/mojo/src/mojo/public/cpp/application/connect.h"
#include "third_party/mojo/src/mojo/public/cpp/system/data_pipe.h"
#include "third_party/mojo/src/mojo/public/interfaces/application/shell.mojom.h"
+#include "third_party/mojo_services/src/surfaces/public/interfaces/surfaces_service.mojom.h"
+#include "third_party/mojo_services/src/view_manager/public/cpp/view.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkDevice.h"
diff --git a/mojo/services/html_viewer/html_document.h b/mojo/services/html_viewer/html_document.h
index ea3019b..eedfc06 100644
--- a/mojo/services/html_viewer/html_document.h
+++ b/mojo/services/html_viewer/html_document.h
@@ -9,13 +9,8 @@
#include "base/callback.h"
#include "base/macros.h"
-#include "mojo/services/content_handler/public/interfaces/content_handler.mojom.h"
#include "mojo/services/html_viewer/ax_provider_impl.h"
-#include "mojo/services/navigation/public/interfaces/navigation.mojom.h"
#include "mojo/services/network/public/interfaces/url_loader.mojom.h"
-#include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h"
-#include "mojo/services/view_manager/public/cpp/view_manager_delegate.h"
-#include "mojo/services/view_manager/public/cpp/view_observer.h"
#include "third_party/WebKit/public/web/WebFrameClient.h"
#include "third_party/WebKit/public/web/WebSandboxFlags.h"
#include "third_party/WebKit/public/web/WebViewClient.h"
@@ -24,6 +19,11 @@
#include "third_party/mojo/src/mojo/public/cpp/application/service_provider_impl.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
#include "third_party/mojo/src/mojo/public/interfaces/application/application.mojom.h"
+#include "third_party/mojo_services/src/content_handler/public/interfaces/content_handler.mojom.h"
+#include "third_party/mojo_services/src/navigation/public/interfaces/navigation.mojom.h"
+#include "third_party/mojo_services/src/view_manager/public/cpp/view_manager_client_factory.h"
+#include "third_party/mojo_services/src/view_manager/public/cpp/view_manager_delegate.h"
+#include "third_party/mojo_services/src/view_manager/public/cpp/view_observer.h"
namespace base {
class MessageLoopProxy;
diff --git a/mojo/services/html_viewer/html_viewer.cc b/mojo/services/html_viewer/html_viewer.cc
index 73f3045..02c290a 100644
--- a/mojo/services/html_viewer/html_viewer.cc
+++ b/mojo/services/html_viewer/html_viewer.cc
@@ -10,7 +10,6 @@
#include "base/threading/thread.h"
#include "gin/public/isolate_holder.h"
#include "mojo/application/application_runner_chromium.h"
-#include "mojo/services/content_handler/public/interfaces/content_handler.mojom.h"
#include "mojo/services/html_viewer/html_document.h"
#include "mojo/services/html_viewer/mojo_blink_platform_impl.h"
#include "mojo/services/html_viewer/webmediaplayer_factory.h"
@@ -24,6 +23,7 @@
#include "third_party/mojo/src/mojo/public/cpp/application/connect.h"
#include "third_party/mojo/src/mojo/public/cpp/application/interface_factory_impl.h"
#include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
+#include "third_party/mojo_services/src/content_handler/public/interfaces/content_handler.mojom.h"
#if !defined(COMPONENT_BUILD)
#include "base/i18n/icu_util.h"
diff --git a/mojo/services/html_viewer/webclipboard_impl.h b/mojo/services/html_viewer/webclipboard_impl.h
index b4320d8..5edccf4 100644
--- a/mojo/services/html_viewer/webclipboard_impl.h
+++ b/mojo/services/html_viewer/webclipboard_impl.h
@@ -5,8 +5,8 @@
#ifndef MOJO_SERVICES_HTML_VIEWER_WEBCLIPBOARD_IMPL_H_
#define MOJO_SERVICES_HTML_VIEWER_WEBCLIPBOARD_IMPL_H_
-#include "mojo/services/clipboard/public/interfaces/clipboard.mojom.h"
#include "third_party/WebKit/public/platform/WebClipboard.h"
+#include "third_party/mojo_services/src/clipboard/public/interfaces/clipboard.mojom.h"
namespace html_viewer {
diff --git a/mojo/services/html_viewer/weblayertreeview_impl.cc b/mojo/services/html_viewer/weblayertreeview_impl.cc
index 77c74ec..0c2811a 100644
--- a/mojo/services/html_viewer/weblayertreeview_impl.cc
+++ b/mojo/services/html_viewer/weblayertreeview_impl.cc
@@ -13,8 +13,8 @@
#include "mojo/cc/context_provider_mojo.h"
#include "mojo/cc/output_surface_mojo.h"
#include "mojo/converters/surfaces/surfaces_type_converters.h"
-#include "mojo/services/view_manager/public/cpp/view.h"
#include "third_party/WebKit/public/web/WebWidget.h"
+#include "third_party/mojo_services/src/view_manager/public/cpp/view.h"
namespace html_viewer {
diff --git a/mojo/services/html_viewer/weblayertreeview_impl.h b/mojo/services/html_viewer/weblayertreeview_impl.h
index c4e420a..42ae1bc 100644
--- a/mojo/services/html_viewer/weblayertreeview_impl.h
+++ b/mojo/services/html_viewer/weblayertreeview_impl.h
@@ -12,9 +12,9 @@
#include "base/single_thread_task_runner.h"
#include "cc/trees/layer_tree_host_client.h"
#include "mojo/cc/output_surface_mojo.h"
-#include "mojo/services/gpu/public/interfaces/gpu.mojom.h"
-#include "mojo/services/surfaces/public/interfaces/surfaces_service.mojom.h"
#include "third_party/WebKit/public/platform/WebLayerTreeView.h"
+#include "third_party/mojo_services/src/gpu/public/interfaces/gpu.mojom.h"
+#include "third_party/mojo_services/src/surfaces/public/interfaces/surfaces_service.mojom.h"
namespace base {
class MessageLoopProxy;
diff --git a/mojo/services/input_events/public/interfaces/input_event_constants.mojom b/mojo/services/input_events/public/interfaces/input_event_constants.mojom
deleted file mode 100644
index f137fb3..0000000
--- a/mojo/services/input_events/public/interfaces/input_event_constants.mojom
+++ /dev/null
@@ -1,77 +0,0 @@
-// 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.
-
-module mojo;
-
-// This mirrors ui::EventType
-enum EventType {
- UNKNOWN ,
- MOUSE_PRESSED,
- MOUSE_DRAGGED,
- MOUSE_RELEASED,
- MOUSE_MOVED,
- MOUSE_ENTERED,
- MOUSE_EXITED,
- KEY_PRESSED,
- KEY_RELEASED,
- MOUSEWHEEL,
- MOUSE_CAPTURE_CHANGED,
- TOUCH_RELEASED,
- TOUCH_PRESSED,
- TOUCH_MOVED,
- TOUCH_CANCELLED,
- DROP_TARGET_EVENT,
- TRANSLATED_KEY_PRESS,
- TRANSLATED_KEY_RELEASE,
- GESTURE_SCROLL_BEGIN,
- GESTURE_SCROLL_END,
- GESTURE_SCROLL_UPDATE,
- GESTURE_TAP,
- GESTURE_TAP_DOWN,
- GESTURE_TAP_CANCEL,
- GESTURE_TAP_UNCONFIRMED,
- GESTURE_DOUBLE_TAP,
- GESTURE_BEGIN,
- GESTURE_END,
- GESTURE_TWO_FINGER_TAP,
- GESTURE_PINCH_BEGIN,
- GESTURE_PINCH_END,
- GESTURE_PINCH_UPDATE,
- GESTURE_LONG_PRESS,
- GESTURE_LONG_TAP,
- GESTURE_SWIPE,
- GESTURE_SHOW_PRESS,
- GESTURE_WIN8_EDGE_SWIPE,
- SCROLL,
- SCROLL_FLING_START,
- SCROLL_FLING_CANCEL,
- CANCEL_MODE,
- UMA_DATA
-};
-
-// This mirrors ui::EventFlags
-// TODO(morrita): Use shift operator once it is available.
-enum EventFlags {
- NONE = 0,
- CAPS_LOCK_DOWN = 1,
- SHIFT_DOWN = 2,
- CONTROL_DOWN = 4,
- ALT_DOWN = 8,
- LEFT_MOUSE_BUTTON = 16,
- MIDDLE_MOUSE_BUTTON = 32,
- RIGHT_MOUSE_BUTTON = 64,
- COMMAND_DOWN = 128,
- EXTENDED = 256,
- IS_SYNTHESIZED = 512,
- ALTGR_DOWN = 1024,
- MOD3_DOWN = 2048
-};
-
-enum MouseEventFlags {
- IS_DOUBLE_CLICK = 65536,
- IS_TRIPLE_CLICK = 131072,
- IS_NON_CLIENT = 262144,
-
- // TODO(erg): Move accessibility flags and maybe synthetic touch events here.
-};
diff --git a/mojo/services/input_events/public/interfaces/input_events.mojom b/mojo/services/input_events/public/interfaces/input_events.mojom
deleted file mode 100644
index 1cab579..0000000
--- a/mojo/services/input_events/public/interfaces/input_events.mojom
+++ /dev/null
@@ -1,98 +0,0 @@
-// 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.
-
-module mojo;
-
-import "geometry/public/interfaces/geometry.mojom";
-import "input_events/public/interfaces/input_event_constants.mojom";
-import "input_events/public/interfaces/input_key_codes.mojom";
-
-struct LocationData {
- Point? in_view_location;
- Point? screen_location;
-};
-
-struct KeyData {
- // The chromium event key code; these values are from the ui/ KeyCode enum,
- // which has the fun property of being neither consistently the Windows key
- // code, nor the X11 keycodes. (This value is consistent across platforms
- // for basic ASCII characters; it will differ for modifiers. We don't define
- // this as a mojo enum because mojom doesn't appear to have a platform
- // dependent preprocessor yet.)
- //
- // TODO(erg): Remove this, and declare Win32 keycodes correct by fiat. We can
- // not do this until we remove ui::Event usage from within mojo.
- int32 key_code;
-
- // Whether this is a character event, and the character value if it is. Note
- // that this is different than |text|, which holds a value even when there
- // isn't actually a character to insert. (For example, |text| will be set and
- // have a value on backspace, and |character| won't.)
- bool is_char;
- uint16 character;
-
- // The Win32 key code. Because of the web, this is the closest thing that we
- // have to a cross platform key state.
- KeyboardCode windows_key_code;
-
- // The platform specific key code.
- //
- // TODO(erg): This exists only for NPAPI support, pepper USB keyboard support
- // and IME on android support. Theoretically, we should be able to remove this
- // in the medium to long term.
- int32 native_key_code;
-
- // The text generated by this keystroke. Corresponds to
- // blink::WebKeyboardEvent::text.
- uint16 text;
-
- // Like |text|, but unmodified by concurrently held modifier keys (except
- // shift). Corresponds to blink::WebKeyboardEvent::unmodifiedText.
- uint16 unmodified_text;
-};
-
-struct TouchData {
- int32 pointer_id;
-};
-
-struct GestureData {
- // A bounding box for all the input events that contributed to this gesture.
- RectF? bounding_box;
-
- // GESTURE_SCROLL_UPDATE
- float scroll_x;
- float scroll_y;
-
- // SCROLL_FLING_START
- float velocity_x;
- float velocity_y;
-
- // GESTURE_PINCH_UPDATE
- float scale;
-
- // GESTURE_SWIPE
- bool swipe_left;
- bool swipe_right;
- bool swipe_up;
- bool swipe_down;
-
- // GESTURE_TAP and GESTURE_TAP_UNCONFIRMED and GESTURE_DOUBLE_TAP
- int32 tap_count;
-};
-
-struct MouseWheelData {
- int32 x_offset;
- int32 y_offset;
-};
-
-struct Event {
- EventType action;
- EventFlags flags;
- int64 time_stamp;
- LocationData? location_data;
- KeyData? key_data;
- TouchData? touch_data;
- GestureData? gesture_data;
- MouseWheelData? wheel_data;
-};
diff --git a/mojo/services/input_events/public/interfaces/input_key_codes.mojom b/mojo/services/input_events/public/interfaces/input_key_codes.mojom
deleted file mode 100644
index 695f5bd..0000000
--- a/mojo/services/input_events/public/interfaces/input_key_codes.mojom
+++ /dev/null
@@ -1,186 +0,0 @@
-// 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.
-
-module mojo;
-
-// Cross platform keyboard codes.
-//
-// Because the web has standardized on Win32 keyboard codes, so does mojo.
-enum KeyboardCode {
- BACK = 0x08,
- TAB = 0x09,
- CLEAR = 0x0C,
- RETURN = 0x0D,
- SHIFT = 0x10,
- CONTROL = 0x11,
- MENU = 0x12, // a.k.a. ALT
- PAUSE = 0x13,
- CAPITAL = 0x14,
- KANA = 0x15,
- HANGUL = 0x15,
- JUNJA = 0x17,
- FINAL = 0x18,
- HANJA = 0x19,
- KANJI = 0x19,
- ESCAPE = 0x1B,
- CONVERT = 0x1C,
- NONCONVERT = 0x1D,
- ACCEPT = 0x1E,
- MODECHANGE = 0x1F,
- SPACE = 0x20,
- PRIOR = 0x21,
- NEXT = 0x22,
- END = 0x23,
- HOME = 0x24,
- LEFT = 0x25,
- UP = 0x26,
- RIGHT = 0x27,
- DOWN = 0x28,
- SELECT = 0x29,
- PRINT = 0x2A,
- EXECUTE = 0x2B,
- SNAPSHOT = 0x2C,
- INSERT = 0x2D,
- DELETE = 0x2E,
- HELP = 0x2F,
- NUM_0 = 0x30,
- NUM_1 = 0x31,
- NUM_2 = 0x32,
- NUM_3 = 0x33,
- NUM_4 = 0x34,
- NUM_5 = 0x35,
- NUM_6 = 0x36,
- NUM_7 = 0x37,
- NUM_8 = 0x38,
- NUM_9 = 0x39,
- A = 0x41,
- B = 0x42,
- C = 0x43,
- D = 0x44,
- E = 0x45,
- F = 0x46,
- G = 0x47,
- H = 0x48,
- I = 0x49,
- J = 0x4A,
- K = 0x4B,
- L = 0x4C,
- M = 0x4D,
- N = 0x4E,
- O = 0x4F,
- P = 0x50,
- Q = 0x51,
- R = 0x52,
- S = 0x53,
- T = 0x54,
- U = 0x55,
- V = 0x56,
- W = 0x57,
- X = 0x58,
- Y = 0x59,
- Z = 0x5A,
- LWIN = 0x5B,
- COMMAND = 0x5B, // Provide the Mac name for convenience.
- RWIN = 0x5C,
- APPS = 0x5D,
- SLEEP = 0x5F,
- NUMPAD0 = 0x60,
- NUMPAD1 = 0x61,
- NUMPAD2 = 0x62,
- NUMPAD3 = 0x63,
- NUMPAD4 = 0x64,
- NUMPAD5 = 0x65,
- NUMPAD6 = 0x66,
- NUMPAD7 = 0x67,
- NUMPAD8 = 0x68,
- NUMPAD9 = 0x69,
- MULTIPLY = 0x6A,
- ADD = 0x6B,
- SEPARATOR = 0x6C,
- SUBTRACT = 0x6D,
- DECIMAL = 0x6E,
- DIVIDE = 0x6F,
- F1 = 0x70,
- F2 = 0x71,
- F3 = 0x72,
- F4 = 0x73,
- F5 = 0x74,
- F6 = 0x75,
- F7 = 0x76,
- F8 = 0x77,
- F9 = 0x78,
- F10 = 0x79,
- F11 = 0x7A,
- F12 = 0x7B,
- F13 = 0x7C,
- F14 = 0x7D,
- F15 = 0x7E,
- F16 = 0x7F,
- F17 = 0x80,
- F18 = 0x81,
- F19 = 0x82,
- F20 = 0x83,
- F21 = 0x84,
- F22 = 0x85,
- F23 = 0x86,
- F24 = 0x87,
- NUMLOCK = 0x90,
- SCROLL = 0x91,
- LSHIFT = 0xA0,
- RSHIFT = 0xA1,
- LCONTROL = 0xA2,
- RCONTROL = 0xA3,
- LMENU = 0xA4,
- RMENU = 0xA5,
- BROWSER_BACK = 0xA6,
- BROWSER_FORWARD = 0xA7,
- BROWSER_REFRESH = 0xA8,
- BROWSER_STOP = 0xA9,
- BROWSER_SEARCH = 0xAA,
- BROWSER_FAVORITES = 0xAB,
- BROWSER_HOME = 0xAC,
- VOLUME_MUTE = 0xAD,
- VOLUME_DOWN = 0xAE,
- VOLUME_UP = 0xAF,
- MEDIA_NEXT_TRACK = 0xB0,
- MEDIA_PREV_TRACK = 0xB1,
- MEDIA_STOP = 0xB2,
- MEDIA_PLAY_PAUSE = 0xB3,
- MEDIA_LAUNCH_MAIL = 0xB4,
- MEDIA_LAUNCH_MEDIA_SELECT = 0xB5,
- MEDIA_LAUNCH_APP1 = 0xB6,
- MEDIA_LAUNCH_APP2 = 0xB7,
-
- OEM_1 = 0xBA,
- OEM_PLUS = 0xBB,
- OEM_COMMA = 0xBC,
- OEM_MINUS = 0xBD,
- OEM_PERIOD = 0xBE,
- OEM_2 = 0xBF,
- OEM_3 = 0xC0,
- OEM_4 = 0xDB,
- OEM_5 = 0xDC,
- OEM_6 = 0xDD,
- OEM_7 = 0xDE,
- OEM_8 = 0xDF,
- OEM_102 = 0xE2,
- PROCESSKEY = 0xE5,
- PACKET = 0xE7,
- DBE_SBCSCHAR = 0xF3,
- DBE_DBCSCHAR = 0xF4,
- ATTN = 0xF6,
- CRSEL = 0xF7,
- EXSEL = 0xF8,
- EREOF = 0xF9,
- PLAY = 0xFA,
- ZOOM = 0xFB,
- NONAME = 0xFC,
- PA1 = 0xFD,
- OEM_CLEAR = 0xFE,
- UNKNOWN = 0,
-
- // Windows does not have a specific key code for AltGr. We use the unused
- // VK_OEM_AX to represent AltGr, matching the behaviour of Firefox on Linux.
- ALTGR = 0xE1,
-};
diff --git a/mojo/services/native_viewport/public/cpp/args.h b/mojo/services/native_viewport/public/cpp/args.h
deleted file mode 100644
index 2bad98d..0000000
--- a/mojo/services/native_viewport/public/cpp/args.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_NATIVE_VIEWPORT_PUBLIC_CPP_ARGS_H_
-#define MOJO_SERVICES_NATIVE_VIEWPORT_PUBLIC_CPP_ARGS_H_
-
-namespace mojo {
-
-// All args in alphabetical order. The switches should be documented
-// alongside the definition of their values in the .cc file.
-extern const char kUseHeadlessConfig[];
-extern const char kUseOSMesa[];
-extern const char kUseTestConfig[];
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_NATIVE_VIEWPORT_PUBLIC_CPP_ARGS_H_
diff --git a/mojo/services/native_viewport/public/cpp/lib/args.cc b/mojo/services/native_viewport/public/cpp/lib/args.cc
deleted file mode 100644
index 25ee1ae..0000000
--- a/mojo/services/native_viewport/public/cpp/lib/args.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-// 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 "native_viewport/public/cpp/args.h"
-
-namespace mojo {
-
-// Instead of using the system GL implementation, use OSMesa.
-const char kUseOSMesa[] = "--use-osmesa";
-// Loads an app from the specified directory and launches it.
-// Force gl to be initialized in test mode.
-const char kUseTestConfig[] = "--use-test-config";
-// Create native viewport in headless mode.
-const char kUseHeadlessConfig[] = "--use-headless-config";
-
-} // namespace mojo
diff --git a/mojo/services/native_viewport/public/interfaces/native_viewport.mojom b/mojo/services/native_viewport/public/interfaces/native_viewport.mojom
deleted file mode 100644
index 75757c2..0000000
--- a/mojo/services/native_viewport/public/interfaces/native_viewport.mojom
+++ /dev/null
@@ -1,39 +0,0 @@
-// 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.
-
-module mojo;
-
-import "geometry/public/interfaces/geometry.mojom";
-import "gpu/public/interfaces/command_buffer.mojom";
-import "input_events/public/interfaces/input_events.mojom";
-import "surfaces/public/interfaces/surface_id.mojom";
-
-struct ViewportMetrics {
- Size size;
- float device_pixel_ratio = 1.0;
-};
-
-interface NativeViewport {
- // TODO(sky): having a create function is awkward. Should there be a factory
- // to create the NativeViewport that takes the size?
- Create(Size size) => (uint64 native_viewport_id, ViewportMetrics metrics);
-
- Show();
- Hide();
- Close();
- SetSize(Size size);
- SubmittedFrame(SurfaceId surface_id);
- SetEventDispatcher(NativeViewportEventDispatcher dispatcher);
-
- // The initial viewport metrics will be sent in the reply to the Create
- // method. Call RequestMetrics() to receive updates when the viewport metrics
- // change. The reply will be sent when the viewport metrics are different from
- // the values last sent, so to receive continuous updates call this method
- // again after receiving the callback.
- RequestMetrics() => (ViewportMetrics metrics);
-};
-
-interface NativeViewportEventDispatcher {
- OnEvent(Event event) => ();
-};
diff --git a/mojo/services/navigation/public/interfaces/navigation.mojom b/mojo/services/navigation/public/interfaces/navigation.mojom
deleted file mode 100644
index 0d2656a..0000000
--- a/mojo/services/navigation/public/interfaces/navigation.mojom
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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.
-
-module mojo;
-
-import "network/public/interfaces/url_loader.mojom";
-
-// Expresses a preference for where a navigation will be performed.
-enum Target {
- // No preference
- DEFAULT,
-
- // In the same ViewManager node that the navigation was initiated
- SOURCE_NODE,
-
- // In a new ViewManager node
- NEW_NODE
-};
-
-// Embedders that support navigation of implement this interface.
-interface NavigatorHost {
- RequestNavigate(Target target, URLRequest request);
-
- // Applications call this to inform hosts of navigations they performed
- // locally. For example, pushState() navigations in an HTML application.
- DidNavigateLocally(string url);
-};
diff --git a/mojo/services/public/js/application.js b/mojo/services/public/js/application.js
deleted file mode 100644
index d4aa1e6..0000000
--- a/mojo/services/public/js/application.js
+++ /dev/null
@@ -1,74 +0,0 @@
-// 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.
-
-define("mojo/services/public/js/application", [
- "mojo/public/js/bindings",
- "mojo/public/js/core",
- "mojo/public/js/connection",
- "mojo/public/js/threading",
- "mojo/public/interfaces/application/application.mojom",
- "mojo/services/public/js/service_provider",
- "mojo/services/public/js/shell",
-], function(bindings, core, connection, threading, applicationMojom, serviceProvider, shell) {
-
- const ApplicationInterface = applicationMojom.Application;
- const ProxyBindings = bindings.ProxyBindings;
- const ServiceProvider = serviceProvider.ServiceProvider;
- const Shell = shell.Shell;
-
- class Application {
- constructor(appRequestHandle, url) {
- this.url = url;
- this.serviceProviders = [];
- this.exposedServiceProviders = [];
- this.appRequestHandle_ = appRequestHandle;
- this.appStub_ =
- connection.bindHandleToStub(appRequestHandle, ApplicationInterface);
- bindings.StubBindings(this.appStub_).delegate = {
- initialize: this.doInitialize.bind(this),
- acceptConnection: this.doAcceptConnection.bind(this),
- };
- }
-
- doInitialize(shellProxy, args) {
- this.shellProxy_ = shellProxy;
- this.shell = new Shell(shellProxy);
- this.initialize(args);
- }
-
- initialize(args) {}
-
- // The mojom signature of this function is:
- // AcceptConnection(string requestor_url,
- // ServiceProvider&? services,
- // ServiceProvider? exposed_services);
- //
- // We want to bind |services| to our js implementation of ServiceProvider
- // and store |exposed_services| so we can request services of the connecting
- // application.
- doAcceptConnection(requestorUrl, servicesRequest, exposedServicesProxy) {
- // Construct a new js ServiceProvider that can make outgoing calls on
- // exposedServicesProxy.
- var serviceProvider =
- new ServiceProvider(servicesRequest, exposedServicesProxy);
- this.serviceProviders.push(serviceProvider);
- this.acceptConnection(requestorUrl, serviceProvider);
- }
-
- acceptConnection(requestorUrl, serviceProvider) {}
-
- quit() {
- this.serviceProviders.forEach(function(sp) {
- sp.close();
- });
- this.shell.close();
- core.close(this.appRequestHandle_);
- threading.quit();
- }
- }
-
- var exports = {};
- exports.Application = Application;
- return exports;
-});
diff --git a/mojo/services/public/js/service_provider.js b/mojo/services/public/js/service_provider.js
deleted file mode 100644
index a6a81ca..0000000
--- a/mojo/services/public/js/service_provider.js
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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.
-
-define("mojo/services/public/js/service_provider", [
- "mojo/public/js/bindings",
- "mojo/public/interfaces/application/service_provider.mojom",
- "mojo/public/js/connection",
-], function(bindings, spMojom, connection) {
-
- const ProxyBindings = bindings.ProxyBindings;
- const StubBindings = bindings.StubBindings;
- const ServiceProviderInterface = spMojom.ServiceProvider;
-
- function checkServiceProvider(sp) {
- if (!sp.providers_)
- throw new Error("Service was closed");
- }
-
- class ServiceProvider {
- constructor(servicesRequest, exposedServicesProxy) {
- this.proxy = exposedServicesProxy;
- this.providers_ = new Map(); // serviceName => see provideService() below
- this.pendingRequests_ = new Map(); // serviceName => serviceHandle
- if (servicesRequest)
- StubBindings(servicesRequest).delegate = this;
- }
-
- // Incoming requests
- connectToService(serviceName, serviceHandle) {
- if (!this.providers_) // We're closed.
- return;
-
- var provider = this.providers_.get(serviceName);
- if (!provider) {
- this.pendingRequests_.set(serviceName, serviceHandle);
- return;
- }
-
- var stub = connection.bindHandleToStub(serviceHandle, provider.service);
- StubBindings(stub).delegate = new provider.factory();
- provider.connections.push(StubBindings(stub).connection);
- }
-
- provideService(service, factory) {
- checkServiceProvider(this);
-
- var provider = {
- service: service, // A JS bindings interface object.
- factory: factory, // factory(clientProxy) => interface implemntation
- connections: [],
- };
- this.providers_.set(service.name, provider);
-
- if (this.pendingRequests_.has(service.name)) {
- this.connectToService(service.name, pendingRequests_.get(service.name));
- pendingRequests_.delete(service.name);
- }
- return this;
- }
-
- // Outgoing requests
- requestService(interfaceObject, clientImpl) {
- checkServiceProvider(this);
- if (!interfaceObject.name)
- throw new Error("Invalid service parameter");
- if (!clientImpl && interfaceObject.client)
- throw new Error("Client implementation must be provided");
-
- var serviceProxy;
- var serviceHandle = connection.bindProxy(
- function(sp) {serviceProxy = sp;}, interfaceObject);
- this.proxy.connectToService(interfaceObject.name, serviceHandle);
- return serviceProxy;
- };
-
- close() {
- this.providers_ = null;
- this.pendingRequests_ = null;
- }
- }
-
- var exports = {};
- exports.ServiceProvider = ServiceProvider;
- return exports;
-});
diff --git a/mojo/services/public/js/shell.js b/mojo/services/public/js/shell.js
deleted file mode 100644
index e6c2dee..0000000
--- a/mojo/services/public/js/shell.js
+++ /dev/null
@@ -1,57 +0,0 @@
-// 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.
-
-define("mojo/services/public/js/shell", [
- "mojo/public/js/bindings",
- "mojo/public/js/core",
- "mojo/public/js/connection",
- "mojo/public/interfaces/application/shell.mojom",
- "mojo/public/interfaces/application/service_provider.mojom",
- "mojo/services/public/js/service_provider","console",
-], function(bindings, core, connection, shellMojom, spMojom, sp, console) {
-
- const ProxyBindings = bindings.ProxyBindings;
- const StubBindings = bindings.StubBindings;
- const ServiceProvider = sp.ServiceProvider;
- const ServiceProviderInterface = spMojom.ServiceProvider;
- const ShellInterface = shellMojom.Shell;
-
- class Shell {
- constructor(shellProxy) {
- this.shellProxy = shellProxy;
- this.applications_ = new Map();
- }
-
- connectToApplication(url) {
- var application = this.applications_.get(url);
- if (application)
- return application;
-
- var application = new ServiceProvider();
- this.shellProxy.connectToApplication(url,
- function(services) {
- application.proxy = services;
- },
- application);
- this.applications_.set(url, application);
- return application;
- }
-
- connectToService(url, service, client) {
- return this.connectToApplication(url).requestService(service, client);
- };
-
- close() {
- this.applications_.forEach(function(application, url) {
- application.close();
- });
- ProxyBindings(this.shellProxy).close();
- this.applications_.clear();
- }
- }
-
- var exports = {};
- exports.Shell = Shell;
- return exports;
-});
diff --git a/mojo/services/surfaces/public/cpp/surfaces_utils.cc b/mojo/services/surfaces/public/cpp/surfaces_utils.cc
deleted file mode 100644
index 2e52fd2..0000000
--- a/mojo/services/surfaces/public/cpp/surfaces_utils.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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 "surfaces/public/cpp/surfaces_utils.h"
-
-#include "geometry/public/interfaces/geometry.mojom.h"
-
-namespace mojo {
-
-namespace {
-TransformPtr GetIdentityTransform() {
- TransformPtr transform(Transform::New());
- transform->matrix.resize(16);
- transform->matrix[0] = 1.f;
- transform->matrix[5] = 1.f;
- transform->matrix[10] = 1.f;
- transform->matrix[15] = 1.f;
- return transform.Pass();
-}
-}
-
-SharedQuadStatePtr CreateDefaultSQS(const Size& size) {
- SharedQuadStatePtr sqs = SharedQuadState::New();
- sqs->content_to_target_transform = GetIdentityTransform();
- sqs->content_bounds = size.Clone();
- Rect rect;
- rect.width = size.width;
- rect.height = size.height;
- sqs->visible_content_rect = rect.Clone();
- sqs->clip_rect = rect.Clone();
- sqs->is_clipped = false;
- sqs->opacity = 1.f;
- sqs->blend_mode = mojo::SK_XFERMODE_kSrc_Mode;
- sqs->sorting_context_id = 0;
- return sqs.Pass();
-}
-
-PassPtr CreateDefaultPass(int id, const Rect& rect) {
- PassPtr pass = Pass::New();
- pass->id = id;
- pass->output_rect = rect.Clone();
- pass->damage_rect = rect.Clone();
- pass->transform_to_root_target = GetIdentityTransform();
- pass->has_transparent_background = false;
- return pass.Pass();
-}
-
-} // namespace mojo
diff --git a/mojo/services/surfaces/public/cpp/surfaces_utils.h b/mojo/services/surfaces/public/cpp/surfaces_utils.h
deleted file mode 100644
index f74731e..0000000
--- a/mojo/services/surfaces/public/cpp/surfaces_utils.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_SURFACES_PUBLIC_CPP_SURFACES_UTILS_H_
-#define MOJO_SERVICES_SURFACES_PUBLIC_CPP_SURFACES_UTILS_H_
-
-#include "surfaces/public/interfaces/quads.mojom.h"
-
-namespace mojo {
-class Rect;
-class Size;
-
-SharedQuadStatePtr CreateDefaultSQS(const Size& size);
-
-// Constructs a pass with the given id, output_rect and damage_rect set to rect,
-// transform_to_root_target set to identity and has_transparent_background set
-// to false.
-PassPtr CreateDefaultPass(int id, const Rect& rect);
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_SURFACES_PUBLIC_CPP_SURFACES_UTILS_H_
diff --git a/mojo/services/surfaces/public/interfaces/quads.mojom b/mojo/services/surfaces/public/interfaces/quads.mojom
deleted file mode 100644
index 58f85e0..0000000
--- a/mojo/services/surfaces/public/interfaces/quads.mojom
+++ /dev/null
@@ -1,211 +0,0 @@
-// 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.
-
-module mojo;
-
-import "geometry/public/interfaces/geometry.mojom";
-import "surfaces/public/interfaces/surface_id.mojom";
-
-struct Color {
- uint32 rgba;
-};
-
-// TODO(jamesr): Populate subtype fields.
-struct CheckerboardQuadState {};
-
-struct DebugBorderQuadState {};
-
-struct IoSurfaceContentQuadState {};
-
-struct RenderPassId {
- int32 layer_id;
- int32 index;
-};
-
-struct RenderPassQuadState {
- RenderPassId render_pass_id;
-
- // If nonzero, resource id of mask to use when drawing this pass.
- uint32 mask_resource_id;
- PointF mask_uv_scale;
- Size mask_texture_size;
-
- // Post-processing filters, applied to the pixels in the render pass' texture.
- // TODO(jamesr): Support
- // FilterOperations filters;
-
- // The scale from layer space of the root layer of the render pass to
- // the render pass physical pixels. This scale is applied to the filter
- // parameters for pixel-moving filters. This scale should include
- // content-to-target-space scale, and device pixel ratio.
- PointF filters_scale;
-
- // Post-processing filters, applied to the pixels showing through the
- // background of the render pass, from behind it.
- // TODO(jamesr): Support
- // FilterOperations background_filters;
-};
-
-struct SolidColorQuadState {
- Color color;
- bool force_anti_aliasing_off;
-};
-
-struct SurfaceQuadState {
- SurfaceId surface;
-};
-
-struct TextureQuadState {
- uint32 resource_id;
- bool premultiplied_alpha;
- PointF uv_top_left;
- PointF uv_bottom_right;
- Color background_color;
- array<float, 4> vertex_opacity;
- bool flipped;
- bool nearest_neighbor;
-};
-
-struct TileQuadState {
- RectF tex_coord_rect;
- Size texture_size;
- bool swizzle_contents;
- uint32 resource_id;
- bool nearest_neighbor;
-};
-
-struct StreamVideoQuadState {};
-
-enum YUVColorSpace {
- REC_601, // SDTV standard with restricted "studio swing" color range.
- REC_601_JPEG, // Full color range [0, 255] variant of the above.
-};
-
-struct YUVVideoQuadState {
- RectF tex_coord_rect;
- uint32 y_plane_resource_id;
- uint32 u_plane_resource_id;
- uint32 v_plane_resource_id;
- uint32 a_plane_resource_id;
- YUVColorSpace color_space;
-};
-
-enum Material {
- CHECKERBOARD = 1,
- DEBUG_BORDER,
- IO_SURFACE_CONTENT,
- PICTURE_CONTENT,
- RENDER_PASS,
- SOLID_COLOR,
- STREAM_VIDEO_CONTENT,
- SURFACE_CONTENT,
- TEXTURE_CONTENT,
- TILED_CONTENT,
- YUV_VIDEO_CONTENT,
-};
-
-struct Quad {
- Material material;
-
- // This rect, after applying the quad_transform(), gives the geometry that
- // this quad should draw to. This rect lives in content space.
- Rect rect;
-
- // This specifies the region of the quad that is opaque. This rect lives in
- // content space.
- Rect opaque_rect;
-
- // Allows changing the rect that gets drawn to make it smaller. This value
- // should be clipped to |rect|. This rect lives in content space.
- Rect visible_rect;
-
- // Allows changing the rect that gets drawn to make it smaller. This value
- // should be clipped to |rect|. This rect lives in content space.
- bool needs_blending;
-
- // Index into the containing pass' shared quad state array which has state
- // (transforms etc) shared by multiple quads.
- uint32 shared_quad_state_index;
-
- // Only one of the following will be set, depending on the material.
- CheckerboardQuadState? checkerboard_quad_state;
- DebugBorderQuadState? debug_border_quad_state;
- IoSurfaceContentQuadState? io_surface_quad_state;
- RenderPassQuadState? render_pass_quad_state;
- SolidColorQuadState? solid_color_quad_state;
- SurfaceQuadState? surface_quad_state;
- TextureQuadState? texture_quad_state;
- TileQuadState? tile_quad_state;
- StreamVideoQuadState? stream_video_quad_state;
- YUVVideoQuadState? yuv_video_quad_state;
-};
-
-enum SkXfermode {
- kClear_Mode = 0, //!< [0, 0]
- kSrc_Mode, //!< [Sa, Sc]
- kDst_Mode, //!< [Da, Dc]
- kSrcOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Sc + (1 - Sa)*Dc]
- kDstOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Dc + (1 - Da)*Sc]
- kSrcIn_Mode, //!< [Sa * Da, Sc * Da]
- kDstIn_Mode, //!< [Sa * Da, Sa * Dc]
- kSrcOut_Mode, //!< [Sa * (1 - Da), Sc * (1 - Da)]
- kDstOut_Mode, //!< [Da * (1 - Sa), Dc * (1 - Sa)]
- kSrcATop_Mode, //!< [Da, Sc * Da + (1 - Sa) * Dc]
- kDstATop_Mode, //!< [Sa, Sa * Dc + Sc * (1 - Da)]
- kXor_Mode, //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc]
- kPlus_Mode, //!< [Sa + Da, Sc + Dc]
- kModulate_Mode, // multiplies all components (= alpha and color)
-
- // Following blend modes are defined in the CSS Compositing standard:
- // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blending
- kScreen_Mode,
- kLastCoeffMode = kScreen_Mode,
-
- kOverlay_Mode,
- kDarken_Mode,
- kLighten_Mode,
- kColorDodge_Mode,
- kColorBurn_Mode,
- kHardLight_Mode,
- kSoftLight_Mode,
- kDifference_Mode,
- kExclusion_Mode,
- kMultiply_Mode,
- kLastSeparableMode = kMultiply_Mode,
-
- kHue_Mode,
- kSaturation_Mode,
- kColor_Mode,
- kLuminosity_Mode,
- kLastMode = kLuminosity_Mode
-};
-
-struct SharedQuadState {
- // Transforms from quad's original content space to its target content space.
- Transform content_to_target_transform;
-
- // This size lives in the content space for the quad's originating layer.
- Size content_bounds;
-
- // This rect lives in the content space for the quad's originating layer.
- Rect visible_content_rect;
-
- // This rect lives in the target content space.
- Rect clip_rect;
-
- bool is_clipped;
- float opacity;
- SkXfermode blend_mode;
- int32 sorting_context_id;
-};
-
-struct Pass {
- int32 id;
- Rect output_rect;
- Rect damage_rect;
- Transform transform_to_root_target;
- bool has_transparent_background;
- array<Quad> quads;
- array<SharedQuadState> shared_quad_states;
-};
diff --git a/mojo/services/surfaces/public/interfaces/surface_id.mojom b/mojo/services/surfaces/public/interfaces/surface_id.mojom
deleted file mode 100644
index 197e6f8..0000000
--- a/mojo/services/surfaces/public/interfaces/surface_id.mojom
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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.
-
-module mojo;
-
-// A surface ID is composed of two parts, a local part and a namespace. The
-// local part is allocated by the client using any scheme that avoids
-// duplicates. The namespace is allocated by the service and will be different
-// for each client (aka each connection to mojo.Surface).
-//
-// The special id_namespace value 0 is equivalent to the namespace of the
-// client. This can be used to create, destroy and submit frames to
-// surfaces before learning the namespace and to reference other surfaces
-// owned by the same client. The actual id namespace must be used to pass
-// surface ids to other clients for them to reference.
-struct SurfaceId {
- uint32 local;
- uint32 id_namespace;
-};
diff --git a/mojo/services/surfaces/public/interfaces/surfaces.mojom b/mojo/services/surfaces/public/interfaces/surfaces.mojom
deleted file mode 100644
index 7badcd3..0000000
--- a/mojo/services/surfaces/public/interfaces/surfaces.mojom
+++ /dev/null
@@ -1,77 +0,0 @@
-// 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.
-
-module mojo;
-
-import "geometry/public/interfaces/geometry.mojom";
-import "gpu/public/interfaces/command_buffer.mojom";
-import "gpu/public/interfaces/viewport_parameter_listener.mojom";
-import "surfaces/public/interfaces/quads.mojom";
-import "surfaces/public/interfaces/surface_id.mojom";
-
-enum ResourceFormat {
- RGBA_8888,
- RGBA_4444,
- BGRA_8888,
- ALPHA_8,
- LUMINANCE_8,
- RGB_565,
- ETC1,
-};
-
-struct Mailbox {
- array<int8, 64> name;
-};
-
-struct MailboxHolder {
- Mailbox mailbox;
- uint32 texture_target;
- uint32 sync_point;
-};
-
-struct TransferableResource {
- uint32 id;
- ResourceFormat format;
- uint32 filter;
- Size size;
- MailboxHolder mailbox_holder;
- bool is_repeated;
- bool is_software;
-};
-
-struct ReturnedResource {
- uint32 id;
- uint32 sync_point;
- int32 count;
- bool lost;
-};
-
-struct Frame {
- array<TransferableResource> resources;
- array<Pass> passes;
-};
-
-interface SurfaceClient {
- // This sets the id namespace for this connection. This method will be invoked
- // exactly once when a new connection is established.
- SetIdNamespace(uint32 id_namespace);
- ReturnResources(array<ReturnedResource> resources);
-};
-
-[Client=SurfaceClient]
-interface Surface {
- CreateSurface(uint32 id_local);
-
- // The client can only submit frames to surfaces created with this
- // connection. After the submitted frame is drawn for the first time, the
- // surface will respond to the SubmitFrame message. Clients should use this
- // acknowledgement to ratelimit frame submissions.
- SubmitFrame(uint32 id_local, Frame frame) => ();
- DestroySurface(uint32 id_local);
-
- CreateGLES2BoundSurface(CommandBuffer gles2_client,
- uint32 id_local,
- Size size,
- ViewportParameterListener& listener);
-};
diff --git a/mojo/services/surfaces/public/interfaces/surfaces_service.mojom b/mojo/services/surfaces/public/interfaces/surfaces_service.mojom
deleted file mode 100644
index e1ca690..0000000
--- a/mojo/services/surfaces/public/interfaces/surfaces_service.mojom
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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.
-
-module mojo;
-
-import "surfaces/public/interfaces/surfaces.mojom";
-
-// Use this interface to request connections to the surfaces service. Each
-// connection is associated with an id namespace
-interface SurfacesService {
- // DEPRECATED: Just connect to mojo.Surface directly and receive the id
- // namespace via SetIdNamespace.
- CreateSurfaceConnection() => (Surface surface, uint32 id_namespace);
-};
diff --git a/mojo/services/view_manager/public/cpp/lib/view.cc b/mojo/services/view_manager/public/cpp/lib/view.cc
deleted file mode 100644
index f7e7784..0000000
--- a/mojo/services/view_manager/public/cpp/lib/view.cc
+++ /dev/null
@@ -1,575 +0,0 @@
-// 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 "view_manager/public/cpp/view.h"
-
-#include <set>
-#include <string>
-
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "view_manager/public/cpp/lib/view_manager_client_impl.h"
-#include "view_manager/public/cpp/lib/view_private.h"
-#include "view_manager/public/cpp/view_observer.h"
-#include "view_manager/public/cpp/view_tracker.h"
-
-namespace mojo {
-
-namespace {
-
-void NotifyViewTreeChangeAtReceiver(
- View* receiver,
- const ViewObserver::TreeChangeParams& params,
- bool change_applied) {
- ViewObserver::TreeChangeParams local_params = params;
- local_params.receiver = receiver;
- if (change_applied) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(receiver).observers(),
- OnTreeChanged(local_params));
- } else {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(receiver).observers(),
- OnTreeChanging(local_params));
- }
-}
-
-void NotifyViewTreeChangeUp(
- View* start_at,
- const ViewObserver::TreeChangeParams& params,
- bool change_applied) {
- for (View* current = start_at; current; current = current->parent())
- NotifyViewTreeChangeAtReceiver(current, params, change_applied);
-}
-
-void NotifyViewTreeChangeDown(
- View* start_at,
- const ViewObserver::TreeChangeParams& params,
- bool change_applied) {
- NotifyViewTreeChangeAtReceiver(start_at, params, change_applied);
- View::Children::const_iterator it = start_at->children().begin();
- for (; it != start_at->children().end(); ++it)
- NotifyViewTreeChangeDown(*it, params, change_applied);
-}
-
-void NotifyViewTreeChange(
- const ViewObserver::TreeChangeParams& params,
- bool change_applied) {
- NotifyViewTreeChangeDown(params.target, params, change_applied);
- if (params.old_parent)
- NotifyViewTreeChangeUp(params.old_parent, params, change_applied);
- if (params.new_parent)
- NotifyViewTreeChangeUp(params.new_parent, params, change_applied);
-}
-
-class ScopedTreeNotifier {
- public:
- ScopedTreeNotifier(View* target, View* old_parent, View* new_parent) {
- params_.target = target;
- params_.old_parent = old_parent;
- params_.new_parent = new_parent;
- NotifyViewTreeChange(params_, false);
- }
- ~ScopedTreeNotifier() {
- NotifyViewTreeChange(params_, true);
- }
-
- private:
- ViewObserver::TreeChangeParams params_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedTreeNotifier);
-};
-
-void RemoveChildImpl(View* child, View::Children* children) {
- View::Children::iterator it =
- std::find(children->begin(), children->end(), child);
- if (it != children->end()) {
- children->erase(it);
- ViewPrivate(child).ClearParent();
- }
-}
-
-class ScopedOrderChangedNotifier {
- public:
- ScopedOrderChangedNotifier(View* view,
- View* relative_view,
- OrderDirection direction)
- : view_(view),
- relative_view_(relative_view),
- direction_(direction) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(view_).observers(),
- OnViewReordering(view_, relative_view_, direction_));
- }
- ~ScopedOrderChangedNotifier() {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(view_).observers(),
- OnViewReordered(view_, relative_view_, direction_));
- }
-
- private:
- View* view_;
- View* relative_view_;
- OrderDirection direction_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedOrderChangedNotifier);
-};
-
-// Returns true if the order actually changed.
-bool ReorderImpl(View::Children* children,
- View* view,
- View* relative,
- OrderDirection direction) {
- DCHECK(relative);
- DCHECK_NE(view, relative);
- DCHECK_EQ(view->parent(), relative->parent());
-
- const size_t child_i =
- std::find(children->begin(), children->end(), view) - children->begin();
- const size_t target_i =
- std::find(children->begin(), children->end(), relative) -
- children->begin();
- if ((direction == ORDER_DIRECTION_ABOVE && child_i == target_i + 1) ||
- (direction == ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) {
- return false;
- }
-
- ScopedOrderChangedNotifier notifier(view, relative, direction);
-
- const size_t dest_i = direction == ORDER_DIRECTION_ABOVE
- ? (child_i < target_i ? target_i : target_i + 1)
- : (child_i < target_i ? target_i - 1 : target_i);
- children->erase(children->begin() + child_i);
- children->insert(children->begin() + dest_i, view);
-
- return true;
-}
-
-class ScopedSetBoundsNotifier {
- public:
- ScopedSetBoundsNotifier(View* view,
- const Rect& old_bounds,
- const Rect& new_bounds)
- : view_(view),
- old_bounds_(old_bounds),
- new_bounds_(new_bounds) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(view_).observers(),
- OnViewBoundsChanging(view_, old_bounds_, new_bounds_));
- }
- ~ScopedSetBoundsNotifier() {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(view_).observers(),
- OnViewBoundsChanged(view_, old_bounds_, new_bounds_));
- }
-
- private:
- View* view_;
- const Rect old_bounds_;
- const Rect new_bounds_;
-
- DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier);
-};
-
-// Some operations are only permitted in the connection that created the view.
-bool OwnsView(ViewManager* manager, View* view) {
- return !manager ||
- static_cast<ViewManagerClientImpl*>(manager)->OwnsView(view->id());
-}
-
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// View, public:
-
-void View::Destroy() {
- if (!OwnsView(manager_, this))
- return;
-
- if (manager_)
- static_cast<ViewManagerClientImpl*>(manager_)->DestroyView(id_);
- while (!children_.empty()) {
- View* child = children_.front();
- if (!OwnsView(manager_, child)) {
- ViewPrivate(child).ClearParent();
- children_.erase(children_.begin());
- } else {
- child->Destroy();
- DCHECK(std::find(children_.begin(), children_.end(), child) ==
- children_.end());
- }
- }
- LocalDestroy();
-}
-
-void View::SetBounds(const Rect& bounds) {
- if (!OwnsView(manager_, this))
- return;
-
- if (bounds_.Equals(bounds))
- return;
-
- if (manager_)
- static_cast<ViewManagerClientImpl*>(manager_)->SetBounds(id_, bounds);
- LocalSetBounds(bounds_, bounds);
-}
-
-void View::SetVisible(bool value) {
- if (visible_ == value)
- return;
-
- if (manager_)
- static_cast<ViewManagerClientImpl*>(manager_)->SetVisible(id_, value);
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanging(this));
- visible_ = value;
- NotifyViewVisibilityChanged(this);
-}
-
-void View::SetSharedProperty(const std::string& name,
- const std::vector<uint8_t>* value) {
- std::vector<uint8_t> old_value;
- std::vector<uint8_t>* old_value_ptr = nullptr;
- auto it = properties_.find(name);
- if (it != properties_.end()) {
- old_value = it->second;
- old_value_ptr = &old_value;
-
- if (value && old_value == *value)
- return;
- } else if (!value) {
- // This property isn't set in |properties_| and |value| is NULL, so there's
- // no change.
- return;
- }
-
- if (value) {
- properties_[name] = *value;
- } else if (it != properties_.end()) {
- properties_.erase(it);
- }
-
- // TODO: add test coverage of this (450303).
- if (manager_) {
- Array<uint8_t> transport_value;
- if (value) {
- transport_value.resize(value->size());
- if (value->size())
- memcpy(&transport_value.front(), &(value->front()), value->size());
- }
- static_cast<ViewManagerClientImpl*>(manager_)->SetProperty(
- id_, name, transport_value.Pass());
- }
-
- FOR_EACH_OBSERVER(
- ViewObserver, observers_,
- OnViewSharedPropertyChanged(this, name, old_value_ptr, value));
-}
-
-bool View::IsDrawn() const {
- if (!visible_)
- return false;
- return parent_ ? parent_->IsDrawn() : drawn_;
-}
-
-void View::AddObserver(ViewObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void View::RemoveObserver(ViewObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
-const View* View::GetRoot() const {
- const View* root = this;
- for (const View* parent = this; parent; parent = parent->parent())
- root = parent;
- return root;
-}
-
-void View::AddChild(View* child) {
- // TODO(beng): not necessarily valid to all connections, but possibly to the
- // embeddee in an embedder-embeddee relationship.
- if (manager_)
- CHECK_EQ(child->view_manager(), manager_);
- LocalAddChild(child);
- if (manager_)
- static_cast<ViewManagerClientImpl*>(manager_)->AddChild(child->id(), id_);
-}
-
-void View::RemoveChild(View* child) {
- // TODO(beng): not necessarily valid to all connections, but possibly to the
- // embeddee in an embedder-embeddee relationship.
- if (manager_)
- CHECK_EQ(child->view_manager(), manager_);
- LocalRemoveChild(child);
- if (manager_) {
- static_cast<ViewManagerClientImpl*>(manager_)->RemoveChild(child->id(),
- id_);
- }
-}
-
-void View::MoveToFront() {
- if (!parent_ || parent_->children_.back() == this)
- return;
- Reorder(parent_->children_.back(), ORDER_DIRECTION_ABOVE);
-}
-
-void View::MoveToBack() {
- if (!parent_ || parent_->children_.front() == this)
- return;
- Reorder(parent_->children_.front(), ORDER_DIRECTION_BELOW);
-}
-
-void View::Reorder(View* relative, OrderDirection direction) {
- if (!LocalReorder(relative, direction))
- return;
- if (manager_) {
- static_cast<ViewManagerClientImpl*>(manager_)->Reorder(id_,
- relative->id(),
- direction);
- }
-}
-
-bool View::Contains(View* child) const {
- if (!child)
- return false;
- if (child == this)
- return true;
- if (manager_)
- CHECK_EQ(child->view_manager(), manager_);
- for (View* p = child->parent(); p; p = p->parent()) {
- if (p == this)
- return true;
- }
- return false;
-}
-
-View* View::GetChildById(Id id) {
- if (id == id_)
- return this;
- // TODO(beng): this could be improved depending on how we decide to own views.
- Children::const_iterator it = children_.begin();
- for (; it != children_.end(); ++it) {
- View* view = (*it)->GetChildById(id);
- if (view)
- return view;
- }
- return NULL;
-}
-
-void View::SetSurfaceId(SurfaceIdPtr id) {
- if (manager_) {
- static_cast<ViewManagerClientImpl*>(manager_)->SetSurfaceId(id_, id.Pass());
- }
-}
-
-void View::SetFocus() {
- if (manager_)
- static_cast<ViewManagerClientImpl*>(manager_)->SetFocus(id_);
-}
-
-void View::Embed(const String& url) {
- static_cast<ViewManagerClientImpl*>(manager_)->Embed(url, id_);
-}
-
-void View::Embed(const String& url,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) {
- static_cast<ViewManagerClientImpl*>(manager_)
- ->Embed(url, id_, services.Pass(), exposed_services.Pass());
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// View, protected:
-
-namespace {
-
-ViewportMetricsPtr CreateEmptyViewportMetrics() {
- ViewportMetricsPtr metrics = ViewportMetrics::New();
- metrics->size = Size::New();
- return metrics;
-}
-}
-
-View::View()
- : manager_(NULL),
- id_(static_cast<Id>(-1)),
- parent_(NULL),
- viewport_metrics_(CreateEmptyViewportMetrics()),
- visible_(true),
- drawn_(false) {
-}
-
-View::~View() {
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroying(this));
- if (parent_)
- parent_->LocalRemoveChild(this);
-
- // We may still have children. This can happen if the embedder destroys the
- // root while we're still alive.
- while (!children_.empty()) {
- View* child = children_.front();
- LocalRemoveChild(child);
- DCHECK(children_.empty() || children_.front() != child);
- }
-
- // TODO(beng): It'd be better to do this via a destruction observer in the
- // ViewManagerClientImpl.
- if (manager_)
- static_cast<ViewManagerClientImpl*>(manager_)->RemoveView(id_);
-
- // Clear properties.
- for (auto& pair : prop_map_) {
- if (pair.second.deallocator)
- (*pair.second.deallocator)(pair.second.value);
- }
- prop_map_.clear();
-
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroyed(this));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// View, private:
-
-View::View(ViewManager* manager, Id id)
- : manager_(manager),
- id_(id),
- parent_(nullptr),
- viewport_metrics_(CreateEmptyViewportMetrics()),
- visible_(false),
- drawn_(false) {
-}
-
-int64 View::SetLocalPropertyInternal(const void* key,
- const char* name,
- PropertyDeallocator deallocator,
- int64 value,
- int64 default_value) {
- int64 old = GetLocalPropertyInternal(key, default_value);
- if (value == default_value) {
- prop_map_.erase(key);
- } else {
- Value prop_value;
- prop_value.name = name;
- prop_value.value = value;
- prop_value.deallocator = deallocator;
- prop_map_[key] = prop_value;
- }
- FOR_EACH_OBSERVER(ViewObserver, observers_,
- OnViewLocalPropertyChanged(this, key, old));
- return old;
-}
-
-int64 View::GetLocalPropertyInternal(const void* key,
- int64 default_value) const {
- std::map<const void*, Value>::const_iterator iter = prop_map_.find(key);
- if (iter == prop_map_.end())
- return default_value;
- return iter->second.value;
-}
-
-void View::LocalDestroy() {
- delete this;
-}
-
-void View::LocalAddChild(View* child) {
- ScopedTreeNotifier notifier(child, child->parent(), this);
- if (child->parent())
- RemoveChildImpl(child, &child->parent_->children_);
- children_.push_back(child);
- child->parent_ = this;
-}
-
-void View::LocalRemoveChild(View* child) {
- DCHECK_EQ(this, child->parent());
- ScopedTreeNotifier notifier(child, this, NULL);
- RemoveChildImpl(child, &children_);
-}
-
-bool View::LocalReorder(View* relative, OrderDirection direction) {
- return ReorderImpl(&parent_->children_, this, relative, direction);
-}
-
-void View::LocalSetBounds(const Rect& old_bounds,
- const Rect& new_bounds) {
- DCHECK(old_bounds.x == bounds_.x);
- DCHECK(old_bounds.y == bounds_.y);
- DCHECK(old_bounds.width == bounds_.width);
- DCHECK(old_bounds.height == bounds_.height);
- ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds);
- bounds_ = new_bounds;
-}
-
-void View::LocalSetViewportMetrics(const ViewportMetrics& old_metrics,
- const ViewportMetrics& new_metrics) {
- // TODO(eseidel): We could check old_metrics against viewport_metrics_.
- viewport_metrics_ = new_metrics.Clone();
- FOR_EACH_OBSERVER(
- ViewObserver, observers_,
- OnViewViewportMetricsChanged(this, old_metrics, new_metrics));
-}
-
-void View::LocalSetDrawn(bool value) {
- if (drawn_ == value)
- return;
-
- // As IsDrawn() is derived from |visible_| and |drawn_|, only send drawn
- // notification is the value of IsDrawn() is really changing.
- if (IsDrawn() == value) {
- drawn_ = value;
- return;
- }
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this));
- drawn_ = value;
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this));
-}
-
-void View::NotifyViewVisibilityChanged(View* target) {
- if (!NotifyViewVisibilityChangedDown(target)) {
- return; // |this| has been deleted.
- }
- NotifyViewVisibilityChangedUp(target);
-}
-
-bool View::NotifyViewVisibilityChangedAtReceiver(View* target) {
- // |this| may be deleted during a call to OnViewVisibilityChanged() on one
- // of the observers. We create an local observer for that. In that case we
- // exit without further access to any members.
- ViewTracker tracker;
- tracker.Add(this);
- FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanged(target));
- return tracker.Contains(this);
-}
-
-bool View::NotifyViewVisibilityChangedDown(View* target) {
- if (!NotifyViewVisibilityChangedAtReceiver(target))
- return false; // |this| was deleted.
- std::set<const View*> child_already_processed;
- bool child_destroyed = false;
- do {
- child_destroyed = false;
- for (View::Children::const_iterator it = children_.begin();
- it != children_.end(); ++it) {
- if (!child_already_processed.insert(*it).second)
- continue;
- if (!(*it)->NotifyViewVisibilityChangedDown(target)) {
- // |*it| was deleted, |it| is invalid and |children_| has changed. We
- // exit the current for-loop and enter a new one.
- child_destroyed = true;
- break;
- }
- }
- } while (child_destroyed);
- return true;
-}
-
-void View::NotifyViewVisibilityChangedUp(View* target) {
- // Start with the parent as we already notified |this|
- // in NotifyViewVisibilityChangedDown.
- for (View* view = parent(); view; view = view->parent()) {
- bool ret = view->NotifyViewVisibilityChangedAtReceiver(target);
- DCHECK(ret);
- }
-}
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/lib/view_manager_client_factory.cc b/mojo/services/view_manager/public/cpp/lib/view_manager_client_factory.cc
deleted file mode 100644
index be4463c..0000000
--- a/mojo/services/view_manager/public/cpp/lib/view_manager_client_factory.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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 "view_manager/public/cpp/view_manager_client_factory.h"
-
-#include "mojo/public/interfaces/application/shell.mojom.h"
-#include "view_manager/public/cpp/lib/view_manager_client_impl.h"
-
-namespace mojo {
-
-ViewManagerClientFactory::ViewManagerClientFactory(
- Shell* shell,
- ViewManagerDelegate* delegate)
- : shell_(shell), delegate_(delegate) {
-}
-
-ViewManagerClientFactory::~ViewManagerClientFactory() {
-}
-
-// static
-scoped_ptr<ViewManagerClient>
-ViewManagerClientFactory::WeakBindViewManagerToPipe(
- ScopedMessagePipeHandle handle,
- Shell* shell,
- ViewManagerDelegate* delegate) {
- const bool delete_on_error = false;
- scoped_ptr<ViewManagerClientImpl> client(new ViewManagerClientImpl(
- delegate, shell, handle.Pass(), delete_on_error));
- return client.Pass();
-}
-
-// InterfaceFactory<ViewManagerClient> implementation.
-void ViewManagerClientFactory::Create(
- ApplicationConnection* connection,
- InterfaceRequest<ViewManagerClient> request) {
- const bool delete_on_error = true;
- new ViewManagerClientImpl(delegate_, shell_, request.PassMessagePipe(),
- delete_on_error);
-}
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.cc b/mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.cc
deleted file mode 100644
index 595e039..0000000
--- a/mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.cc
+++ /dev/null
@@ -1,498 +0,0 @@
-// 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 "view_manager/public/cpp/lib/view_manager_client_impl.h"
-
-#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
-#include "base/stl_util.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/connect.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
-#include "mojo/public/interfaces/application/shell.mojom.h"
-#include "view_manager/public/cpp/lib/view_private.h"
-#include "view_manager/public/cpp/util.h"
-#include "view_manager/public/cpp/view_manager_delegate.h"
-#include "view_manager/public/cpp/view_observer.h"
-
-namespace mojo {
-
-Id MakeTransportId(ConnectionSpecificId connection_id,
- ConnectionSpecificId local_id) {
- return (connection_id << 16) | local_id;
-}
-
-// Helper called to construct a local view object from transport data.
-View* AddViewToViewManager(ViewManagerClientImpl* client,
- View* parent,
- const ViewDataPtr& view_data) {
- // We don't use the ctor that takes a ViewManager here, since it will call
- // back to the service and attempt to create a new view.
- View* view = ViewPrivate::LocalCreate();
- ViewPrivate private_view(view);
- private_view.set_view_manager(client);
- private_view.set_id(view_data->view_id);
- private_view.set_visible(view_data->visible);
- private_view.set_drawn(view_data->drawn);
- private_view.LocalSetViewportMetrics(ViewportMetrics(),
- *view_data->viewport_metrics);
- private_view.set_properties(
- view_data->properties.To<std::map<std::string, std::vector<uint8_t>>>());
- client->AddView(view);
- private_view.LocalSetBounds(Rect(), *view_data->bounds);
- if (parent)
- ViewPrivate(parent).LocalAddChild(view);
- return view;
-}
-
-View* BuildViewTree(ViewManagerClientImpl* client,
- const Array<ViewDataPtr>& views,
- View* initial_parent) {
- std::vector<View*> parents;
- View* root = NULL;
- View* last_view = NULL;
- if (initial_parent)
- parents.push_back(initial_parent);
- for (size_t i = 0; i < views.size(); ++i) {
- if (last_view && views[i]->parent_id == last_view->id()) {
- parents.push_back(last_view);
- } else if (!parents.empty()) {
- while (parents.back()->id() != views[i]->parent_id)
- parents.pop_back();
- }
- View* view = AddViewToViewManager(
- client, !parents.empty() ? parents.back() : NULL, views[i]);
- if (!last_view)
- root = view;
- last_view = view;
- }
- return root;
-}
-
-// Responsible for removing a root from the ViewManager when that view is
-// destroyed.
-class RootObserver : public ViewObserver {
- public:
- explicit RootObserver(View* root) : root_(root) {}
- ~RootObserver() override {}
-
- private:
- // Overridden from ViewObserver:
- void OnViewDestroyed(View* view) override {
- DCHECK_EQ(view, root_);
- static_cast<ViewManagerClientImpl*>(root_->view_manager())
- ->RootDestroyed(root_);
- view->RemoveObserver(this);
- delete this;
- }
-
- View* root_;
-
- DISALLOW_COPY_AND_ASSIGN(RootObserver);
-};
-
-ViewManagerClientImpl::ViewManagerClientImpl(ViewManagerDelegate* delegate,
- Shell* shell,
- ScopedMessagePipeHandle handle,
- bool delete_on_error)
- : connected_(false),
- connection_id_(0),
- next_id_(1),
- delegate_(delegate),
- root_(nullptr),
- capture_view_(nullptr),
- focused_view_(nullptr),
- activated_view_(nullptr),
- binding_(this, handle.Pass()),
- service_(binding_.client()),
- delete_on_error_(delete_on_error) {
-}
-
-ViewManagerClientImpl::~ViewManagerClientImpl() {
- std::vector<View*> non_owned;
- while (!views_.empty()) {
- IdToViewMap::iterator it = views_.begin();
- if (OwnsView(it->second->id())) {
- it->second->Destroy();
- } else {
- non_owned.push_back(it->second);
- views_.erase(it);
- }
- }
- // Delete the non-owned views last. In the typical case these are roots. The
- // exception is the window manager, which may know aboutother random views
- // that it doesn't own.
- // NOTE: we manually delete as we're a friend.
- for (size_t i = 0; i < non_owned.size(); ++i)
- delete non_owned[i];
-
- delegate_->OnViewManagerDisconnected(this);
-}
-
-void ViewManagerClientImpl::DestroyView(Id view_id) {
- DCHECK(connected_);
- service_->DeleteView(view_id, ActionCompletedCallback());
-}
-
-void ViewManagerClientImpl::AddChild(Id child_id, Id parent_id) {
- DCHECK(connected_);
- service_->AddView(parent_id, child_id, ActionCompletedCallback());
-}
-
-void ViewManagerClientImpl::RemoveChild(Id child_id, Id parent_id) {
- DCHECK(connected_);
- service_->RemoveViewFromParent(child_id, ActionCompletedCallback());
-}
-
-void ViewManagerClientImpl::Reorder(
- Id view_id,
- Id relative_view_id,
- OrderDirection direction) {
- DCHECK(connected_);
- service_->ReorderView(view_id, relative_view_id, direction,
- ActionCompletedCallback());
-}
-
-bool ViewManagerClientImpl::OwnsView(Id id) const {
- return HiWord(id) == connection_id_;
-}
-
-void ViewManagerClientImpl::SetBounds(Id view_id, const Rect& bounds) {
- DCHECK(connected_);
- service_->SetViewBounds(view_id, bounds.Clone(), ActionCompletedCallback());
-}
-
-void ViewManagerClientImpl::SetSurfaceId(Id view_id, SurfaceIdPtr surface_id) {
- DCHECK(connected_);
- if (surface_id.is_null())
- return;
- service_->SetViewSurfaceId(
- view_id, surface_id.Pass(), ActionCompletedCallback());
-}
-
-void ViewManagerClientImpl::SetFocus(Id view_id) {
- // In order for us to get here we had to have exposed a view, which implies we
- // got a connection.
- DCHECK(window_manager_.get());
- window_manager_->FocusWindow(view_id, ActionCompletedCallback());
-}
-
-void ViewManagerClientImpl::SetVisible(Id view_id, bool visible) {
- DCHECK(connected_);
- service_->SetViewVisibility(view_id, visible, ActionCompletedCallback());
-}
-
-void ViewManagerClientImpl::SetProperty(
- Id view_id,
- const std::string& name,
- const std::vector<uint8_t>& data) {
- DCHECK(connected_);
- service_->SetViewProperty(view_id,
- String(name),
- Array<uint8_t>::From(data),
- ActionCompletedCallback());
-}
-
-void ViewManagerClientImpl::Embed(const String& url, Id view_id) {
- Embed(url, view_id, nullptr, nullptr);
-}
-
-void ViewManagerClientImpl::Embed(const String& url,
- Id view_id,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) {
- DCHECK(connected_);
- service_->Embed(url, view_id, services.Pass(), exposed_services.Pass(),
- ActionCompletedCallback());
-}
-
-void ViewManagerClientImpl::AddView(View* view) {
- DCHECK(views_.find(view->id()) == views_.end());
- views_[view->id()] = view;
-}
-
-void ViewManagerClientImpl::RemoveView(Id view_id) {
- IdToViewMap::iterator it = views_.find(view_id);
- if (it != views_.end())
- views_.erase(it);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewManagerClientImpl, ViewManager implementation:
-
-Id ViewManagerClientImpl::CreateViewOnServer() {
- DCHECK(connected_);
- const Id view_id = MakeTransportId(connection_id_, ++next_id_);
- service_->CreateView(view_id, ActionCompletedCallbackWithErrorCode());
- return view_id;
-}
-
-const std::string& ViewManagerClientImpl::GetEmbedderURL() const {
- return creator_url_;
-}
-
-View* ViewManagerClientImpl::GetRoot() {
- return root_;
-}
-
-View* ViewManagerClientImpl::GetViewById(Id id) {
- IdToViewMap::const_iterator it = views_.find(id);
- return it != views_.end() ? it->second : NULL;
-}
-
-View* ViewManagerClientImpl::GetFocusedView() {
- return focused_view_;
-}
-
-View* ViewManagerClientImpl::CreateView() {
- View* view = new View(this, CreateViewOnServer());
- AddView(view);
- return view;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewManagerClientImpl, ViewManagerClient implementation:
-
-void ViewManagerClientImpl::OnEmbed(
- ConnectionSpecificId connection_id,
- const String& creator_url,
- ViewDataPtr root_data,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services,
- ScopedMessagePipeHandle window_manager_pipe) {
- DCHECK(!connected_);
- connected_ = true;
- connection_id_ = connection_id;
- creator_url_ = String::From(creator_url);
-
- DCHECK(!root_);
- root_ = AddViewToViewManager(this, nullptr, root_data);
- root_->AddObserver(new RootObserver(root_));
-
- window_manager_.Bind(window_manager_pipe.Pass());
- window_manager_.set_client(this);
- // base::Unretained() is safe here as |window_manager_| is bound to our
- // lifetime.
- window_manager_->GetFocusedAndActiveViews(
- base::Bind(&ViewManagerClientImpl::OnGotFocusedAndActiveViews,
- base::Unretained(this)));
-
- delegate_->OnEmbed(root_, services.Pass(), exposed_services.Pass());
-}
-
-void ViewManagerClientImpl::OnEmbeddedAppDisconnected(Id view_id) {
- View* view = GetViewById(view_id);
- if (view) {
- FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view).observers(),
- OnViewEmbeddedAppDisconnected(view));
- }
-}
-
-void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id,
- RectPtr old_bounds,
- RectPtr new_bounds) {
- View* view = GetViewById(view_id);
- ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds);
-}
-
-namespace {
-
-void SetViewportMetricsOnDecendants(View* root,
- const ViewportMetrics& old_metrics,
- const ViewportMetrics& new_metrics) {
- ViewPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics);
- const View::Children& children = root->children();
- for (size_t i = 0; i < children.size(); ++i)
- SetViewportMetricsOnDecendants(children[i], old_metrics, new_metrics);
-}
-}
-
-void ViewManagerClientImpl::OnViewViewportMetricsChanged(
- ViewportMetricsPtr old_metrics,
- ViewportMetricsPtr new_metrics) {
- View* view = GetRoot();
- if (view)
- SetViewportMetricsOnDecendants(view, *old_metrics, *new_metrics);
-}
-
-void ViewManagerClientImpl::OnViewHierarchyChanged(
- Id view_id,
- Id new_parent_id,
- Id old_parent_id,
- mojo::Array<ViewDataPtr> views) {
- View* initial_parent = views.size() ?
- GetViewById(views[0]->parent_id) : NULL;
-
- BuildViewTree(this, views, initial_parent);
-
- View* new_parent = GetViewById(new_parent_id);
- View* old_parent = GetViewById(old_parent_id);
- View* view = GetViewById(view_id);
- if (new_parent)
- ViewPrivate(new_parent).LocalAddChild(view);
- else
- ViewPrivate(old_parent).LocalRemoveChild(view);
-}
-
-void ViewManagerClientImpl::OnViewReordered(Id view_id,
- Id relative_view_id,
- OrderDirection direction) {
- View* view = GetViewById(view_id);
- View* relative_view = GetViewById(relative_view_id);
- if (view && relative_view)
- ViewPrivate(view).LocalReorder(relative_view, direction);
-}
-
-void ViewManagerClientImpl::OnViewDeleted(Id view_id) {
- View* view = GetViewById(view_id);
- if (view)
- ViewPrivate(view).LocalDestroy();
-}
-
-void ViewManagerClientImpl::OnViewVisibilityChanged(Id view_id, bool visible) {
- // TODO(sky): there is a race condition here. If this client and another
- // client change the visibility at the same time the wrong value may be set.
- // Deal with this some how.
- View* view = GetViewById(view_id);
- if (view)
- view->SetVisible(visible);
-}
-
-void ViewManagerClientImpl::OnViewDrawnStateChanged(Id view_id, bool drawn) {
- View* view = GetViewById(view_id);
- if (view)
- ViewPrivate(view).LocalSetDrawn(drawn);
-}
-
-void ViewManagerClientImpl::OnViewSharedPropertyChanged(
- Id view_id,
- const String& name,
- Array<uint8_t> new_data) {
- View* view = GetViewById(view_id);
- if (view) {
- std::vector<uint8_t> data;
- std::vector<uint8_t>* data_ptr = NULL;
- if (!new_data.is_null()) {
- data = new_data.To<std::vector<uint8_t>>();
- data_ptr = &data;
- }
-
- view->SetSharedProperty(name, data_ptr);
- }
-}
-
-void ViewManagerClientImpl::OnViewInputEvent(
- Id view_id,
- EventPtr event,
- const Callback<void()>& ack_callback) {
- View* view = GetViewById(view_id);
- if (view) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(view).observers(),
- OnViewInputEvent(view, event));
- }
- ack_callback.Run();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewManagerClientImpl, WindowManagerClient implementation:
-
-void ViewManagerClientImpl::OnCaptureChanged(Id old_capture_view_id,
- Id new_capture_view_id) {
- View* gained_capture = GetViewById(new_capture_view_id);
- View* lost_capture = GetViewById(old_capture_view_id);
- if (lost_capture) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(lost_capture).observers(),
- OnViewFocusChanged(gained_capture, lost_capture));
- }
- capture_view_ = gained_capture;
- if (gained_capture) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(gained_capture).observers(),
- OnViewFocusChanged(gained_capture, lost_capture));
- }
-}
-
-void ViewManagerClientImpl::OnFocusChanged(Id old_focused_view_id,
- Id new_focused_view_id) {
- View* focused = GetViewById(new_focused_view_id);
- View* blurred = GetViewById(old_focused_view_id);
- if (blurred) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(blurred).observers(),
- OnViewFocusChanged(focused, blurred));
- }
- focused_view_ = focused;
- if (focused) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(focused).observers(),
- OnViewFocusChanged(focused, blurred));
- }
-}
-
-void ViewManagerClientImpl::OnActiveWindowChanged(Id old_active_view_id,
- Id new_active_view_id) {
- View* activated = GetViewById(new_active_view_id);
- View* deactivated = GetViewById(old_active_view_id);
- if (deactivated) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(deactivated).observers(),
- OnViewActivationChanged(activated, deactivated));
- }
- activated_view_ = activated;
- if (activated) {
- FOR_EACH_OBSERVER(ViewObserver,
- *ViewPrivate(activated).observers(),
- OnViewActivationChanged(activated, deactivated));
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// OnConnectionError, private:
-void ViewManagerClientImpl::OnConnectionError() {
- if (delete_on_error_)
- delete this;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewManagerClientImpl, private:
-
-void ViewManagerClientImpl::RootDestroyed(View* root) {
- DCHECK_EQ(root, root_);
- root_ = nullptr;
-}
-
-void ViewManagerClientImpl::OnActionCompleted(bool success) {
- if (!change_acked_callback_.is_null())
- change_acked_callback_.Run();
-}
-
-void ViewManagerClientImpl::OnActionCompletedWithErrorCode(ErrorCode code) {
- OnActionCompleted(code == ERROR_CODE_NONE);
-}
-
-base::Callback<void(bool)> ViewManagerClientImpl::ActionCompletedCallback() {
- return base::Bind(&ViewManagerClientImpl::OnActionCompleted,
- base::Unretained(this));
-}
-
-base::Callback<void(ErrorCode)>
- ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() {
- return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode,
- base::Unretained(this));
-}
-
-void ViewManagerClientImpl::OnGotFocusedAndActiveViews(uint32 focused_view_id,
- uint32 active_view_id) {
- if (GetViewById(focused_view_id) != focused_view_)
- OnFocusChanged(focused_view_ ? focused_view_->id() : 0, focused_view_id);
- if (GetViewById(active_view_id) != activated_view_) {
- OnActiveWindowChanged(activated_view_ ? activated_view_->id() : 0,
- active_view_id);
- }
-}
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.h b/mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.h
deleted file mode 100644
index 2405229..0000000
--- a/mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.h
+++ /dev/null
@@ -1,176 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_MANAGER_CLIENT_IMPL_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_MANAGER_CLIENT_IMPL_H_
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/memory/scoped_vector.h"
-#include "base/memory/weak_ptr.h"
-#include "mojo/public/cpp/bindings/strong_binding.h"
-#include "view_manager/public/cpp/types.h"
-#include "view_manager/public/cpp/view.h"
-#include "view_manager/public/cpp/view_manager.h"
-#include "view_manager/public/interfaces/view_manager.mojom.h"
-#include "window_manager/public/interfaces/window_manager.mojom.h"
-
-namespace mojo {
-class Shell;
-class ViewManager;
-class ViewManagerDelegate;
-class ViewManagerTransaction;
-
-// Manages the connection with the View Manager service.
-class ViewManagerClientImpl : public ViewManager,
- public ViewManagerClient,
- public WindowManagerClient,
- public ErrorHandler {
- public:
- ViewManagerClientImpl(ViewManagerDelegate* delegate,
- Shell* shell,
- ScopedMessagePipeHandle handle,
- bool delete_on_error);
- ~ViewManagerClientImpl() override;
-
- bool connected() const { return connected_; }
- ConnectionSpecificId connection_id() const { return connection_id_; }
-
- // API exposed to the view implementations that pushes local changes to the
- // service.
- void DestroyView(Id view_id);
-
- // These methods take TransportIds. For views owned by the current connection,
- // the connection id high word can be zero. In all cases, the TransportId 0x1
- // refers to the root view.
- void AddChild(Id child_id, Id parent_id);
- void RemoveChild(Id child_id, Id parent_id);
-
- void Reorder(Id view_id, Id relative_view_id, OrderDirection direction);
-
- // Returns true if the specified view was created by this connection.
- bool OwnsView(Id id) const;
-
- void SetBounds(Id view_id, const Rect& bounds);
- void SetSurfaceId(Id view_id, SurfaceIdPtr surface_id);
- void SetFocus(Id view_id);
- void SetVisible(Id view_id, bool visible);
- void SetProperty(Id view_id,
- const std::string& name,
- const std::vector<uint8_t>& data);
-
- void Embed(const String& url, Id view_id);
- void Embed(const String& url,
- Id view_id,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services);
-
- void set_change_acked_callback(const base::Callback<void(void)>& callback) {
- change_acked_callback_ = callback;
- }
- void ClearChangeAckedCallback() {
- change_acked_callback_ = base::Callback<void(void)>();
- }
-
- // Start/stop tracking views. While tracked, they can be retrieved via
- // ViewManager::GetViewById.
- void AddView(View* view);
- void RemoveView(Id view_id);
-
- private:
- friend class RootObserver;
-
- typedef std::map<Id, View*> IdToViewMap;
-
- Id CreateViewOnServer();
-
- // Overridden from ViewManager:
- const std::string& GetEmbedderURL() const override;
- View* GetRoot() override;
- View* GetViewById(Id id) override;
- View* GetFocusedView() override;
- View* CreateView() override;
-
- // Overridden from ViewManagerClient:
- void OnEmbed(ConnectionSpecificId connection_id,
- const String& creator_url,
- ViewDataPtr root,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services,
- ScopedMessagePipeHandle window_manager_pipe) override;
- void OnEmbeddedAppDisconnected(Id view_id) override;
- void OnViewBoundsChanged(Id view_id,
- RectPtr old_bounds,
- RectPtr new_bounds) override;
- void OnViewViewportMetricsChanged(ViewportMetricsPtr old_metrics,
- ViewportMetricsPtr new_metrics) override;
- void OnViewHierarchyChanged(Id view_id,
- Id new_parent_id,
- Id old_parent_id,
- Array<ViewDataPtr> views) override;
- void OnViewReordered(Id view_id,
- Id relative_view_id,
- OrderDirection direction) override;
- void OnViewDeleted(Id view_id) override;
- void OnViewVisibilityChanged(Id view_id, bool visible) override;
- void OnViewDrawnStateChanged(Id view_id, bool drawn) override;
- void OnViewSharedPropertyChanged(Id view_id,
- const String& name,
- Array<uint8_t> new_data) override;
- void OnViewInputEvent(Id view_id,
- EventPtr event,
- const Callback<void()>& callback) override;
-
- // Overridden from WindowManagerClient:
- void OnCaptureChanged(Id old_capture_view_id,
- Id new_capture_view_id) override;
- void OnFocusChanged(Id old_focused_view_id, Id new_focused_view_id) override;
- void OnActiveWindowChanged(Id old_focused_view_id,
- Id new_focused_view_id) override;
-
- // ErrorHandler implementation.
- void OnConnectionError() override;
-
- void RootDestroyed(View* root);
-
- void OnActionCompleted(bool success);
- void OnActionCompletedWithErrorCode(ErrorCode code);
-
- base::Callback<void(bool)> ActionCompletedCallback();
- base::Callback<void(ErrorCode)> ActionCompletedCallbackWithErrorCode();
-
- // Callback from server for initial request of focused/active views.
- void OnGotFocusedAndActiveViews(uint32 focused_view_id,
- uint32 active_view_id);
-
- bool connected_;
- ConnectionSpecificId connection_id_;
- ConnectionSpecificId next_id_;
-
- std::string creator_url_;
-
- base::Callback<void(void)> change_acked_callback_;
-
- ViewManagerDelegate* delegate_;
-
- View* root_;
-
- IdToViewMap views_;
-
- View* capture_view_;
- View* focused_view_;
- View* activated_view_;
-
- WindowManagerPtr window_manager_;
-
- Binding<ViewManagerClient> binding_;
- ViewManagerService* service_;
- const bool delete_on_error_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl);
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_MANAGER_CLIENT_IMPL_H_
diff --git a/mojo/services/view_manager/public/cpp/lib/view_manager_context.cc b/mojo/services/view_manager/public/cpp/lib/view_manager_context.cc
deleted file mode 100644
index a47f59a..0000000
--- a/mojo/services/view_manager/public/cpp/lib/view_manager_context.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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 "view_manager/public/cpp/view_manager_context.h"
-
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/bindings/interface_request.h"
-#include "window_manager/public/interfaces/window_manager.mojom.h"
-
-namespace mojo {
-class ApplicationImpl;
-
-class ViewManagerContext::InternalState {
- public:
- explicit InternalState(ApplicationImpl* application_impl) {
- application_impl->ConnectToService("mojo:window_manager", &wm_);
- }
- ~InternalState() {}
-
- WindowManager* wm() { return wm_.get(); }
-
- private:
- WindowManagerPtr wm_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(InternalState);
-};
-
-ViewManagerContext::ViewManagerContext(ApplicationImpl* application_impl)
- : state_(new InternalState(application_impl)) {}
-ViewManagerContext::~ViewManagerContext() {}
-
-void ViewManagerContext::Embed(const String& url) {
- Embed(url, nullptr, nullptr);
-}
-
-void ViewManagerContext::Embed(const String& url,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) {
- state_->wm()->Embed(url, services.Pass(), exposed_services.Pass());
-}
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/lib/view_observer.cc b/mojo/services/view_manager/public/cpp/lib/view_observer.cc
deleted file mode 100644
index 456147c..0000000
--- a/mojo/services/view_manager/public/cpp/lib/view_observer.cc
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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 "view_manager/public/cpp/view_observer.h"
-
-#include "base/basictypes.h"
-
-namespace mojo {
-
-////////////////////////////////////////////////////////////////////////////////
-// ViewObserver, public:
-
-ViewObserver::TreeChangeParams::TreeChangeParams()
- : target(NULL),
- old_parent(NULL),
- new_parent(NULL),
- receiver(NULL) {}
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/lib/view_private.cc b/mojo/services/view_manager/public/cpp/lib/view_private.cc
deleted file mode 100644
index 20232e8..0000000
--- a/mojo/services/view_manager/public/cpp/lib/view_private.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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 "view_manager/public/cpp/lib/view_private.h"
-
-namespace mojo {
-
-ViewPrivate::ViewPrivate(View* view)
- : view_(view) {
- CHECK(view);
-}
-
-ViewPrivate::~ViewPrivate() {
-}
-
-// static
-View* ViewPrivate::LocalCreate() {
- return new View;
-}
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/lib/view_private.h b/mojo/services/view_manager/public/cpp/lib/view_private.h
deleted file mode 100644
index 1c54567..0000000
--- a/mojo/services/view_manager/public/cpp/lib/view_private.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_
-
-#include "base/basictypes.h"
-
-#include "view_manager/public/cpp/view.h"
-
-namespace mojo {
-
-// This class is a friend of a View and contains functions to mutate internal
-// state of View.
-class ViewPrivate {
- public:
- explicit ViewPrivate(View* view);
- ~ViewPrivate();
-
- // Creates and returns a new View. Caller owns the return value.
- static View* LocalCreate();
-
- ObserverList<ViewObserver>* observers() { return &view_->observers_; }
-
- void ClearParent() { view_->parent_ = NULL; }
-
- void set_visible(bool visible) { view_->visible_ = visible; }
-
- void set_drawn(bool drawn) { view_->drawn_ = drawn; }
-
- void set_id(Id id) { view_->id_ = id; }
-
- void set_view_manager(ViewManager* manager) {
- view_->manager_ = manager;
- }
-
- void set_properties(const std::map<std::string, std::vector<uint8_t>>& data) {
- view_->properties_ = data;
- }
-
- void LocalSetViewportMetrics(const ViewportMetrics& old_metrics,
- const ViewportMetrics& new_metrics) {
- view_->LocalSetViewportMetrics(new_metrics, new_metrics);
- }
-
- void LocalDestroy() {
- view_->LocalDestroy();
- }
- void LocalAddChild(View* child) {
- view_->LocalAddChild(child);
- }
- void LocalRemoveChild(View* child) {
- view_->LocalRemoveChild(child);
- }
- void LocalReorder(View* relative, OrderDirection direction) {
- view_->LocalReorder(relative, direction);
- }
- void LocalSetBounds(const Rect& old_bounds,
- const Rect& new_bounds) {
- view_->LocalSetBounds(old_bounds, new_bounds);
- }
- void LocalSetDrawn(bool drawn) { view_->LocalSetDrawn(drawn); }
-
- private:
- View* view_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewPrivate);
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_
diff --git a/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.cc b/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.cc
deleted file mode 100644
index 2bfdd1e..0000000
--- a/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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/services/view_manager/public/cpp/tests/view_manager_test_suite.h"
-
-#include "base/i18n/icu_util.h"
-
-#if defined(USE_X11)
-#include "ui/gfx/x/x11_connection.h"
-#endif
-
-namespace mojo {
-
-ViewManagerTestSuite::ViewManagerTestSuite(int argc, char** argv)
- : TestSuite(argc, argv) {}
-
-ViewManagerTestSuite::~ViewManagerTestSuite() {
-}
-
-void ViewManagerTestSuite::Initialize() {
-#if defined(USE_X11)
- // Each test ends up creating a new thread for the native viewport service.
- // In other words we'll use X on different threads, so tell it that.
- gfx::InitializeThreadedX11();
-#endif
-
- base::TestSuite::Initialize();
-
- // base::TestSuite and ViewsInit both try to load icu. That's ok for tests.
- base::i18n::AllowMultipleInitializeCallsForTesting();
-}
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h b/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h
deleted file mode 100644
index ef81661..0000000
--- a/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_SUITE_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_SUITE_H_
-
-#include "base/test/test_suite.h"
-
-namespace mojo {
-
-class ViewManagerTestSuite : public base::TestSuite {
- public:
- ViewManagerTestSuite(int argc, char** argv);
- ~ViewManagerTestSuite() override;
-
- protected:
- void Initialize() override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ViewManagerTestSuite);
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_SUITE_H_
diff --git a/mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc b/mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc
deleted file mode 100644
index bc69464..0000000
--- a/mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc
+++ /dev/null
@@ -1,652 +0,0 @@
-// 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/services/view_manager/public/cpp/view_manager.h"
-
-#include "base/auto_reset.h"
-#include "base/bind.h"
-#include "base/logging.h"
-#include "mojo/public/cpp/application/application_connection.h"
-#include "mojo/public/cpp/application/application_delegate.h"
-#include "mojo/public/cpp/application/application_impl.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
-#include "mojo/services/geometry/public/cpp/geometry_util.h"
-#include "mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.h"
-#include "mojo/services/view_manager/public/cpp/lib/view_private.h"
-#include "mojo/services/view_manager/public/cpp/util.h"
-#include "mojo/services/view_manager/public/cpp/view_manager_client_factory.h"
-#include "mojo/services/view_manager/public/cpp/view_manager_delegate.h"
-#include "mojo/services/view_manager/public/cpp/view_observer.h"
-#include "shell/application_manager/application_manager.h"
-#include "shell/shell_test_helper.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace mojo {
-
-namespace {
-
-const char kWindowManagerURL[] = "mojo:window_manager";
-const char kEmbeddedApp1URL[] = "mojo:embedded_app_1";
-
-base::RunLoop* current_run_loop = NULL;
-
-void DoRunLoop() {
- base::RunLoop run_loop;
- current_run_loop = &run_loop;
- current_run_loop->Run();
- current_run_loop = NULL;
-}
-
-void QuitRunLoop() {
- current_run_loop->Quit();
-}
-
-class ConnectApplicationLoader : public ApplicationLoader,
- public ApplicationDelegate,
- public ViewManagerDelegate {
- public:
- typedef base::Callback<void(View*)> LoadedCallback;
-
- explicit ConnectApplicationLoader(const LoadedCallback& callback)
- : callback_(callback) {}
- ~ConnectApplicationLoader() override {}
-
- private:
- // Overridden from ApplicationDelegate:
- void Initialize(ApplicationImpl* app) override {
- view_manager_client_factory_.reset(
- new ViewManagerClientFactory(app->shell(), this));
- }
-
- // Overridden from ApplicationLoader:
- void Load(ApplicationManager* manager,
- const GURL& url,
- InterfaceRequest<Application> application_request,
- LoadCallback callback) override {
- ASSERT_TRUE(application_request.is_pending());
- scoped_ptr<ApplicationImpl> app(
- new ApplicationImpl(this, application_request.Pass()));
- apps_.push_back(app.release());
- }
-
- void OnApplicationError(ApplicationManager* manager,
- const GURL& url) override {}
-
- bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
- connection->AddService(view_manager_client_factory_.get());
- return true;
- }
-
- // Overridden from ViewManagerDelegate:
- void OnEmbed(View* root,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) override {
- callback_.Run(root);
- }
- void OnViewManagerDisconnected(ViewManager* view_manager) override {}
-
- ScopedVector<ApplicationImpl> apps_;
- LoadedCallback callback_;
- scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(ConnectApplicationLoader);
-};
-
-class BoundsChangeObserver : public ViewObserver {
- public:
- explicit BoundsChangeObserver(View* view) : view_(view) {}
- ~BoundsChangeObserver() override {}
-
- private:
- // Overridden from ViewObserver:
- void OnViewBoundsChanged(View* view,
- const Rect& old_bounds,
- const Rect& new_bounds) override {
- DCHECK_EQ(view, view_);
- QuitRunLoop();
- }
-
- View* view_;
-
- DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver);
-};
-
-// Wait until the bounds of the supplied view change.
-void WaitForBoundsToChange(View* view) {
- BoundsChangeObserver observer(view);
- view->AddObserver(&observer);
- DoRunLoop();
- view->RemoveObserver(&observer);
-}
-
-// Spins a runloop until the tree beginning at |root| has |tree_size| views
-// (including |root|).
-class TreeSizeMatchesObserver : public ViewObserver {
- public:
- TreeSizeMatchesObserver(View* tree, size_t tree_size)
- : tree_(tree),
- tree_size_(tree_size) {}
- ~TreeSizeMatchesObserver() override {}
-
- bool IsTreeCorrectSize() {
- return CountViews(tree_) == tree_size_;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnTreeChanged(const TreeChangeParams& params) override {
- if (IsTreeCorrectSize())
- QuitRunLoop();
- }
-
- size_t CountViews(const View* view) const {
- size_t count = 1;
- View::Children::const_iterator it = view->children().begin();
- for (; it != view->children().end(); ++it)
- count += CountViews(*it);
- return count;
- }
-
- View* tree_;
- size_t tree_size_;
-
- DISALLOW_COPY_AND_ASSIGN(TreeSizeMatchesObserver);
-};
-
-void WaitForTreeSizeToMatch(View* view, size_t tree_size) {
- TreeSizeMatchesObserver observer(view, tree_size);
- if (observer.IsTreeCorrectSize())
- return;
- view->AddObserver(&observer);
- DoRunLoop();
- view->RemoveObserver(&observer);
-}
-
-// Utility class that waits for the destruction of some number of views and
-// views.
-class DestructionObserver : public ViewObserver {
- public:
- // |views| or |views| can be NULL.
- explicit DestructionObserver(std::set<Id>* views) : views_(views) {}
-
- private:
- // Overridden from ViewObserver:
- void OnViewDestroyed(View* view) override {
- std::set<Id>::iterator it = views_->find(view->id());
- if (it != views_->end())
- views_->erase(it);
- if (CanQuit())
- QuitRunLoop();
- }
-
- bool CanQuit() {
- return !views_ || views_->empty();
- }
-
- std::set<Id>* views_;
-
- DISALLOW_COPY_AND_ASSIGN(DestructionObserver);
-};
-
-void WaitForDestruction(ViewManager* view_manager, std::set<Id>* views) {
- DestructionObserver observer(views);
- DCHECK(views);
- if (views) {
- for (std::set<Id>::const_iterator it = views->begin();
- it != views->end(); ++it) {
- view_manager->GetViewById(*it)->AddObserver(&observer);
- }
- }
- DoRunLoop();
-}
-
-class OrderChangeObserver : public ViewObserver {
- public:
- OrderChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- ~OrderChangeObserver() override { view_->RemoveObserver(this); }
-
- private:
- // Overridden from ViewObserver:
- void OnViewReordered(View* view,
- View* relative_view,
- OrderDirection direction) override {
- DCHECK_EQ(view, view_);
- QuitRunLoop();
- }
-
- View* view_;
-
- DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver);
-};
-
-void WaitForOrderChange(ViewManager* view_manager, View* view) {
- OrderChangeObserver observer(view);
- DoRunLoop();
-}
-
-// Tracks a view's destruction. Query is_valid() for current state.
-class ViewTracker : public ViewObserver {
- public:
- explicit ViewTracker(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- ~ViewTracker() override {
- if (view_)
- view_->RemoveObserver(this);
- }
-
- bool is_valid() const { return !!view_; }
-
- private:
- // Overridden from ViewObserver:
- void OnViewDestroyed(View* view) override {
- DCHECK_EQ(view, view_);
- view_ = NULL;
- }
-
- int id_;
- View* view_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewTracker);
-};
-
-} // namespace
-
-// ViewManager -----------------------------------------------------------------
-
-// These tests model synchronization of two peer connections to the view manager
-// service, that are given access to some root view.
-
-class ViewManagerTest : public testing::Test {
- public:
- ViewManagerTest()
- : connect_loop_(NULL),
- loaded_view_manager_(NULL),
- window_manager_(NULL),
- commit_count_(0) {}
-
- protected:
- ViewManager* window_manager() { return window_manager_; }
-
- View* CreateViewInParent(View* parent) {
- ViewManager* parent_manager = parent->view_manager();
- View* view = parent_manager->CreateView();
- view->SetVisible(true);
- parent->AddChild(view);
- return view;
- }
-
- // Embeds another version of the test app @ view.
- ViewManager* Embed(ViewManager* view_manager, View* view) {
- DCHECK_EQ(view_manager, view->view_manager());
- view->Embed(kEmbeddedApp1URL);
- RunRunLoop();
- return GetLoadedViewManager();
- }
-
- ViewManager* GetLoadedViewManager() {
- ViewManager* view_manager = loaded_view_manager_;
- loaded_view_manager_ = NULL;
- return view_manager;
- }
-
- void UnloadApplication(const GURL& url) {
- test_helper_.SetLoaderForURL(scoped_ptr<ApplicationLoader>(), url);
- }
-
- private:
- // Overridden from testing::Test:
- void SetUp() override {
- ConnectApplicationLoader::LoadedCallback ready_callback = base::Bind(
- &ViewManagerTest::OnViewManagerLoaded, base::Unretained(this));
- test_helper_.Init();
- test_helper_.SetLoaderForURL(
- scoped_ptr<ApplicationLoader>(
- new ConnectApplicationLoader(ready_callback)),
- GURL(kWindowManagerURL));
- test_helper_.SetLoaderForURL(
- scoped_ptr<ApplicationLoader>(
- new ConnectApplicationLoader(ready_callback)),
- GURL(kEmbeddedApp1URL));
-
- // TODO(sky): resolve this. Need to establish initial connection.
- }
-
- void OnViewManagerLoaded(View* root) {
- loaded_view_manager_ = root->view_manager();
- connect_loop_->Quit();
- }
-
- void RunRunLoop() {
- base::RunLoop run_loop;
- connect_loop_ = &run_loop;
- connect_loop_->Run();
- connect_loop_ = NULL;
- }
-
- base::RunLoop* connect_loop_;
- shell::ShellTestHelper test_helper_;
- // Used to receive the most recent view manager loaded by an embed action.
- ViewManager* loaded_view_manager_;
- // The View Manager connection held by the window manager (app running at the
- // root view).
- ViewManager* window_manager_;
- int commit_count_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewManagerTest);
-};
-
-// TODO(sky): all of these tests are disabled as each test triggers running
-// ViewsInit, which tries to register the same set of paths with the
-// PathService, triggering a DCHECK.
-TEST_F(ViewManagerTest, DISABLED_SetUp) {}
-
-TEST_F(ViewManagerTest, DISABLED_Embed) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewManager* embedded = Embed(window_manager(), view);
- EXPECT_TRUE(NULL != embedded);
-
- View* view_in_embedded = embedded->GetRoot();
- EXPECT_EQ(view->parent(), window_manager()->GetRoot());
- EXPECT_EQ(NULL, view_in_embedded->parent());
-}
-
-// Window manager has two views, N1 and N11. Embeds A at N1. A should not see
-// N11.
-// TODO(sky): Update client lib to match server.
-TEST_F(ViewManagerTest, DISABLED_EmbeddedDoesntSeeChild) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- View* nested = window_manager()->CreateView();
- nested->SetVisible(true);
- view->AddChild(nested);
-
- ViewManager* embedded = Embed(window_manager(), view);
- EXPECT_EQ(embedded->GetRoot()->children().front()->id(),
- nested->id());
- EXPECT_TRUE(embedded->GetRoot()->children().empty());
- EXPECT_TRUE(nested->parent() == NULL);
-}
-
-// http://crbug.com/396300
-TEST_F(ViewManagerTest, DISABLED_ViewManagerDestroyed_CleanupView) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewManager* embedded = Embed(window_manager(), view);
-
- Id view_id = view->id();
-
- UnloadApplication(GURL(kWindowManagerURL));
-
- std::set<Id> views;
- views.insert(view_id);
- WaitForDestruction(embedded, &views);
-
- EXPECT_EQ(nullptr, embedded->GetRoot());
-}
-
-// TODO(beng): write a replacement test for the one that once existed here:
-// This test validates the following scenario:
-// - a view originating from one connection
-// - a view originating from a second connection
-// + the connection originating the view is destroyed
-// -> the view should still exist (since the second connection is live) but
-// should be disconnected from any views.
-// http://crbug.com/396300
-//
-// TODO(beng): The new test should validate the scenario as described above
-// except that the second connection still has a valid tree.
-
-// Verifies that bounds changes applied to a view hierarchy in one connection
-// are reflected to another.
-TEST_F(ViewManagerTest, DISABLED_SetBounds) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewManager* embedded = Embed(window_manager(), view);
-
- View* view_in_embedded = embedded->GetViewById(view->id());
- EXPECT_EQ(view->bounds(), view_in_embedded->bounds());
-
- Rect rect;
- rect.width = rect.height = 100;
- view->SetBounds(rect);
- EXPECT_NE(view->bounds(), view_in_embedded->bounds());
- WaitForBoundsToChange(view_in_embedded);
- EXPECT_EQ(view->bounds(), view_in_embedded->bounds());
-}
-
-// Verifies that bounds changes applied to a view owned by a different
-// connection are refused.
-TEST_F(ViewManagerTest, DISABLED_SetBoundsSecurity) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewManager* embedded = Embed(window_manager(), view);
-
- View* view_in_embedded = embedded->GetViewById(view->id());
- Rect rect;
- rect.width = 800;
- rect.height = 600;
- view->SetBounds(rect);
- WaitForBoundsToChange(view_in_embedded);
-
- rect.width = 1024;
- rect.height = 768;
- view_in_embedded->SetBounds(rect);
- // Bounds change should have been rejected.
- EXPECT_EQ(view->bounds(), view_in_embedded->bounds());
-}
-
-// Verifies that a view can only be destroyed by the connection that created it.
-TEST_F(ViewManagerTest, DISABLED_DestroySecurity) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewManager* embedded = Embed(window_manager(), view);
-
- View* view_in_embedded = embedded->GetViewById(view->id());
-
- ViewTracker tracker2(view_in_embedded);
- view_in_embedded->Destroy();
- // View should not have been destroyed.
- EXPECT_TRUE(tracker2.is_valid());
-
- ViewTracker tracker1(view);
- view->Destroy();
- EXPECT_FALSE(tracker1.is_valid());
-}
-
-TEST_F(ViewManagerTest, DISABLED_MultiRoots) {
- View* view1 = window_manager()->CreateView();
- view1->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view1);
- View* view2 = window_manager()->CreateView();
- view2->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view2);
- ViewManager* embedded1 = Embed(window_manager(), view1);
- ViewManager* embedded2 = Embed(window_manager(), view2);
- EXPECT_EQ(embedded1, embedded2);
-}
-
-TEST_F(ViewManagerTest, DISABLED_EmbeddingIdentity) {
- View* view = window_manager()->CreateView();
- view->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view);
- ViewManager* embedded = Embed(window_manager(), view);
- EXPECT_EQ(kWindowManagerURL, embedded->GetEmbedderURL());
-}
-
-TEST_F(ViewManagerTest, DISABLED_Reorder) {
- View* view1 = window_manager()->CreateView();
- view1->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view1);
-
- ViewManager* embedded = Embed(window_manager(), view1);
-
- View* view11 = embedded->CreateView();
- view11->SetVisible(true);
- embedded->GetRoot()->AddChild(view11);
- View* view12 = embedded->CreateView();
- view12->SetVisible(true);
- embedded->GetRoot()->AddChild(view12);
-
- View* view1_in_wm = window_manager()->GetViewById(view1->id());
-
- {
- WaitForTreeSizeToMatch(view1, 2u);
- view11->MoveToFront();
- WaitForOrderChange(window_manager(),
- window_manager()->GetViewById(view11->id()));
-
- EXPECT_EQ(view1_in_wm->children().front(),
- window_manager()->GetViewById(view12->id()));
- EXPECT_EQ(view1_in_wm->children().back(),
- window_manager()->GetViewById(view11->id()));
- }
-
- {
- view11->MoveToBack();
- WaitForOrderChange(window_manager(),
- window_manager()->GetViewById(view11->id()));
-
- EXPECT_EQ(view1_in_wm->children().front(),
- window_manager()->GetViewById(view11->id()));
- EXPECT_EQ(view1_in_wm->children().back(),
- window_manager()->GetViewById(view12->id()));
- }
-}
-
-namespace {
-
-class VisibilityChangeObserver : public ViewObserver {
- public:
- explicit VisibilityChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- ~VisibilityChangeObserver() override { view_->RemoveObserver(this); }
-
- private:
- // Overridden from ViewObserver:
- void OnViewVisibilityChanged(View* view) override {
- EXPECT_EQ(view, view_);
- QuitRunLoop();
- }
-
- View* view_;
-
- DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewManagerTest, DISABLED_Visible) {
- View* view1 = window_manager()->CreateView();
- view1->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view1);
-
- // Embed another app and verify initial state.
- ViewManager* embedded = Embed(window_manager(), view1);
- ASSERT_NE(nullptr, embedded->GetRoot());
- View* embedded_root = embedded->GetRoot();
- EXPECT_TRUE(embedded_root->visible());
- EXPECT_TRUE(embedded_root->IsDrawn());
-
- // Change the visible state from the first connection and verify its mirrored
- // correctly to the embedded app.
- {
- VisibilityChangeObserver observer(embedded_root);
- view1->SetVisible(false);
- DoRunLoop();
- }
-
- EXPECT_FALSE(view1->visible());
- EXPECT_FALSE(view1->IsDrawn());
-
- EXPECT_FALSE(embedded_root->visible());
- EXPECT_FALSE(embedded_root->IsDrawn());
-
- // Make the node visible again.
- {
- VisibilityChangeObserver observer(embedded_root);
- view1->SetVisible(true);
- DoRunLoop();
- }
-
- EXPECT_TRUE(view1->visible());
- EXPECT_TRUE(view1->IsDrawn());
-
- EXPECT_TRUE(embedded_root->visible());
- EXPECT_TRUE(embedded_root->IsDrawn());
-}
-
-namespace {
-
-class DrawnChangeObserver : public ViewObserver {
- public:
- explicit DrawnChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- ~DrawnChangeObserver() override { view_->RemoveObserver(this); }
-
- private:
- // Overridden from ViewObserver:
- void OnViewDrawnChanged(View* view) override {
- EXPECT_EQ(view, view_);
- QuitRunLoop();
- }
-
- View* view_;
-
- DISALLOW_COPY_AND_ASSIGN(DrawnChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewManagerTest, DISABLED_Drawn) {
- View* view1 = window_manager()->CreateView();
- view1->SetVisible(true);
- window_manager()->GetRoot()->AddChild(view1);
-
- // Embed another app and verify initial state.
- ViewManager* embedded = Embed(window_manager(), view1);
- ASSERT_NE(nullptr, embedded->GetRoot());
- View* embedded_root = embedded->GetRoot();
- EXPECT_TRUE(embedded_root->visible());
- EXPECT_TRUE(embedded_root->IsDrawn());
-
- // Change the visibility of the root, this should propagate a drawn state
- // change to |embedded|.
- {
- DrawnChangeObserver observer(embedded_root);
- window_manager()->GetRoot()->SetVisible(false);
- DoRunLoop();
- }
-
- EXPECT_TRUE(view1->visible());
- EXPECT_FALSE(view1->IsDrawn());
-
- EXPECT_TRUE(embedded_root->visible());
- EXPECT_FALSE(embedded_root->IsDrawn());
-}
-
-// TODO(beng): tests for view event dispatcher.
-// - verify that we see events for all views.
-
-// TODO(beng): tests for focus:
-// - focus between two views known to a connection
-// - focus between views unknown to one of the connections.
-// - focus between views unknown to either connection.
-
-// TODO(sky): need test of root being destroyed with existing views. See
-// 434555 for specific case.
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/tests/view_manager_unittests.cc b/mojo/services/view_manager/public/cpp/tests/view_manager_unittests.cc
deleted file mode 100644
index 95a7b5c..0000000
--- a/mojo/services/view_manager/public/cpp/tests/view_manager_unittests.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-// 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 "base/bind.h"
-#include "base/test/launcher/unit_test_launcher.h"
-#include "mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h"
-
-int main(int argc, char** argv) {
- mojo::ViewManagerTestSuite test_suite(argc, argv);
-
- return base::LaunchUnitTests(
- argc, argv, base::Bind(&TestSuite::Run, base::Unretained(&test_suite)));
-}
diff --git a/mojo/services/view_manager/public/cpp/tests/view_unittest.cc b/mojo/services/view_manager/public/cpp/tests/view_unittest.cc
deleted file mode 100644
index 149eb3a..0000000
--- a/mojo/services/view_manager/public/cpp/tests/view_unittest.cc
+++ /dev/null
@@ -1,884 +0,0 @@
-// 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/services/view_manager/public/cpp/view.h"
-
-#include "base/logging.h"
-#include "base/strings/stringprintf.h"
-#include "mojo/services/view_manager/public/cpp/lib/view_private.h"
-#include "mojo/services/view_manager/public/cpp/util.h"
-#include "mojo/services/view_manager/public/cpp/view_observer.h"
-#include "mojo/services/view_manager/public/cpp/view_property.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace mojo {
-
-// View ------------------------------------------------------------------------
-
-typedef testing::Test ViewTest;
-
-// Subclass with public ctor/dtor.
-class TestView : public View {
- public:
- TestView() {
- ViewPrivate(this).set_id(1);
- }
- ~TestView() {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestView);
-};
-
-TEST_F(ViewTest, AddChild) {
- TestView v1;
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_EQ(1U, v1.children().size());
-}
-
-TEST_F(ViewTest, RemoveChild) {
- TestView v1;
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_EQ(1U, v1.children().size());
- v1.RemoveChild(&v11);
- EXPECT_EQ(0U, v1.children().size());
-}
-
-TEST_F(ViewTest, Reparent) {
- TestView v1;
- TestView v2;
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_EQ(1U, v1.children().size());
- v2.AddChild(&v11);
- EXPECT_EQ(1U, v2.children().size());
- EXPECT_EQ(0U, v1.children().size());
-}
-
-TEST_F(ViewTest, Contains) {
- TestView v1;
-
- // Direct descendant.
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_TRUE(v1.Contains(&v11));
-
- // Indirect descendant.
- TestView v111;
- v11.AddChild(&v111);
- EXPECT_TRUE(v1.Contains(&v111));
-}
-
-TEST_F(ViewTest, GetChildById) {
- TestView v1;
- ViewPrivate(&v1).set_id(1);
- TestView v11;
- ViewPrivate(&v11).set_id(11);
- v1.AddChild(&v11);
- TestView v111;
- ViewPrivate(&v111).set_id(111);
- v11.AddChild(&v111);
-
- // Find direct & indirect descendents.
- EXPECT_EQ(&v11, v1.GetChildById(v11.id()));
- EXPECT_EQ(&v111, v1.GetChildById(v111.id()));
-}
-
-TEST_F(ViewTest, DrawnAndVisible) {
- TestView v1;
- EXPECT_TRUE(v1.visible());
- EXPECT_FALSE(v1.IsDrawn());
-
- ViewPrivate(&v1).set_drawn(true);
-
- TestView v11;
- v1.AddChild(&v11);
- EXPECT_TRUE(v11.visible());
- EXPECT_TRUE(v11.IsDrawn());
-
- v1.RemoveChild(&v11);
- EXPECT_TRUE(v11.visible());
- EXPECT_FALSE(v11.IsDrawn());
-}
-
-namespace {
-DEFINE_VIEW_PROPERTY_KEY(int, kIntKey, -2);
-DEFINE_VIEW_PROPERTY_KEY(const char*, kStringKey, "squeamish");
-}
-
-TEST_F(ViewTest, Property) {
- TestView v;
-
- // Non-existent properties should return the default values.
- EXPECT_EQ(-2, v.GetLocalProperty(kIntKey));
- EXPECT_EQ(std::string("squeamish"), v.GetLocalProperty(kStringKey));
-
- // A set property value should be returned again (even if it's the default
- // value).
- v.SetLocalProperty(kIntKey, INT_MAX);
- EXPECT_EQ(INT_MAX, v.GetLocalProperty(kIntKey));
- v.SetLocalProperty(kIntKey, -2);
- EXPECT_EQ(-2, v.GetLocalProperty(kIntKey));
- v.SetLocalProperty(kIntKey, INT_MIN);
- EXPECT_EQ(INT_MIN, v.GetLocalProperty(kIntKey));
-
- v.SetLocalProperty(kStringKey, static_cast<const char*>(NULL));
- EXPECT_EQ(NULL, v.GetLocalProperty(kStringKey));
- v.SetLocalProperty(kStringKey, "squeamish");
- EXPECT_EQ(std::string("squeamish"), v.GetLocalProperty(kStringKey));
- v.SetLocalProperty(kStringKey, "ossifrage");
- EXPECT_EQ(std::string("ossifrage"), v.GetLocalProperty(kStringKey));
-
- // ClearProperty should restore the default value.
- v.ClearLocalProperty(kIntKey);
- EXPECT_EQ(-2, v.GetLocalProperty(kIntKey));
- v.ClearLocalProperty(kStringKey);
- EXPECT_EQ(std::string("squeamish"), v.GetLocalProperty(kStringKey));
-}
-
-namespace {
-
-class TestProperty {
- public:
- TestProperty() {}
- virtual ~TestProperty() { last_deleted_ = this; }
- static TestProperty* last_deleted() { return last_deleted_; }
-
- private:
- static TestProperty* last_deleted_;
- DISALLOW_COPY_AND_ASSIGN(TestProperty);
-};
-
-TestProperty* TestProperty::last_deleted_ = NULL;
-
-DEFINE_OWNED_VIEW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL);
-
-} // namespace
-
-TEST_F(ViewTest, OwnedProperty) {
- TestProperty* p3 = NULL;
- {
- TestView v;
- EXPECT_EQ(NULL, v.GetLocalProperty(kOwnedKey));
- TestProperty* p1 = new TestProperty();
- v.SetLocalProperty(kOwnedKey, p1);
- EXPECT_EQ(p1, v.GetLocalProperty(kOwnedKey));
- EXPECT_EQ(NULL, TestProperty::last_deleted());
-
- TestProperty* p2 = new TestProperty();
- v.SetLocalProperty(kOwnedKey, p2);
- EXPECT_EQ(p2, v.GetLocalProperty(kOwnedKey));
- EXPECT_EQ(p1, TestProperty::last_deleted());
-
- v.ClearLocalProperty(kOwnedKey);
- EXPECT_EQ(NULL, v.GetLocalProperty(kOwnedKey));
- EXPECT_EQ(p2, TestProperty::last_deleted());
-
- p3 = new TestProperty();
- v.SetLocalProperty(kOwnedKey, p3);
- EXPECT_EQ(p3, v.GetLocalProperty(kOwnedKey));
- EXPECT_EQ(p2, TestProperty::last_deleted());
- }
-
- EXPECT_EQ(p3, TestProperty::last_deleted());
-}
-
-// ViewObserver --------------------------------------------------------
-
-typedef testing::Test ViewObserverTest;
-
-bool TreeChangeParamsMatch(const ViewObserver::TreeChangeParams& lhs,
- const ViewObserver::TreeChangeParams& rhs) {
- return lhs.target == rhs.target && lhs.old_parent == rhs.old_parent &&
- lhs.new_parent == rhs.new_parent && lhs.receiver == rhs.receiver;
-}
-
-class TreeChangeObserver : public ViewObserver {
- public:
- explicit TreeChangeObserver(View* observee) : observee_(observee) {
- observee_->AddObserver(this);
- }
- ~TreeChangeObserver() override { observee_->RemoveObserver(this); }
-
- void Reset() {
- received_params_.clear();
- }
-
- const std::vector<TreeChangeParams>& received_params() {
- return received_params_;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnTreeChanging(const TreeChangeParams& params) override {
- received_params_.push_back(params);
- }
- void OnTreeChanged(const TreeChangeParams& params) override {
- received_params_.push_back(params);
- }
-
- View* observee_;
- std::vector<TreeChangeParams> received_params_;
-
- DISALLOW_COPY_AND_ASSIGN(TreeChangeObserver);
-};
-
-// Adds/Removes v11 to v1.
-TEST_F(ViewObserverTest, TreeChange_SimpleAddRemove) {
- TestView v1;
- TreeChangeObserver o1(&v1);
- EXPECT_TRUE(o1.received_params().empty());
-
- TestView v11;
- TreeChangeObserver o11(&v11);
- EXPECT_TRUE(o11.received_params().empty());
-
- // Add.
-
- v1.AddChild(&v11);
-
- EXPECT_EQ(2U, o1.received_params().size());
- ViewObserver::TreeChangeParams p1;
- p1.target = &v11;
- p1.receiver = &v1;
- p1.old_parent = NULL;
- p1.new_parent = &v1;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back()));
-
- EXPECT_EQ(2U, o11.received_params().size());
- ViewObserver::TreeChangeParams p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back()));
-
- o1.Reset();
- o11.Reset();
- EXPECT_TRUE(o1.received_params().empty());
- EXPECT_TRUE(o11.received_params().empty());
-
- // Remove.
-
- v1.RemoveChild(&v11);
-
- EXPECT_EQ(2U, o1.received_params().size());
- p1.target = &v11;
- p1.receiver = &v1;
- p1.old_parent = &v1;
- p1.new_parent = NULL;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front()));
-
- EXPECT_EQ(2U, o11.received_params().size());
- p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back()));
-}
-
-// Creates these two trees:
-// v1
-// +- v11
-// v111
-// +- v1111
-// +- v1112
-// Then adds/removes v111 from v11.
-TEST_F(ViewObserverTest, TreeChange_NestedAddRemove) {
- TestView v1, v11, v111, v1111, v1112;
-
- // Root tree.
- v1.AddChild(&v11);
-
- // Tree to be attached.
- v111.AddChild(&v1111);
- v111.AddChild(&v1112);
-
- TreeChangeObserver o1(&v1), o11(&v11), o111(&v111), o1111(&v1111),
- o1112(&v1112);
- ViewObserver::TreeChangeParams p1, p11, p111, p1111, p1112;
-
- // Add.
-
- v11.AddChild(&v111);
-
- EXPECT_EQ(2U, o1.received_params().size());
- p1.target = &v111;
- p1.receiver = &v1;
- p1.old_parent = NULL;
- p1.new_parent = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back()));
-
- EXPECT_EQ(2U, o11.received_params().size());
- p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back()));
-
- EXPECT_EQ(2U, o111.received_params().size());
- p111 = p11;
- p111.receiver = &v111;
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back()));
-
- EXPECT_EQ(2U, o1111.received_params().size());
- p1111 = p111;
- p1111.receiver = &v1111;
- EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().back()));
-
- EXPECT_EQ(2U, o1112.received_params().size());
- p1112 = p111;
- p1112.receiver = &v1112;
- EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().back()));
-
- // Remove.
- o1.Reset();
- o11.Reset();
- o111.Reset();
- o1111.Reset();
- o1112.Reset();
- EXPECT_TRUE(o1.received_params().empty());
- EXPECT_TRUE(o11.received_params().empty());
- EXPECT_TRUE(o111.received_params().empty());
- EXPECT_TRUE(o1111.received_params().empty());
- EXPECT_TRUE(o1112.received_params().empty());
-
- v11.RemoveChild(&v111);
-
- EXPECT_EQ(2U, o1.received_params().size());
- p1.target = &v111;
- p1.receiver = &v1;
- p1.old_parent = &v11;
- p1.new_parent = NULL;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front()));
-
- EXPECT_EQ(2U, o11.received_params().size());
- p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
-
- EXPECT_EQ(2U, o111.received_params().size());
- p111 = p11;
- p111.receiver = &v111;
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back()));
-
- EXPECT_EQ(2U, o1111.received_params().size());
- p1111 = p111;
- p1111.receiver = &v1111;
- EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().back()));
-
- EXPECT_EQ(2U, o1112.received_params().size());
- p1112 = p111;
- p1112.receiver = &v1112;
- EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().back()));
-}
-
-TEST_F(ViewObserverTest, TreeChange_Reparent) {
- TestView v1, v11, v12, v111;
- v1.AddChild(&v11);
- v1.AddChild(&v12);
- v11.AddChild(&v111);
-
- TreeChangeObserver o1(&v1), o11(&v11), o12(&v12), o111(&v111);
-
- // Reparent.
- v12.AddChild(&v111);
-
- // v1 (root) should see both changing and changed notifications.
- EXPECT_EQ(4U, o1.received_params().size());
- ViewObserver::TreeChangeParams p1;
- p1.target = &v111;
- p1.receiver = &v1;
- p1.old_parent = &v11;
- p1.new_parent = &v12;
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back()));
-
- // v11 should see changing notifications.
- EXPECT_EQ(2U, o11.received_params().size());
- ViewObserver::TreeChangeParams p11;
- p11 = p1;
- p11.receiver = &v11;
- EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front()));
-
- // v12 should see changed notifications.
- EXPECT_EQ(2U, o12.received_params().size());
- ViewObserver::TreeChangeParams p12;
- p12 = p1;
- p12.receiver = &v12;
- EXPECT_TRUE(TreeChangeParamsMatch(p12, o12.received_params().back()));
-
- // v111 should see both changing and changed notifications.
- EXPECT_EQ(2U, o111.received_params().size());
- ViewObserver::TreeChangeParams p111;
- p111 = p1;
- p111.receiver = &v111;
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front()));
- EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back()));
-}
-
-namespace {
-
-class OrderChangeObserver : public ViewObserver {
- public:
- struct Change {
- View* view;
- View* relative_view;
- OrderDirection direction;
- };
- typedef std::vector<Change> Changes;
-
- explicit OrderChangeObserver(View* observee) : observee_(observee) {
- observee_->AddObserver(this);
- }
- ~OrderChangeObserver() override { observee_->RemoveObserver(this); }
-
- Changes GetAndClearChanges() {
- Changes changes;
- changes_.swap(changes);
- return changes;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnViewReordering(View* view,
- View* relative_view,
- OrderDirection direction) override {
- OnViewReordered(view, relative_view, direction);
- }
-
- void OnViewReordered(View* view,
- View* relative_view,
- OrderDirection direction) override {
- Change change;
- change.view = view;
- change.relative_view = relative_view;
- change.direction = direction;
- changes_.push_back(change);
- }
-
- View* observee_;
- Changes changes_;
-
- DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, Order) {
- TestView v1, v11, v12, v13;
- v1.AddChild(&v11);
- v1.AddChild(&v12);
- v1.AddChild(&v13);
-
- // Order: v11, v12, v13
- EXPECT_EQ(3U, v1.children().size());
- EXPECT_EQ(&v11, v1.children().front());
- EXPECT_EQ(&v13, v1.children().back());
-
- {
- OrderChangeObserver observer(&v11);
-
- // Move v11 to front.
- // Resulting order: v12, v13, v11
- v11.MoveToFront();
- EXPECT_EQ(&v12, v1.children().front());
- EXPECT_EQ(&v11, v1.children().back());
-
- OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(&v11, changes[0].view);
- EXPECT_EQ(&v13, changes[0].relative_view);
- EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[0].direction);
-
- EXPECT_EQ(&v11, changes[1].view);
- EXPECT_EQ(&v13, changes[1].relative_view);
- EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[1].direction);
- }
-
- {
- OrderChangeObserver observer(&v11);
-
- // Move v11 to back.
- // Resulting order: v11, v12, v13
- v11.MoveToBack();
- EXPECT_EQ(&v11, v1.children().front());
- EXPECT_EQ(&v13, v1.children().back());
-
- OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(&v11, changes[0].view);
- EXPECT_EQ(&v12, changes[0].relative_view);
- EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[0].direction);
-
- EXPECT_EQ(&v11, changes[1].view);
- EXPECT_EQ(&v12, changes[1].relative_view);
- EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[1].direction);
- }
-
- {
- OrderChangeObserver observer(&v11);
-
- // Move v11 above v12.
- // Resulting order: v12. v11, v13
- v11.Reorder(&v12, ORDER_DIRECTION_ABOVE);
- EXPECT_EQ(&v12, v1.children().front());
- EXPECT_EQ(&v13, v1.children().back());
-
- OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(&v11, changes[0].view);
- EXPECT_EQ(&v12, changes[0].relative_view);
- EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[0].direction);
-
- EXPECT_EQ(&v11, changes[1].view);
- EXPECT_EQ(&v12, changes[1].relative_view);
- EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[1].direction);
- }
-
- {
- OrderChangeObserver observer(&v11);
-
- // Move v11 below v12.
- // Resulting order: v11, v12, v13
- v11.Reorder(&v12, ORDER_DIRECTION_BELOW);
- EXPECT_EQ(&v11, v1.children().front());
- EXPECT_EQ(&v13, v1.children().back());
-
- OrderChangeObserver::Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(&v11, changes[0].view);
- EXPECT_EQ(&v12, changes[0].relative_view);
- EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[0].direction);
-
- EXPECT_EQ(&v11, changes[1].view);
- EXPECT_EQ(&v12, changes[1].relative_view);
- EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[1].direction);
- }
-}
-
-namespace {
-
-typedef std::vector<std::string> Changes;
-
-std::string ViewIdToString(Id id) {
- return (id == 0) ? "null" :
- base::StringPrintf("%d,%d", HiWord(id), LoWord(id));
-}
-
-std::string RectToString(const Rect& rect) {
- return base::StringPrintf("%d,%d %dx%d",
- rect.x, rect.y, rect.width, rect.height);
-}
-
-class BoundsChangeObserver : public ViewObserver {
- public:
- explicit BoundsChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- ~BoundsChangeObserver() override { view_->RemoveObserver(this); }
-
- Changes GetAndClearChanges() {
- Changes changes;
- changes.swap(changes_);
- return changes;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnViewBoundsChanging(View* view,
- const Rect& old_bounds,
- const Rect& new_bounds) override {
- changes_.push_back(
- base::StringPrintf(
- "view=%s old_bounds=%s new_bounds=%s phase=changing",
- ViewIdToString(view->id()).c_str(),
- RectToString(old_bounds).c_str(),
- RectToString(new_bounds).c_str()));
- }
- void OnViewBoundsChanged(View* view,
- const Rect& old_bounds,
- const Rect& new_bounds) override {
- changes_.push_back(
- base::StringPrintf(
- "view=%s old_bounds=%s new_bounds=%s phase=changed",
- ViewIdToString(view->id()).c_str(),
- RectToString(old_bounds).c_str(),
- RectToString(new_bounds).c_str()));
- }
-
- View* view_;
- Changes changes_;
-
- DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, SetBounds) {
- TestView v1;
- {
- BoundsChangeObserver observer(&v1);
- Rect rect;
- rect.width = rect.height = 100;
- v1.SetBounds(rect);
-
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ(
- "view=0,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100 phase=changing",
- changes[0]);
- EXPECT_EQ(
- "view=0,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100 phase=changed",
- changes[1]);
- }
-}
-
-namespace {
-
-class VisibilityChangeObserver : public ViewObserver {
- public:
- explicit VisibilityChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- ~VisibilityChangeObserver() override { view_->RemoveObserver(this); }
-
- Changes GetAndClearChanges() {
- Changes changes;
- changes.swap(changes_);
- return changes;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnViewVisibilityChanging(View* view) override {
- changes_.push_back(
- base::StringPrintf("view=%s phase=changing visibility=%s",
- ViewIdToString(view->id()).c_str(),
- view->visible() ? "true" : "false"));
- }
- void OnViewVisibilityChanged(View* view) override {
- changes_.push_back(base::StringPrintf("view=%s phase=changed visibility=%s",
- ViewIdToString(view->id()).c_str(),
- view->visible() ? "true" : "false"));
- }
-
- View* view_;
- Changes changes_;
-
- DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, SetVisible) {
- TestView v1;
- EXPECT_TRUE(v1.visible());
- {
- // Change visibility from true to false and make sure we get notifications.
- VisibilityChangeObserver observer(&v1);
- v1.SetVisible(false);
-
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(2U, changes.size());
- EXPECT_EQ("view=0,1 phase=changing visibility=true", changes[0]);
- EXPECT_EQ("view=0,1 phase=changed visibility=false", changes[1]);
- }
- {
- // Set visible to existing value and verify no notifications.
- VisibilityChangeObserver observer(&v1);
- v1.SetVisible(false);
- EXPECT_TRUE(observer.GetAndClearChanges().empty());
- }
-}
-
-TEST_F(ViewObserverTest, SetVisibleParent) {
- TestView parent;
- ViewPrivate(&parent).set_id(1);
- TestView child;
- ViewPrivate(&child).set_id(2);
- parent.AddChild(&child);
- EXPECT_TRUE(parent.visible());
- EXPECT_TRUE(child.visible());
- {
- // Change visibility from true to false and make sure we get notifications
- // on the parent.
- VisibilityChangeObserver observer(&parent);
- child.SetVisible(false);
-
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(1U, changes.size());
- EXPECT_EQ("view=0,2 phase=changed visibility=false", changes[0]);
- }
-}
-
-TEST_F(ViewObserverTest, SetVisibleChild) {
- TestView parent;
- ViewPrivate(&parent).set_id(1);
- TestView child;
- ViewPrivate(&child).set_id(2);
- parent.AddChild(&child);
- EXPECT_TRUE(parent.visible());
- EXPECT_TRUE(child.visible());
- {
- // Change visibility from true to false and make sure we get notifications
- // on the child.
- VisibilityChangeObserver observer(&child);
- parent.SetVisible(false);
-
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(1U, changes.size());
- EXPECT_EQ("view=0,1 phase=changed visibility=false", changes[0]);
- }
-}
-
-namespace {
-
-class SharedPropertyChangeObserver : public ViewObserver {
- public:
- explicit SharedPropertyChangeObserver(View* view) : view_(view) {
- view_->AddObserver(this);
- }
- virtual ~SharedPropertyChangeObserver() { view_->RemoveObserver(this); }
-
- Changes GetAndClearChanges() {
- Changes changes;
- changes.swap(changes_);
- return changes;
- }
-
- private:
- // Overridden from ViewObserver:
- void OnViewSharedPropertyChanged(
- View* view,
- const std::string& name,
- const std::vector<uint8_t>* old_data,
- const std::vector<uint8_t>* new_data) override {
- changes_.push_back(base::StringPrintf(
- "view=%s shared property changed key=%s old_value=%s new_value=%s",
- ViewIdToString(view->id()).c_str(), name.c_str(),
- VectorToString(old_data).c_str(), VectorToString(new_data).c_str()));
- }
-
- std::string VectorToString(const std::vector<uint8_t>* data) {
- if (!data)
- return "NULL";
- std::string s;
- for (char c : *data)
- s += c;
- return s;
- }
-
- View* view_;
- Changes changes_;
-
- DISALLOW_COPY_AND_ASSIGN(SharedPropertyChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, SetLocalProperty) {
- TestView v1;
- std::vector<uint8_t> one(1, '1');
-
- {
- // Change visibility from true to false and make sure we get notifications.
- SharedPropertyChangeObserver observer(&v1);
- v1.SetSharedProperty("one", &one);
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(1U, changes.size());
- EXPECT_EQ(
- "view=0,1 shared property changed key=one old_value=NULL new_value=1",
- changes[0]);
- EXPECT_EQ(1U, v1.shared_properties().size());
- }
- {
- // Set visible to existing value and verify no notifications.
- SharedPropertyChangeObserver observer(&v1);
- v1.SetSharedProperty("one", &one);
- EXPECT_TRUE(observer.GetAndClearChanges().empty());
- EXPECT_EQ(1U, v1.shared_properties().size());
- }
- {
- // Set the value to NULL to delete it.
- // Change visibility from true to false and make sure we get notifications.
- SharedPropertyChangeObserver observer(&v1);
- v1.SetSharedProperty("one", NULL);
- Changes changes = observer.GetAndClearChanges();
- ASSERT_EQ(1U, changes.size());
- EXPECT_EQ(
- "view=0,1 shared property changed key=one old_value=1 new_value=NULL",
- changes[0]);
- EXPECT_EQ(0U, v1.shared_properties().size());
- }
- {
- // Setting a null property to null shouldn't update us.
- SharedPropertyChangeObserver observer(&v1);
- v1.SetSharedProperty("one", NULL);
- EXPECT_TRUE(observer.GetAndClearChanges().empty());
- EXPECT_EQ(0U, v1.shared_properties().size());
- }
-}
-
-namespace {
-
-typedef std::pair<const void*, intptr_t> PropertyChangeInfo;
-
-class LocalPropertyChangeObserver : public ViewObserver {
- public:
- explicit LocalPropertyChangeObserver(View* view)
- : view_(view),
- property_key_(nullptr),
- old_property_value_(-1) {
- view_->AddObserver(this);
- }
- virtual ~LocalPropertyChangeObserver() { view_->RemoveObserver(this); }
-
- PropertyChangeInfo PropertyChangeInfoAndClear() {
- PropertyChangeInfo result(property_key_, old_property_value_);
- property_key_ = NULL;
- old_property_value_ = -3;
- return result;
- }
-
- private:
- void OnViewLocalPropertyChanged(View* window,
- const void* key,
- intptr_t old) override {
- property_key_ = key;
- old_property_value_ = old;
- }
-
- View* view_;
- const void* property_key_;
- intptr_t old_property_value_;
-
- DISALLOW_COPY_AND_ASSIGN(LocalPropertyChangeObserver);
-};
-
-} // namespace
-
-TEST_F(ViewObserverTest, LocalPropertyChanged) {
- TestView v1;
- LocalPropertyChangeObserver o(&v1);
-
- static const ViewProperty<int> prop = {-2};
-
- v1.SetLocalProperty(&prop, 1);
- EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear());
- v1.SetLocalProperty(&prop, -2);
- EXPECT_EQ(PropertyChangeInfo(&prop, 1), o.PropertyChangeInfoAndClear());
- v1.SetLocalProperty(&prop, 3);
- EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear());
- v1.ClearLocalProperty(&prop);
- EXPECT_EQ(PropertyChangeInfo(&prop, 3), o.PropertyChangeInfoAndClear());
-
- // Sanity check to see if |PropertyChangeInfoAndClear| really clears.
- EXPECT_EQ(PropertyChangeInfo(
- reinterpret_cast<const void*>(NULL), -3), o.PropertyChangeInfoAndClear());
-}
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/types.h b/mojo/services/view_manager/public/cpp/types.h
deleted file mode 100644
index 5652691..0000000
--- a/mojo/services/view_manager/public/cpp/types.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TYPES_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TYPES_H_
-
-#include <stdint.h>
-
-// Typedefs for the transport types. These typedefs match that of the mojom
-// file, see it for specifics.
-
-namespace mojo {
-
-// Used to identify views and change ids.
-typedef uint32_t Id;
-
-// Used to identify a connection as well as a connection specific view id. For
-// example, the Id for a view consists of the ConnectionSpecificId of the
-// connection and the ConnectionSpecificId of the view.
-typedef uint16_t ConnectionSpecificId;
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TYPES_H_
diff --git a/mojo/services/view_manager/public/cpp/util.h b/mojo/services/view_manager/public/cpp/util.h
deleted file mode 100644
index 33e75dd..0000000
--- a/mojo/services/view_manager/public/cpp/util.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_UTIL_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_UTIL_H_
-
-#include "view_manager/public/cpp/types.h"
-
-// TODO(beng): #$*&@#(@ MacOSX SDK!
-#if defined(HiWord)
-#undef HiWord
-#endif
-#if defined(LoWord)
-#undef LoWord
-#endif
-
-namespace mojo {
-
-inline uint16_t HiWord(uint32_t id) {
- return static_cast<uint16_t>((id >> 16) & 0xFFFF);
-}
-
-inline uint16_t LoWord(uint32_t id) {
- return static_cast<uint16_t>(id & 0xFFFF);
-}
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_UTIL_H_
diff --git a/mojo/services/view_manager/public/cpp/view.h b/mojo/services/view_manager/public/cpp/view.h
deleted file mode 100644
index 07bc5b0..0000000
--- a/mojo/services/view_manager/public/cpp/view.h
+++ /dev/null
@@ -1,206 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/observer_list.h"
-#include "geometry/public/interfaces/geometry.mojom.h"
-#include "mojo/public/cpp/bindings/array.h"
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
-#include "surfaces/public/interfaces/surface_id.mojom.h"
-#include "view_manager/public/cpp/types.h"
-#include "view_manager/public/interfaces/view_manager.mojom.h"
-#include "view_manager/public/interfaces/view_manager_constants.mojom.h"
-
-namespace mojo {
-
-class ServiceProviderImpl;
-class View;
-class ViewManager;
-class ViewObserver;
-
-// Defined in view_property.h (which we do not include)
-template <typename T>
-struct ViewProperty;
-
-// Views are owned by the ViewManager.
-// TODO(beng): Right now, you'll have to implement a ViewObserver to track
-// destruction and NULL any pointers you have.
-// Investigate some kind of smart pointer or weak pointer for these.
-class View {
- public:
- using Children = std::vector<View*>;
- using SharedProperties = std::map<std::string, std::vector<uint8_t>>;
-
- // Destroys this view and all its children.
- void Destroy();
-
- ViewManager* view_manager() { return manager_; }
-
- // Configuration.
- Id id() const { return id_; }
-
- // Geometric disposition.
- const Rect& bounds() const { return bounds_; }
- void SetBounds(const Rect& bounds);
-
- // Visibility (also see IsDrawn()). When created views are hidden.
- bool visible() const { return visible_; }
- void SetVisible(bool value);
-
- const ViewportMetrics& viewport_metrics() { return *viewport_metrics_; }
-
- // Returns the set of string to bag of byte properties. These properties are
- // shared with the view manager.
- const SharedProperties& shared_properties() const { return properties_; }
- // Sets a property. If |data| is null, this property is deleted.
- void SetSharedProperty(const std::string& name,
- const std::vector<uint8_t>* data);
-
- // Sets the |value| of the given window |property|. Setting to the default
- // value (e.g., NULL) removes the property. The caller is responsible for the
- // lifetime of any object set as a property on the View.
- //
- // These properties are not visible to the view manager.
- template <typename T>
- void SetLocalProperty(const ViewProperty<T>* property, T value);
-
- // Returns the value of the given window |property|. Returns the
- // property-specific default value if the property was not previously set.
- //
- // These properties are only visible in the current process and are not
- // shared with other mojo services.
- template <typename T>
- T GetLocalProperty(const ViewProperty<T>* property) const;
-
- // Sets the |property| to its default value. Useful for avoiding a cast when
- // setting to NULL.
- //
- // These properties are only visible in the current process and are not
- // shared with other mojo services.
- template <typename T>
- void ClearLocalProperty(const ViewProperty<T>* property);
-
- // Type of a function to delete a property that this view owns.
- typedef void (*PropertyDeallocator)(int64 value);
-
- // A View is drawn if the View and all its ancestors are visible and the
- // View is attached to the root.
- bool IsDrawn() const;
-
- // Observation.
- void AddObserver(ViewObserver* observer);
- void RemoveObserver(ViewObserver* observer);
-
- // Tree.
- View* parent() { return parent_; }
- const View* parent() const { return parent_; }
- const Children& children() const { return children_; }
- View* GetRoot() {
- return const_cast<View*>(const_cast<const View*>(this)->GetRoot());
- }
- const View* GetRoot() const;
-
- void AddChild(View* child);
- void RemoveChild(View* child);
-
- void Reorder(View* relative, OrderDirection direction);
- void MoveToFront();
- void MoveToBack();
-
- bool Contains(View* child) const;
-
- View* GetChildById(Id id);
-
- void SetSurfaceId(SurfaceIdPtr id);
-
- // Focus.
- void SetFocus();
-
- // Embedding.
- void Embed(const String& url);
- void Embed(const String& url,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services);
-
- protected:
- // This class is subclassed only by test classes that provide a public ctor.
- View();
- ~View();
-
- private:
- friend class ViewPrivate;
- friend class ViewManagerClientImpl;
-
- View(ViewManager* manager, Id id);
-
- // Called by the public {Set,Get,Clear}Property functions.
- int64 SetLocalPropertyInternal(const void* key,
- const char* name,
- PropertyDeallocator deallocator,
- int64 value,
- int64 default_value);
- int64 GetLocalPropertyInternal(const void* key, int64 default_value) const;
-
- void LocalDestroy();
- void LocalAddChild(View* child);
- void LocalRemoveChild(View* child);
- // Returns true if the order actually changed.
- bool LocalReorder(View* relative, OrderDirection direction);
- void LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds);
- void LocalSetViewportMetrics(const ViewportMetrics& old_metrics,
- const ViewportMetrics& new_metrics);
- void LocalSetDrawn(bool drawn);
-
- // Methods implementing visibility change notifications. See ViewObserver
- // for more details.
- void NotifyViewVisibilityChanged(View* target);
- // Notifies this view's observers. Returns false if |this| was deleted during
- // the call (by an observer), otherwise true.
- bool NotifyViewVisibilityChangedAtReceiver(View* target);
- // Notifies this view and its child hierarchy. Returns false if |this| was
- // deleted during the call (by an observer), otherwise true.
- bool NotifyViewVisibilityChangedDown(View* target);
- // Notifies this view and its parent hierarchy.
- void NotifyViewVisibilityChangedUp(View* target);
-
- ViewManager* manager_;
- Id id_;
- View* parent_;
- Children children_;
-
- ObserverList<ViewObserver> observers_;
-
- Rect bounds_;
- ViewportMetricsPtr viewport_metrics_;
-
- bool visible_;
-
- SharedProperties properties_;
-
- // Drawn state is derived from the visible state and the parent's visible
- // state. This field is only used if the view has no parent (eg it's a root).
- bool drawn_;
-
- // Value struct to keep the name and deallocator for this property.
- // Key cannot be used for this purpose because it can be char* or
- // WindowProperty<>.
- struct Value {
- const char* name;
- int64 value;
- PropertyDeallocator deallocator;
- };
-
- std::map<const void*, Value> prop_map_;
-
- DISALLOW_COPY_AND_ASSIGN(View);
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_
diff --git a/mojo/services/view_manager/public/cpp/view_manager.h b/mojo/services/view_manager/public/cpp/view_manager.h
deleted file mode 100644
index 5852dd2..0000000
--- a/mojo/services/view_manager/public/cpp/view_manager.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_H_
-
-#include <string>
-
-#include "view_manager/public/cpp/types.h"
-
-namespace mojo {
-class View;
-
-// Encapsulates a connection to the view manager service. A unique connection
-// is made every time an app is embedded.
-class ViewManager {
- public:
- // Returns the URL of the application that embedded this application.
- virtual const std::string& GetEmbedderURL() const = 0;
-
- // Returns the root of this connection.
- virtual View* GetRoot() = 0;
-
- // Returns a View known to this connection.
- virtual View* GetViewById(Id id) = 0;
-
- // Returns the focused view; null if focus is not yet known or another app is
- // focused.
- virtual View* GetFocusedView() = 0;
-
- // Creates and returns a new View (which is owned by the ViewManager). Views
- // are initially hidden, use SetVisible(true) to show.
- virtual View* CreateView() = 0;
-
- protected:
- virtual ~ViewManager() {}
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_H_
diff --git a/mojo/services/view_manager/public/cpp/view_manager_client_factory.h b/mojo/services/view_manager/public/cpp/view_manager_client_factory.h
deleted file mode 100644
index 35b1245..0000000
--- a/mojo/services/view_manager/public/cpp/view_manager_client_factory.h
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CLIENT_FACTORY_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CLIENT_FACTORY_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "mojo/public/cpp/application/interface_factory.h"
-#include "view_manager/public/interfaces/view_manager.mojom.h"
-
-namespace mojo {
-
-class ViewManagerDelegate;
-class Shell;
-
-// Add an instance of this class to an incoming connection to allow it to
-// instantiate ViewManagerClient implementations in response to
-// ViewManagerClient requests.
-class ViewManagerClientFactory : public InterfaceFactory<ViewManagerClient> {
- public:
- ViewManagerClientFactory(Shell* shell, ViewManagerDelegate* delegate);
- ~ViewManagerClientFactory() override;
-
- // Creates a ViewManagerClient from the supplied arguments.
- static scoped_ptr<ViewManagerClient> WeakBindViewManagerToPipe(
- ScopedMessagePipeHandle handle,
- Shell* shell,
- ViewManagerDelegate* delegate);
-
- // InterfaceFactory<ViewManagerClient> implementation.
- void Create(ApplicationConnection* connection,
- InterfaceRequest<ViewManagerClient> request) override;
-
- private:
- Shell* shell_;
- ViewManagerDelegate* delegate_;
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CLIENT_FACTORY_H_
diff --git a/mojo/services/view_manager/public/cpp/view_manager_context.h b/mojo/services/view_manager/public/cpp/view_manager_context.h
deleted file mode 100644
index 1976598..0000000
--- a/mojo/services/view_manager/public/cpp/view_manager_context.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CONTEXT_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CONTEXT_H_
-
-#include <string>
-#include <vector>
-
-#include "base/bind.h"
-#include "base/memory/scoped_ptr.h"
-#include "mojo/public/cpp/application/service_provider_impl.h"
-
-namespace mojo {
-class ApplicationImpl;
-
-class ViewManagerContext {
- public:
- explicit ViewManagerContext(ApplicationImpl* application_impl);
- ~ViewManagerContext();
-
- // Embed an application @ |url| at an appropriate View.
- // The first time this method is called in the life time of the View Manager
- // service the "appropriate View" is defined as being the service' root View.
- // Subsequent times, the implementation of this method is delegated to the
- // application embedded at the service root View. This application will have a
- // specific definition of where within its View hierarchy to embed an
- // un-parented URL.
- // |services| encapsulates services offered by the embedder to the embedded
- // app alongside this Embed() call. |exposed_services| provides a means for
- // the embedder to connect to services exposed by the embedded app.
- void Embed(const String& url);
- void Embed(const String& url,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_Services);
-
- private:
- class InternalState;
- scoped_ptr<InternalState> state_;
-
- MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerContext);
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CONTEXT_H_
diff --git a/mojo/services/view_manager/public/cpp/view_manager_delegate.h b/mojo/services/view_manager/public/cpp/view_manager_delegate.h
deleted file mode 100644
index e78e925..0000000
--- a/mojo/services/view_manager/public/cpp/view_manager_delegate.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_DELEGATE_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_DELEGATE_H_
-
-#include "mojo/public/interfaces/application/service_provider.mojom.h"
-
-namespace mojo {
-
-class View;
-class ViewManager;
-
-// Interface implemented by an application using the view manager.
-class ViewManagerDelegate {
- public:
- // Called when the application implementing this interface is embedded at
- // |root|. Every embed results in a new ViewManager and root View being
- // created. |root| and it's corresponding ViewManager are valid until
- // OnViewManagerDisconnected() is called with the same object.
- //
- // |services| exposes the services offered by the embedder to the delegate.
- //
- // |exposed_services| is an object that the delegate can add services to
- // expose to the embedder.
- //
- // Note that if a different application is subsequently embedded at |root|,
- // the pipes connecting |services| and |exposed_services| to the embedder and
- // any services obtained from them are not broken and will continue to be
- // valid.
- virtual void OnEmbed(View* root,
- InterfaceRequest<ServiceProvider> services,
- ServiceProviderPtr exposed_services) = 0;
-
- // Called when a connection to the view manager service is closed.
- // |view_manager| is not valid after this function returns.
- virtual void OnViewManagerDisconnected(ViewManager* view_manager) = 0;
-
- protected:
- virtual ~ViewManagerDelegate() {}
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_DELEGATE_H_
diff --git a/mojo/services/view_manager/public/cpp/view_observer.h b/mojo/services/view_manager/public/cpp/view_observer.h
deleted file mode 100644
index 7430566..0000000
--- a/mojo/services/view_manager/public/cpp/view_observer.h
+++ /dev/null
@@ -1,108 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_OBSERVER_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_OBSERVER_H_
-
-#include <vector>
-
-#include "base/basictypes.h"
-
-#include "input_events/public/interfaces/input_events.mojom.h"
-#include "view_manager/public/cpp/view.h"
-
-namespace mojo {
-
-class View;
-
-// A note on -ing and -ed suffixes:
-//
-// -ing methods are called before changes are applied to the local view model.
-// -ed methods are called after changes are applied to the local view model.
-//
-// If the change originated from another connection to the view manager, it's
-// possible that the change has already been applied to the service-side model
-// prior to being called, so for example in the case of OnViewDestroying(), it's
-// possible the view has already been destroyed on the service side.
-
-class ViewObserver {
- public:
- struct TreeChangeParams {
- TreeChangeParams();
- View* target;
- View* old_parent;
- View* new_parent;
- View* receiver;
- };
-
- virtual void OnTreeChanging(const TreeChangeParams& params) {}
- virtual void OnTreeChanged(const TreeChangeParams& params) {}
-
- virtual void OnViewReordering(View* view,
- View* relative_view,
- OrderDirection direction) {}
- virtual void OnViewReordered(View* view,
- View* relative_view,
- OrderDirection direction) {}
-
- virtual void OnViewDestroying(View* view) {}
- virtual void OnViewDestroyed(View* view) {}
-
- virtual void OnViewBoundsChanging(View* view,
- const Rect& old_bounds,
- const Rect& new_bounds) {}
- virtual void OnViewBoundsChanged(View* view,
- const Rect& old_bounds,
- const Rect& new_bounds) {}
-
- virtual void OnViewViewportMetricsChanged(View* view,
- const ViewportMetrics& old_bounds,
- const ViewportMetrics& new_bounds) {
- }
-
- virtual void OnCaptureChanged(View* gained_capture, View* lost_capture) {}
- virtual void OnViewFocusChanged(View* gained_focus, View* lost_focus) {}
- virtual void OnViewActivationChanged(View* gained_active, View* lost_active) {
- }
-
- virtual void OnViewInputEvent(View* view, const EventPtr& event) {}
-
- virtual void OnViewVisibilityChanging(View* view) {}
- virtual void OnViewVisibilityChanged(View* view) {}
-
- // Invoked when this View's shared properties have changed. This can either
- // be caused by SetSharedProperty() being called locally, or by us receiving
- // a mojo message that this property has changed. If this property has been
- // added, |old_data| is null. If this property was removed, |new_data| is
- // null.
- virtual void OnViewSharedPropertyChanged(
- View* view,
- const std::string& name,
- const std::vector<uint8_t>* old_data,
- const std::vector<uint8_t>* new_data) {}
-
- // Invoked when SetProperty() or ClearProperty() is called on the window.
- // |key| is either a WindowProperty<T>* (SetProperty, ClearProperty). Either
- // way, it can simply be compared for equality with the property
- // constant. |old| is the old property value, which must be cast to the
- // appropriate type before use.
- virtual void OnViewLocalPropertyChanged(
- View* view,
- const void* key,
- intptr_t old) {}
-
- virtual void OnViewEmbeddedAppDisconnected(View* view) {}
-
- // Sent when the drawn state changes. This is only sent for the root nodes
- // when embedded.
- virtual void OnViewDrawnChanging(View* view) {}
- virtual void OnViewDrawnChanged(View* view) {}
-
- protected:
- virtual ~ViewObserver() {}
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_OBSERVER_H_
diff --git a/mojo/services/view_manager/public/cpp/view_property.h b/mojo/services/view_manager/public/cpp/view_property.h
deleted file mode 100644
index d3a345f..0000000
--- a/mojo/services/view_manager/public/cpp/view_property.h
+++ /dev/null
@@ -1,140 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_PROPERTY_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_PROPERTY_H_
-
-#include "base/basictypes.h"
-
-// This header should be included by code that defines ViewProperties. It
-// should not be included by code that only gets and sets ViewProperties.
-//
-// To define a new ViewProperty:
-//
-// #include "view_manager/public/cpp/view_property.h"
-//
-// DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(FOO_EXPORT, MyType);
-// namespace foo {
-// // Use this to define an exported property that is premitive,
-// // or a pointer you don't want automatically deleted.
-// DEFINE_VIEW_PROPERTY_KEY(MyType, kMyKey, MyDefault);
-//
-// // Use this to define an exported property whose value is a heap
-// // allocated object, and has to be owned and freed by the view.
-// DEFINE_OWNED_VIEW_PROPERTY_KEY(gfx::Rect, kRestoreBoundsKey, nullptr);
-//
-// // Use this to define a non exported property that is primitive,
-// // or a pointer you don't want to automatically deleted, and is used
-// // only in a specific file. This will define the property in an unnamed
-// // namespace which cannot be accessed from another file.
-// DEFINE_LOCAL_VIEW_PROPERTY_KEY(MyType, kMyKey, MyDefault);
-//
-// } // foo namespace
-//
-// To define a new type used for ViewProperty.
-//
-// // outside all namespaces:
-// DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(FOO_EXPORT, MyType)
-//
-// If a property type is not exported, use DECLARE_VIEW_PROPERTY_TYPE(MyType)
-// which is a shorthand for DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(, MyType).
-
-namespace mojo {
-namespace {
-
-// No single new-style cast works for every conversion to/from int64, so we
-// need this helper class. A third specialization is needed for bool because
-// MSVC warning C4800 (forcing value to bool) is not suppressed by an explicit
-// cast (!).
-template <typename T>
-class ViewPropertyCaster {
- public:
- static int64 ToInt64(T x) { return static_cast<int64>(x); }
- static T FromInt64(int64 x) { return static_cast<T>(x); }
-};
-template <typename T>
-class ViewPropertyCaster<T*> {
- public:
- static int64 ToInt64(T* x) { return reinterpret_cast<int64>(x); }
- static T* FromInt64(int64 x) { return reinterpret_cast<T*>(x); }
-};
-template <>
-class ViewPropertyCaster<bool> {
- public:
- static int64 ToInt64(bool x) { return static_cast<int64>(x); }
- static bool FromInt64(int64 x) { return x != 0; }
-};
-
-} // namespace
-
-template <typename T>
-struct ViewProperty {
- T default_value;
- const char* name;
- View::PropertyDeallocator deallocator;
-};
-
-template <typename T>
-void View::SetLocalProperty(const ViewProperty<T>* property, T value) {
- int64 old = SetLocalPropertyInternal(
- property, property->name,
- value == property->default_value ? nullptr : property->deallocator,
- ViewPropertyCaster<T>::ToInt64(value),
- ViewPropertyCaster<T>::ToInt64(property->default_value));
- if (property->deallocator &&
- old != ViewPropertyCaster<T>::ToInt64(property->default_value)) {
- (*property->deallocator)(old);
- }
-}
-
-template <typename T>
-T View::GetLocalProperty(const ViewProperty<T>* property) const {
- return ViewPropertyCaster<T>::FromInt64(GetLocalPropertyInternal(
- property, ViewPropertyCaster<T>::ToInt64(property->default_value)));
-}
-
-template <typename T>
-void View::ClearLocalProperty(const ViewProperty<T>* property) {
- SetLocalProperty(property, property->default_value);
-}
-
-} // namespace mojo
-
-// Macros to instantiate the property getter/setter template functions.
-#define DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(EXPORT, T) \
- template EXPORT void mojo::View::SetLocalProperty( \
- const mojo::ViewProperty<T>*, T); \
- template EXPORT T mojo::View::GetLocalProperty(const mojo::ViewProperty<T>*) \
- const; \
- template EXPORT void mojo::View::ClearLocalProperty( \
- const mojo::ViewProperty<T>*);
-#define DECLARE_VIEW_PROPERTY_TYPE(T) DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(, T)
-
-#define DEFINE_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
- COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64), property_type_too_large); \
- namespace { \
- const mojo::ViewProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
- } \
- const mojo::ViewProperty<TYPE>* const NAME = &NAME##_Value;
-
-#define DEFINE_LOCAL_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
- COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64), property_type_too_large); \
- namespace { \
- const mojo::ViewProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \
- const mojo::ViewProperty<TYPE>* const NAME = &NAME##_Value; \
- }
-
-#define DEFINE_OWNED_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \
- namespace { \
- void Deallocator##NAME(int64 p) { \
- enum { type_must_be_complete = sizeof(TYPE) }; \
- delete mojo::ViewPropertyCaster<TYPE*>::FromInt64(p); \
- } \
- const mojo::ViewProperty<TYPE*> NAME##_Value = {DEFAULT, \
- #NAME, \
- &Deallocator##NAME}; \
- } \
- const mojo::ViewProperty<TYPE*>* const NAME = &NAME##_Value;
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_PROPERTY_H_
diff --git a/mojo/services/view_manager/public/cpp/view_tracker.cc b/mojo/services/view_manager/public/cpp/view_tracker.cc
deleted file mode 100644
index 317b97a..0000000
--- a/mojo/services/view_manager/public/cpp/view_tracker.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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 "view_manager/public/cpp/view_tracker.h"
-
-namespace mojo {
-
-ViewTracker::ViewTracker() {
-}
-
-ViewTracker::~ViewTracker() {
- for (Views::iterator i = views_.begin(); i != views_.end(); ++i)
- (*i)->RemoveObserver(this);
-}
-
-void ViewTracker::Add(View* view) {
- if (views_.count(view))
- return;
-
- view->AddObserver(this);
- views_.insert(view);
-}
-
-void ViewTracker::Remove(View* view) {
- if (views_.count(view)) {
- views_.erase(view);
- view->RemoveObserver(this);
- }
-}
-
-bool ViewTracker::Contains(View* view) {
- return views_.count(view) > 0;
-}
-
-void ViewTracker::OnViewDestroying(View* view) {
- DCHECK_GT(views_.count(view), 0u);
- Remove(view);
-}
-
-} // namespace mojo
diff --git a/mojo/services/view_manager/public/cpp/view_tracker.h b/mojo/services/view_manager/public/cpp/view_tracker.h
deleted file mode 100644
index 05325b7..0000000
--- a/mojo/services/view_manager/public/cpp/view_tracker.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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.
-
-#ifndef MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_TRACKER_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_TRACKER_H_
-
-#include <set>
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "view_manager/public/cpp/view_observer.h"
-
-namespace mojo {
-
-class ViewTracker : public ViewObserver {
- public:
- using Views = std::set<View*>;
-
- ViewTracker();
- ~ViewTracker() override;
-
- // Returns the set of views being observed.
- const std::set<View*>& views() const { return views_; }
-
- // Adds |view| to the set of Views being tracked.
- void Add(View* view);
-
- // Removes |view| from the set of views being tracked.
- void Remove(View* view);
-
- // Returns true if |view| was previously added and has not been removed or
- // deleted.
- bool Contains(View* view);
-
- // ViewObserver overrides:
- virtual void OnViewDestroying(View* view) override;
-
- private:
- Views views_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewTracker);
-};
-
-} // namespace mojo
-
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_TRACKER_H_
diff --git a/mojo/services/view_manager/public/interfaces/animations.mojom b/mojo/services/view_manager/public/interfaces/animations.mojom
deleted file mode 100644
index 59572c4..0000000
--- a/mojo/services/view_manager/public/interfaces/animations.mojom
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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.
-
-module mojo;
-
-import "geometry/public/interfaces/geometry.mojom";
-
-enum AnimationTweenType {
- LINEAR,
- EASE_IN,
- EASE_OUT,
- EASE_IN_OUT,
-};
-
-enum AnimationProperty {
- // Used for pausing.
- NONE,
- OPACITY,
- TRANSFORM,
-};
-
-struct AnimationValue {
- float float_value;
- Transform transform;
-};
-
-// Identifies how a particular property should be animated between a start and
-// target value.
-struct AnimationElement {
- AnimationProperty property;
-
- // Duration is in microseconds.
- int64 duration;
-
- AnimationTweenType tween_type;
-
- // If not specified the start value is taken from either the current value
- // (for the first element) or the target_value of the previous element.
- AnimationValue? start_value;
-
- // target_value may be null when property is NONE.
- AnimationValue? target_value;
-};
-
-// An AnimationSequence consists of a number of AnimationElements to animate.
-// Each element is animated serially.
-struct AnimationSequence {
- // Number of times to run the sequence. Value of 0 means run until
- // explicitly stopped.
- uint32 cycle_count;
-
- array<AnimationElement> elements;
-};
-
-// AnimationGroup identifies a view and a set of AnimationSequences to apply
-// to the view. Each sequence is run in parallel.
-struct AnimationGroup {
- uint32 view_id;
- array<AnimationSequence> sequences;
-};
diff --git a/mojo/services/view_manager/public/interfaces/view_manager.mojom b/mojo/services/view_manager/public/interfaces/view_manager.mojom
deleted file mode 100644
index 23238d5..0000000
--- a/mojo/services/view_manager/public/interfaces/view_manager.mojom
+++ /dev/null
@@ -1,207 +0,0 @@
-// 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.
-
-module mojo;
-
-import "geometry/public/interfaces/geometry.mojom";
-import "input_events/public/interfaces/input_events.mojom";
-import "mojo/public/interfaces/application/service_provider.mojom";
-import "native_viewport/public/interfaces/native_viewport.mojom";
-import "surfaces/public/interfaces/surface_id.mojom";
-import "view_manager/public/interfaces/view_manager_constants.mojom";
-
-struct ViewData {
- uint32 parent_id;
- uint32 view_id;
- mojo.Rect bounds;
- map<string, array<uint8>> properties;
- // True if this view is visible. The view may not be drawn on screen (see
- // drawn for specifics).
- bool visible;
- // True if this view is drawn on screen. A view is drawn if attached to the
- // root and all ancestors (including this view) are visible.
- bool drawn;
- ViewportMetrics viewport_metrics;
-};
-
-enum ErrorCode {
- NONE,
- VALUE_IN_USE,
- ILLEGAL_ARGUMENT,
-};
-
-// Views are identified by a uint32. The upper 16 bits are the connection id,
-// and the lower 16 the id assigned by the client.
-//
-// The root view is identified with a connection id of 0, and value of 1.
-[Client=ViewManagerClient]
-interface ViewManagerService {
- // Creates a new view with the specified id. It is up to the client to ensure
- // the id is unique to the connection (the id need not be globally unique).
- // Additionally the connection id (embedded in |view_id|) must match that of
- // the connection.
- // Errors:
- // ERROR_CODE_VALUE_IN_USE: a view already exists with the specified id.
- // ERROR_CODE_ILLEGAL_ARGUMENT: The connection part of |view_id| does not
- // match the connection id of the client.
- //
- // TODO(erg): Once we have default values in mojo, make this take a map of
- // properties.
- CreateView(uint32 view_id) => (ErrorCode error_code);
-
- // Deletes a view. This does not recurse. No hierarchy change notifications
- // are sent as a result of this. Only the connection that created the view can
- // delete it.
- DeleteView(uint32 view_id) => (bool success);
-
- // Sets the specified bounds of the specified view.
- SetViewBounds(uint32 view_id, mojo.Rect bounds) => (bool success);
-
- // Sets the visibility of the specified view to |visible|. Connections are
- // allowed to change the visibility of any view they have created, as well as
- // any of their roots.
- SetViewVisibility(uint32 view_id, bool visible) => (bool success);
-
- // Sets an individual named property. Setting an individual property to null
- // deletes the property.
- SetViewProperty(uint32 view_id,
- string name,
- array<uint8>? value) => (bool success);
-
- // Reparents a view.
- // This fails for any of the following reasons:
- // . |parent| or |child| does not identify a valid view.
- // . |child| is an ancestor of |parent|.
- // . |child| is already a child of |parent|.
- //
- // This may result in a connection getting OnViewDeleted(). See
- // RemoveViewFromParent for details.
- AddView(uint32 parent, uint32 child) => (bool success);
-
- // Removes a view from its current parent. This fails if the view is not
- // valid or the view already has no parent.
- //
- // Removing a view from a parent may result in OnViewDeleted() being sent to
- // other connections. For example, connection A has views 1 and 2, with 2 a
- // child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets
- // OnViewDeleted(). This is done as view 2 is effectively no longer visible to
- // connection B.
- RemoveViewFromParent(uint32 view_id) => (bool success);
-
- // Reorders a view in its parent, relative to |relative_view_id| according to
- // |direction|.
- // Only the connection that created the view's parent can reorder its
- // children.
- ReorderView(uint32 view_id,
- uint32 relative_view_id,
- OrderDirection direction) => (bool success);
-
- // Returns the views comprising the tree starting at |view_id|. |view_id| is
- // the first result in the return value, unless |view_id| is invalid, in which
- // case an empty vector is returned. The views are visited using a depth first
- // search (pre-order).
- GetViewTree(uint32 view_id) => (array<ViewData> views);
-
- // Shows the surface in the specified view.
- SetViewSurfaceId(uint32 view_id, SurfaceId surface_id) => (bool success);
-
- // Embeds the app for |url| in the specified view. More specifically this
- // creates a new connection to the specified url, expecting to get a
- // ViewManagerClient and configures it with the root view |view|. Fails
- // if |view| was not created by this connection.
- //
- // A view may only be a root of one connection at a time. Subsequent calls to
- // Embed() for the same view result in the view being removed from the
- // currently embedded app. The embedded app is told this by way of
- // OnViewDeleted().
- //
- // The embedder can detect when the embedded app disconnects by way of
- // OnEmbeddedAppDisconnected().
- //
- // When a connection embeds an app the connection no longer has priviledges
- // to access or see any of the children of the view. If the view had existing
- // children the children are removed. The one exception is the root
- // connection.
- //
- // |services| encapsulates services offered by the embedder to the embedded
- // app alongside this Embed() call. |exposed_services| provides a means for
- // the embedder to connect to services exposed by the embedded app. Note that
- // if a different app is subsequently embedded at |view_id| the
- // ServiceProvider connections to its client in the embedded app and any
- // services it provided are not broken and continue to be valid.
- Embed(string url,
- uint32 view_id,
- ServiceProvider&? services,
- ServiceProvider? exposed_services) => (bool success);
-};
-
-// Changes to views are not sent to the connection that originated the
-// change. For example, if connection 1 changes the bounds of a view by calling
-// SetBounds(), connection 1 does not receive OnViewBoundsChanged().
-[Client=ViewManagerService]
-interface ViewManagerClient {
- // Invoked when the client application has been embedded at |root|.
- // See Embed() on ViewManagerService for more details. |window_manager_pipe|
- // is a pipe to the WindowManager.
- OnEmbed(uint16 connection_id,
- string embedder_url,
- ViewData root,
- ServiceProvider&? services,
- ServiceProvider? exposed_services,
- handle<message_pipe> window_manager_pipe);
-
- // Invoked when the application embedded at |view| is disconnected.
- OnEmbeddedAppDisconnected(uint32 view);
-
- // Invoked when a view's bounds have changed.
- OnViewBoundsChanged(uint32 view,
- mojo.Rect old_bounds,
- mojo.Rect new_bounds);
-
- // Invoked when the viewport metrics for the view have changed.
- // Clients are expected to propagate this to the view tree.
- OnViewViewportMetricsChanged(mojo.ViewportMetrics old_metrics,
- mojo.ViewportMetrics new_metrics);
-
- // Invoked when a change is done to the hierarchy. A value of 0 is used to
- // identify a null view. For example, if the old_parent is NULL, 0 is
- // supplied.
- // |views| contains any views that are that the client has not been told
- // about. This is not sent for hierarchy changes of views not known to this
- // client or not attached to the tree.
- OnViewHierarchyChanged(uint32 view,
- uint32 new_parent,
- uint32 old_parent,
- array<ViewData> views);
-
- // Invoked when the order of views within a parent changes.
- OnViewReordered(uint32 view_id,
- uint32 relative_view_id,
- OrderDirection direction);
-
- // Invoked when a view is deleted.
- OnViewDeleted(uint32 view);
-
- // Invoked when the visibility of the specified view changes.
- OnViewVisibilityChanged(uint32 view, bool visible);
-
- // Invoked when a change to the visibility of |view| or one if it's ancestors
- // is done such that the drawn state changes. This is only invoked for the
- // top most view of a particular connection. For example, if you have the
- // hierarchy: A -> B1 -> B2 (B2 is a child of B1 and B1 a child of A), B1/B2
- // are from connection 2 and A from connection 1 with all views visible and
- // drawn and the visiblity of A changes to false, then connection 2 is told
- // the drawn state of B1 has changed (to false), but is not told anything
- // about B2 as it's drawn state can be calculated from that of B1.
- //
- // NOTE: This is not invoked if OnViewVisibilityChanged() is invoked.
- OnViewDrawnStateChanged(uint32 view, bool drawn);
-
- // Invoked when a view property is changed. If this change is a removal,
- // |new_data| is null.
- OnViewSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data);
-
- // Invoked when an event is targeted at the specified view.
- OnViewInputEvent(uint32 view, mojo.Event event) => ();
-};
diff --git a/mojo/services/view_manager/public/interfaces/view_manager_constants.mojom b/mojo/services/view_manager/public/interfaces/view_manager_constants.mojom
deleted file mode 100644
index 14bd363..0000000
--- a/mojo/services/view_manager/public/interfaces/view_manager_constants.mojom
+++ /dev/null
@@ -1,10 +0,0 @@
-// 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.
-
-module mojo;
-
-enum OrderDirection {
- ABOVE = 1,
- BELOW,
-};
diff --git a/mojo/services/window_manager/public/interfaces/window_manager.mojom b/mojo/services/window_manager/public/interfaces/window_manager.mojom
deleted file mode 100644
index e365fb6..0000000
--- a/mojo/services/window_manager/public/interfaces/window_manager.mojom
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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.
-
-module mojo;
-
-import "input_events/public/interfaces/input_events.mojom";
-import "mojo/public/interfaces/application/service_provider.mojom";
-
-[Client=WindowManagerClient]
-interface WindowManager {
- // Requests the WindowManager to embed the app for |url| at an appropriate
- // View. See ViewMangerService::Embed() for details on |services| and
- // |exposed_services|.
- Embed(string url, ServiceProvider&? services, ServiceProvider? exposed_services);
-
- SetCapture(uint32 view_id) => (bool success);
- FocusWindow(uint32 view_id) => (bool success);
- ActivateWindow(uint32 view_id) => (bool success);
-
- GetFocusedAndActiveViews() => (uint32 focused_view_id, uint32 active_view_id);
-};
-
-interface WindowManagerClient {
- OnCaptureChanged(uint32 old_capture_view_id, uint32 new_capture_view_id);
- OnFocusChanged(uint32 old_focused_view_id, uint32 new_focused_view_id);
- OnActiveWindowChanged(uint32 old_focused_view_id, uint32 new_focused_view_id);
-};
diff --git a/mojo/services/window_manager/public/interfaces/window_manager_internal.mojom b/mojo/services/window_manager/public/interfaces/window_manager_internal.mojom
deleted file mode 100644
index 6b85632..0000000
--- a/mojo/services/window_manager/public/interfaces/window_manager_internal.mojom
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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.
-
-module mojo;
-
-import "geometry/public/interfaces/geometry.mojom";
-import "input_events/public/interfaces/input_events.mojom";
-
-// WindowManagerInternal is an interface provided by the WindowManager
-// exclusively to the ViewManager.
-interface WindowManagerInternal {
- // Creates a connection to the WindowManager specifically for a connection to
- // the ViewManager. |connection_id| is the id of the connection to the
- // ViewManager. See view_manager.mojom for details on the id.
- CreateWindowManagerForViewManagerClient(
- uint16 connection_id,
- handle<message_pipe> window_manager_pipe);
-};
-
-// WindowManagerInternalClient is an interface provide by the ViewManager
-// exclusively to the WindowManager. It provides functionality only available
-// to the WindowManager.
-interface WindowManagerInternalClient {
- // Dispatches the specified input event to the specified view.
- DispatchInputEventToView(uint32 view_id, mojo.Event event);
-
- // Sets the native viewport size.
- SetViewportSize(mojo.Size size);
-
- // Clones the tree rooted at |view_id|. When the animation completes the clone
- // is destroyed.
- // TODO(sky): add actual animation.
- // TODO(sky): I think this only makes sense when destroying (view is
- // already visible), should it be named to indicate this?
- CloneAndAnimate(uint32 view_id);
-};