summaryrefslogtreecommitdiffstats
path: root/mojo/services
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/services')
-rw-r--r--mojo/services/content_handler/public/interfaces/BUILD.gn8
-rw-r--r--mojo/services/content_handler/public/interfaces/content_handler.mojom4
-rw-r--r--mojo/services/html_viewer/html_viewer.cc21
-rw-r--r--mojo/services/native_viewport/public/interfaces/native_viewport.mojom18
-rw-r--r--mojo/services/navigation/public/interfaces/BUILD.gn8
-rw-r--r--mojo/services/public/js/application.js38
-rw-r--r--mojo/services/public/js/service_provider.js26
-rw-r--r--mojo/services/public/js/shell.js26
-rw-r--r--mojo/services/view_manager/public/cpp/DEPS8
-rw-r--r--mojo/services/view_manager/public/cpp/lib/BUILD.gn23
-rw-r--r--mojo/services/view_manager/public/cpp/lib/DEPS15
-rw-r--r--mojo/services/view_manager/public/cpp/lib/view.cc33
-rw-r--r--mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.cc23
-rw-r--r--mojo/services/view_manager/public/cpp/lib/view_manager_client_impl.h2
-rw-r--r--mojo/services/view_manager/public/cpp/lib/view_private.cc1
-rw-r--r--mojo/services/view_manager/public/cpp/lib/view_private.h5
-rw-r--r--mojo/services/view_manager/public/cpp/tests/BUILD.gn12
-rw-r--r--mojo/services/view_manager/public/cpp/tests/DEPS13
-rw-r--r--mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.cc (renamed from mojo/services/view_manager/public/cpp/lib/view_manager_test_suite.cc)2
-rw-r--r--mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h (renamed from mojo/services/view_manager/public/cpp/lib/view_manager_test_suite.h)6
-rw-r--r--mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc6
-rw-r--r--mojo/services/view_manager/public/cpp/tests/view_manager_unittests.cc (renamed from mojo/services/view_manager/public/cpp/lib/view_manager_unittests.cc)2
-rw-r--r--mojo/services/view_manager/public/cpp/view.h2
-rw-r--r--mojo/services/view_manager/public/cpp/view_observer.h5
-rw-r--r--mojo/services/view_manager/public/interfaces/view_manager.mojom7
25 files changed, 201 insertions, 113 deletions
diff --git a/mojo/services/content_handler/public/interfaces/BUILD.gn b/mojo/services/content_handler/public/interfaces/BUILD.gn
index cb38d83..5016c65 100644
--- a/mojo/services/content_handler/public/interfaces/BUILD.gn
+++ b/mojo/services/content_handler/public/interfaces/BUILD.gn
@@ -12,8 +12,14 @@ mojom("interfaces") {
import_dirs = [ get_path_info("../../../", "abspath") ]
+ if (defined(network_service_root)) {
+ import_dirs += [ network_service_root ]
+ } else {
+ network_service_root = "../../.."
+ }
+
deps = [
- "../../../network/public/interfaces",
+ "$network_service_root/network/public/interfaces",
]
mojo_sdk_deps = [ "mojo/public/interfaces/application" ]
diff --git a/mojo/services/content_handler/public/interfaces/content_handler.mojom b/mojo/services/content_handler/public/interfaces/content_handler.mojom
index c56410e..39ddfea 100644
--- a/mojo/services/content_handler/public/interfaces/content_handler.mojom
+++ b/mojo/services/content_handler/public/interfaces/content_handler.mojom
@@ -4,9 +4,9 @@
module mojo;
-import "mojo/public/interfaces/application/shell.mojom";
+import "mojo/public/interfaces/application/application.mojom";
import "network/public/interfaces/url_loader.mojom";
interface ContentHandler {
- StartApplication(Shell shell, URLResponse response);
+ StartApplication(Application& application, URLResponse response);
};
diff --git a/mojo/services/html_viewer/html_viewer.cc b/mojo/services/html_viewer/html_viewer.cc
index 06df351..73f3045 100644
--- a/mojo/services/html_viewer/html_viewer.cc
+++ b/mojo/services/html_viewer/html_viewer.cc
@@ -23,6 +23,7 @@
#include "third_party/mojo/src/mojo/public/cpp/application/application_impl.h"
#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"
#if !defined(COMPONENT_BUILD)
#include "base/i18n/icu_util.h"
@@ -59,24 +60,24 @@ class HTMLViewer;
class HTMLViewerApplication : public mojo::Application {
public:
- HTMLViewerApplication(ShellPtr shell,
+ HTMLViewerApplication(InterfaceRequest<Application> request,
URLResponsePtr response,
scoped_refptr<base::MessageLoopProxy> compositor_thread,
WebMediaPlayerFactory* web_media_player_factory)
: url_(response->url),
- shell_(shell.Pass()),
+ binding_(this, request.Pass()),
initial_response_(response.Pass()),
compositor_thread_(compositor_thread),
- web_media_player_factory_(web_media_player_factory) {
- shell_.set_client(this);
+ web_media_player_factory_(web_media_player_factory) {}
+
+ void Initialize(ShellPtr shell, Array<String> args) override {
ServiceProviderPtr service_provider;
+ shell_ = shell.Pass();
shell_->ConnectToApplication("mojo:network_service",
GetProxy(&service_provider), nullptr);
ConnectToService(service_provider.get(), &network_service_);
}
- void Initialize(Array<String> args) override {}
-
void AcceptConnection(const String& requestor_url,
InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services) override {
@@ -113,6 +114,7 @@ class HTMLViewerApplication : public mojo::Application {
}
String url_;
+ mojo::StrongBinding<mojo::Application> binding_;
ShellPtr shell_;
mojo::NetworkServicePtr network_service_;
URLResponsePtr initial_response_;
@@ -130,8 +132,11 @@ class ContentHandlerImpl : public mojo::InterfaceImpl<ContentHandler> {
private:
// Overridden from ContentHandler:
- void StartApplication(ShellPtr shell, URLResponsePtr response) override {
- new HTMLViewerApplication(shell.Pass(), response.Pass(), compositor_thread_,
+ void StartApplication(InterfaceRequest<mojo::Application> request,
+ URLResponsePtr response) override {
+ new HTMLViewerApplication(request.Pass(),
+ response.Pass(),
+ compositor_thread_,
web_media_player_factory_);
}
diff --git a/mojo/services/native_viewport/public/interfaces/native_viewport.mojom b/mojo/services/native_viewport/public/interfaces/native_viewport.mojom
index 72d3c9d..75757c2 100644
--- a/mojo/services/native_viewport/public/interfaces/native_viewport.mojom
+++ b/mojo/services/native_viewport/public/interfaces/native_viewport.mojom
@@ -14,26 +14,26 @@ struct ViewportMetrics {
float device_pixel_ratio = 1.0;
};
-[Client=NativeViewportClient]
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);
+ 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) => ();
};
-
-interface NativeViewportClient {
- // OnMetricsAvailable() is sent at least once after the callback from Create()
- // is called.
- OnMetricsChanged(ViewportMetrics metrics);
- OnDestroyed();
-};
diff --git a/mojo/services/navigation/public/interfaces/BUILD.gn b/mojo/services/navigation/public/interfaces/BUILD.gn
index 9b396e7..da9fc70 100644
--- a/mojo/services/navigation/public/interfaces/BUILD.gn
+++ b/mojo/services/navigation/public/interfaces/BUILD.gn
@@ -12,7 +12,13 @@ mojom("interfaces") {
import_dirs = [ get_path_info("../../../", "abspath") ]
+ if (defined(network_service_root)) {
+ import_dirs += [ network_service_root ]
+ } else {
+ network_service_root = "../../.."
+ }
+
deps = [
- "../../../network/public/interfaces",
+ "$network_service_root/network/public/interfaces",
]
}
diff --git a/mojo/services/public/js/application.js b/mojo/services/public/js/application.js
index ed41628..d4aa1e6 100644
--- a/mojo/services/public/js/application.js
+++ b/mojo/services/public/js/application.js
@@ -4,30 +4,41 @@
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, threading, serviceProvider, 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(shellHandle, url) {
+ constructor(appRequestHandle, url) {
this.url = url;
this.serviceProviders = [];
this.exposedServiceProviders = [];
- this.shellHandle_ = shellHandle;
- this.shell = new Shell(shellHandle, {
- initialize: this.initialize.bind(this),
- acceptConnection: this.doAcceptConnection.bind(this),
- });
+ this.appRequestHandle_ = appRequestHandle;
+ this.appStub_ =
+ connection.bindHandleToStub(appRequestHandle, ApplicationInterface);
+ bindings.StubBindings(this.appStub_).delegate = {
+ initialize: this.doInitialize.bind(this),
+ acceptConnection: this.doAcceptConnection.bind(this),
+ };
}
- initialize(args) {
+ 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,
@@ -39,23 +50,20 @@ define("mojo/services/public/js/application", [
doAcceptConnection(requestorUrl, servicesRequest, exposedServicesProxy) {
// Construct a new js ServiceProvider that can make outgoing calls on
// exposedServicesProxy.
- var serviceProvider = new ServiceProvider(exposedServicesProxy);
+ var serviceProvider =
+ new ServiceProvider(servicesRequest, exposedServicesProxy);
this.serviceProviders.push(serviceProvider);
-
- // Then associate incoming calls with the serviceProvider.
- ProxyBindings(servicesRequest).setLocalDelegate(serviceProvider);
-
this.acceptConnection(requestorUrl, serviceProvider);
}
- acceptConnection(requestorUrl, serviceProvider) {
- }
+ acceptConnection(requestorUrl, serviceProvider) {}
quit() {
this.serviceProviders.forEach(function(sp) {
sp.close();
});
this.shell.close();
+ core.close(this.appRequestHandle_);
threading.quit();
}
}
diff --git a/mojo/services/public/js/service_provider.js b/mojo/services/public/js/service_provider.js
index 9566583..a6a81ca 100644
--- a/mojo/services/public/js/service_provider.js
+++ b/mojo/services/public/js/service_provider.js
@@ -18,10 +18,12 @@ define("mojo/services/public/js/service_provider", [
}
class ServiceProvider {
- constructor(service) {
- this.proxy = service;
+ 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
@@ -34,11 +36,10 @@ define("mojo/services/public/js/service_provider", [
this.pendingRequests_.set(serviceName, serviceHandle);
return;
}
- var proxy = connection.bindProxyHandle(
- serviceHandle, provider.service, provider.service.client);
- if (ProxyBindings(proxy).local)
- ProxyBindings(proxy).setLocalDelegate(new provider.factory(proxy));
- provider.connections.push(ProxyBindings(proxy).connection);
+
+ var stub = connection.bindHandleToStub(serviceHandle, provider.service);
+ StubBindings(stub).delegate = new provider.factory();
+ provider.connections.push(StubBindings(stub).connection);
}
provideService(service, factory) {
@@ -66,12 +67,11 @@ define("mojo/services/public/js/service_provider", [
if (!clientImpl && interfaceObject.client)
throw new Error("Client implementation must be provided");
- var remoteProxy;
- var clientFactory = function(x) {remoteProxy = x; return clientImpl;};
- var messagePipeHandle = connection.bindProxyClient(
- clientFactory, interfaceObject.client, interfaceObject);
- this.proxy.connectToService(interfaceObject.name, messagePipeHandle);
- return remoteProxy;
+ var serviceProxy;
+ var serviceHandle = connection.bindProxy(
+ function(sp) {serviceProxy = sp;}, interfaceObject);
+ this.proxy.connectToService(interfaceObject.name, serviceHandle);
+ return serviceProxy;
};
close() {
diff --git a/mojo/services/public/js/shell.js b/mojo/services/public/js/shell.js
index 9fc8552..e6c2dee 100644
--- a/mojo/services/public/js/shell.js
+++ b/mojo/services/public/js/shell.js
@@ -8,8 +8,8 @@ define("mojo/services/public/js/shell", [
"mojo/public/js/connection",
"mojo/public/interfaces/application/shell.mojom",
"mojo/public/interfaces/application/service_provider.mojom",
- "mojo/services/public/js/service_provider",
-], function(bindings, core, connection, shellMojom, spMojom, sp) {
+ "mojo/services/public/js/service_provider","console",
+], function(bindings, core, connection, shellMojom, spMojom, sp, console) {
const ProxyBindings = bindings.ProxyBindings;
const StubBindings = bindings.StubBindings;
@@ -18,13 +18,8 @@ define("mojo/services/public/js/shell", [
const ShellInterface = shellMojom.Shell;
class Shell {
- constructor(shellHandle, app) {
- this.shellHandle = shellHandle;
- this.proxy = connection.bindProxyHandle(
- shellHandle, ShellInterface.client, ShellInterface);
-
- ProxyBindings(this.proxy).setLocalDelegate(app);
- // TODO: call this serviceProviders_
+ constructor(shellProxy) {
+ this.shellProxy = shellProxy;
this.applications_ = new Map();
}
@@ -33,11 +28,12 @@ define("mojo/services/public/js/shell", [
if (application)
return application;
- this.proxy.connectToApplication(url, function(services) {
- application = new ServiceProvider(services);
- }, function() {
- return application;
- });
+ var application = new ServiceProvider();
+ this.shellProxy.connectToApplication(url,
+ function(services) {
+ application.proxy = services;
+ },
+ application);
this.applications_.set(url, application);
return application;
}
@@ -50,8 +46,8 @@ define("mojo/services/public/js/shell", [
this.applications_.forEach(function(application, url) {
application.close();
});
+ ProxyBindings(this.shellProxy).close();
this.applications_.clear();
- core.close(this.shellHandle);
}
}
diff --git a/mojo/services/view_manager/public/cpp/DEPS b/mojo/services/view_manager/public/cpp/DEPS
index 84b6bb7..c08c2c8 100644
--- a/mojo/services/view_manager/public/cpp/DEPS
+++ b/mojo/services/view_manager/public/cpp/DEPS
@@ -1,8 +1,14 @@
include_rules = [
- "!base",
"+geometry/public",
"+input_events/public",
"+surfaces/public",
"+view_manager/public",
"+window_manager/public",
+
+ # TODO(blundell): Eliminate these dependencies. crbug.com/451403
+ "!base/basictypes.h",
+ "!base/bind.h",
+ "!base/compiler_specific.h",
+ "!base/memory/scoped_ptr.h",
+ "!base/observer_list.h",
]
diff --git a/mojo/services/view_manager/public/cpp/lib/BUILD.gn b/mojo/services/view_manager/public/cpp/lib/BUILD.gn
deleted file mode 100644
index 2090455..0000000
--- a/mojo/services/view_manager/public/cpp/lib/BUILD.gn
+++ /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.
-
-import("//build/config/ui.gni")
-
-source_set("run_unittests") {
- testonly = true
- sources = [
- "view_manager_test_suite.cc",
- "view_manager_test_suite.h",
- "view_manager_unittests.cc",
- ]
-
- deps = [
- "//base",
- "//base/test:test_support",
- ]
-
- if (use_x11) {
- deps += [ "//ui/gfx/x" ]
- }
-}
diff --git a/mojo/services/view_manager/public/cpp/lib/DEPS b/mojo/services/view_manager/public/cpp/lib/DEPS
index d4de534..f36ebc7 100644
--- a/mojo/services/view_manager/public/cpp/lib/DEPS
+++ b/mojo/services/view_manager/public/cpp/lib/DEPS
@@ -1,11 +1,10 @@
include_rules = [
"+mojo/services/window_manager/public",
-]
-specific_include_rules = {
- "view_manager_test_suite.cc": [
- "!mojo/services/native_viewport/native_viewport.h",
- "!ui/gfx",
- "!ui/gl",
- ],
-}
+ # TODO(blundell): Eliminate these dependencies. crbug.com/451403
+ "!base/callback.h",
+ "!base/memory/scoped_vector.h",
+ "!base/memory/weak_ptr.h",
+ "!base/message_loop/message_loop.h",
+ "!base/stl_util.h",
+]
diff --git a/mojo/services/view_manager/public/cpp/lib/view.cc b/mojo/services/view_manager/public/cpp/lib/view.cc
index 929eec4..f7e7784 100644
--- a/mojo/services/view_manager/public/cpp/lib/view.cc
+++ b/mojo/services/view_manager/public/cpp/lib/view.cc
@@ -5,6 +5,7 @@
#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"
@@ -247,6 +248,18 @@ void View::SetSharedProperty(const std::string& name,
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));
@@ -369,10 +382,20 @@ void View::Embed(const String& url,
////////////////////////////////////////////////////////////////////////////////
// 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) {
}
@@ -412,6 +435,7 @@ View::View(ViewManager* manager, Id id)
: manager_(manager),
id_(id),
parent_(nullptr),
+ viewport_metrics_(CreateEmptyViewportMetrics()),
visible_(false),
drawn_(false) {
}
@@ -476,6 +500,15 @@ void View::LocalSetBounds(const Rect& old_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;
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
index 78daeb3..595e039 100644
--- 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
@@ -36,7 +36,8 @@ View* AddViewToViewManager(ViewManagerClientImpl* 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.set_viewport_metrics(view_data->viewport_metrics.Pass());
+ 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);
@@ -296,6 +297,26 @@ void ViewManagerClientImpl::OnViewBoundsChanged(Id 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,
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
index c8ae5c4..2405229 100644
--- 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
@@ -103,6 +103,8 @@ class ViewManagerClientImpl : public ViewManager,
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,
diff --git a/mojo/services/view_manager/public/cpp/lib/view_private.cc b/mojo/services/view_manager/public/cpp/lib/view_private.cc
index 395aacf..20232e8 100644
--- a/mojo/services/view_manager/public/cpp/lib/view_private.cc
+++ b/mojo/services/view_manager/public/cpp/lib/view_private.cc
@@ -8,6 +8,7 @@ namespace mojo {
ViewPrivate::ViewPrivate(View* view)
: view_(view) {
+ CHECK(view);
}
ViewPrivate::~ViewPrivate() {
diff --git a/mojo/services/view_manager/public/cpp/lib/view_private.h b/mojo/services/view_manager/public/cpp/lib/view_private.h
index 964e6e5..1c54567 100644
--- a/mojo/services/view_manager/public/cpp/lib/view_private.h
+++ b/mojo/services/view_manager/public/cpp/lib/view_private.h
@@ -39,8 +39,9 @@ class ViewPrivate {
view_->properties_ = data;
}
- void set_viewport_metrics(ViewportMetricsPtr viewport_metrics) {
- view_->viewport_metrics_ = viewport_metrics.Pass();
+ void LocalSetViewportMetrics(const ViewportMetrics& old_metrics,
+ const ViewportMetrics& new_metrics) {
+ view_->LocalSetViewportMetrics(new_metrics, new_metrics);
}
void LocalDestroy() {
diff --git a/mojo/services/view_manager/public/cpp/tests/BUILD.gn b/mojo/services/view_manager/public/cpp/tests/BUILD.gn
index 2cbcf43..e912084 100644
--- a/mojo/services/view_manager/public/cpp/tests/BUILD.gn
+++ b/mojo/services/view_manager/public/cpp/tests/BUILD.gn
@@ -7,23 +7,27 @@ import("//testing/test.gni")
test("mojo_view_manager_lib_unittests") {
sources = [
- "view_unittest.cc",
+ "view_manager_test_suite.cc",
+ "view_manager_test_suite.h",
"view_manager_unittest.cc",
+ "view_manager_unittests.cc",
+ "view_unittest.cc",
]
deps = [
"//base",
"//base/test:test_support",
- "//mojo/converters/geometry",
- "//mojo/environment:chromium",
"//mojo/public/cpp/application",
"//mojo/services/geometry/public/cpp",
"//mojo/services/geometry/public/interfaces",
"//mojo/services/view_manager/public/cpp",
- "//mojo/services/view_manager/public/cpp/lib:run_unittests",
"//mojo/services/view_manager/public/interfaces",
"//shell/application_manager",
"//shell:test_support",
"//testing/gtest",
]
+
+ if (use_x11) {
+ deps += [ "//ui/gfx/x" ]
+ }
}
diff --git a/mojo/services/view_manager/public/cpp/tests/DEPS b/mojo/services/view_manager/public/cpp/tests/DEPS
index af27b9a..0f9ddb4 100644
--- a/mojo/services/view_manager/public/cpp/tests/DEPS
+++ b/mojo/services/view_manager/public/cpp/tests/DEPS
@@ -1,5 +1,16 @@
include_rules = [
+ "+mojo/services/geometry/public",
+
+ # TODO(blundell): Determine whether to eliminate these dependencies or move
+ # the tests outside of view_manager's public code. crbug.com/451403
+ "!base/auto_reset.h",
+ "!base/bind.h",
+ "!base/i18n/icu_util.h",
+ "!base/logging.h",
+ "!base/strings/stringprintf.h",
+ "!base/test/launcher/unit_test_launcher.h",
+ "!base/test/test_suite.h",
"!shell/application_manager",
"!shell/shell_test_helper.h",
- "+mojo/services/geometry/public",
+ "!ui/gfx/x/x11_connection.h",
]
diff --git a/mojo/services/view_manager/public/cpp/lib/view_manager_test_suite.cc b/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.cc
index 93a221e..2bfdd1e 100644
--- a/mojo/services/view_manager/public/cpp/lib/view_manager_test_suite.cc
+++ b/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.cc
@@ -2,7 +2,7 @@
// 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/lib/view_manager_test_suite.h"
+#include "mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h"
#include "base/i18n/icu_util.h"
diff --git a/mojo/services/view_manager/public/cpp/lib/view_manager_test_suite.h b/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h
index ec5bb88..ef81661 100644
--- a/mojo/services/view_manager/public/cpp/lib/view_manager_test_suite.h
+++ b/mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h
@@ -2,8 +2,8 @@
// 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_TEST_SUITE_H_
-#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_MANAGER_TEST_SUITE_H_
+#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"
@@ -23,4 +23,4 @@ class ViewManagerTestSuite : public base::TestSuite {
} // namespace mojo
-#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_MANAGER_TEST_SUITE_H_
+#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
index d9e4db8..bc69464 100644
--- a/mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc
+++ b/mojo/services/view_manager/public/cpp/tests/view_manager_unittest.cc
@@ -63,11 +63,11 @@ class ConnectApplicationLoader : public ApplicationLoader,
// Overridden from ApplicationLoader:
void Load(ApplicationManager* manager,
const GURL& url,
- ScopedMessagePipeHandle shell_handle,
+ InterfaceRequest<Application> application_request,
LoadCallback callback) override {
- ASSERT_TRUE(shell_handle.is_valid());
+ ASSERT_TRUE(application_request.is_pending());
scoped_ptr<ApplicationImpl> app(
- new ApplicationImpl(this, shell_handle.Pass()));
+ new ApplicationImpl(this, application_request.Pass()));
apps_.push_back(app.release());
}
diff --git a/mojo/services/view_manager/public/cpp/lib/view_manager_unittests.cc b/mojo/services/view_manager/public/cpp/tests/view_manager_unittests.cc
index 1d8bd98..95a7b5c 100644
--- a/mojo/services/view_manager/public/cpp/lib/view_manager_unittests.cc
+++ b/mojo/services/view_manager/public/cpp/tests/view_manager_unittests.cc
@@ -4,7 +4,7 @@
#include "base/bind.h"
#include "base/test/launcher/unit_test_launcher.h"
-#include "mojo/services/view_manager/public/cpp/lib/view_manager_test_suite.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);
diff --git a/mojo/services/view_manager/public/cpp/view.h b/mojo/services/view_manager/public/cpp/view.h
index 1215a3b..07bc5b0 100644
--- a/mojo/services/view_manager/public/cpp/view.h
+++ b/mojo/services/view_manager/public/cpp/view.h
@@ -153,6 +153,8 @@ class View {
// 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
diff --git a/mojo/services/view_manager/public/cpp/view_observer.h b/mojo/services/view_manager/public/cpp/view_observer.h
index 4c0ba87..7430566 100644
--- a/mojo/services/view_manager/public/cpp/view_observer.h
+++ b/mojo/services/view_manager/public/cpp/view_observer.h
@@ -56,6 +56,11 @@ class ViewObserver {
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) {
diff --git a/mojo/services/view_manager/public/interfaces/view_manager.mojom b/mojo/services/view_manager/public/interfaces/view_manager.mojom
index 55552f8..23238d5 100644
--- a/mojo/services/view_manager/public/interfaces/view_manager.mojom
+++ b/mojo/services/view_manager/public/interfaces/view_manager.mojom
@@ -159,6 +159,11 @@ interface ViewManagerClient {
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.
@@ -173,7 +178,7 @@ interface ViewManagerClient {
// Invoked when the order of views within a parent changes.
OnViewReordered(uint32 view_id,
uint32 relative_view_id,
- OrderDirection direction);
+ OrderDirection direction);
// Invoked when a view is deleted.
OnViewDeleted(uint32 view);