| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "mojo/common/common_type_converters.h" | 16 #include "mojo/common/common_type_converters.h" |
| 17 #include "mojo/public/cpp/application/application_connection.h" | 17 #include "mojo/public/cpp/application/application_connection.h" |
| 18 #include "mojo/public/cpp/application/application_delegate.h" | 18 #include "mojo/public/cpp/application/application_delegate.h" |
| 19 #include "mojo/public/cpp/application/application_impl.h" | 19 #include "mojo/public/cpp/application/application_impl.h" |
| 20 #include "mojo/public/cpp/application/connect.h" | 20 #include "mojo/public/cpp/application/connect.h" |
| 21 #include "mojo/public/cpp/application/default_interface_provider.h" |
| 21 #include "mojo/public/cpp/bindings/lib/router.h" | 22 #include "mojo/public/cpp/bindings/lib/router.h" |
| 22 #include "mojo/service_manager/service_manager.h" | 23 #include "mojo/service_manager/service_manager.h" |
| 23 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 24 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
| 24 #include "mojo/services/public/cpp/view_manager/types.h" | 25 #include "mojo/services/public/cpp/view_manager/types.h" |
| 25 #include "mojo/services/public/cpp/view_manager/util.h" | 26 #include "mojo/services/public/cpp/view_manager/util.h" |
| 26 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" | 27 #include "mojo/services/public/interfaces/view_manager/view_manager.mojom.h" |
| 27 #include "mojo/services/view_manager/ids.h" | 28 #include "mojo/services/view_manager/ids.h" |
| 28 #include "mojo/services/view_manager/test_change_tracker.h" | 29 #include "mojo/services/view_manager/test_change_tracker.h" |
| 29 #include "mojo/shell/shell_test_helper.h" | 30 #include "mojo/shell/shell_test_helper.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 | 298 |
| 298 // static | 299 // static |
| 299 base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL; | 300 base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL; |
| 300 | 301 |
| 301 // static | 302 // static |
| 302 bool ViewManagerProxy::in_embed_ = false; | 303 bool ViewManagerProxy::in_embed_ = false; |
| 303 | 304 |
| 304 class TestViewManagerClientConnection | 305 class TestViewManagerClientConnection |
| 305 : public InterfaceImpl<ViewManagerClient> { | 306 : public InterfaceImpl<ViewManagerClient> { |
| 306 public: | 307 public: |
| 307 TestViewManagerClientConnection(ApplicationConnection* app_connection) : | 308 TestViewManagerClientConnection() : connection_(&tracker_) { |
| 308 connection_(&tracker_) { | |
| 309 tracker_.set_delegate(&connection_); | 309 tracker_.set_delegate(&connection_); |
| 310 } | 310 } |
| 311 | 311 |
| 312 // InterfaceImp: | 312 // InterfaceImp: |
| 313 virtual void OnConnectionEstablished() OVERRIDE { | 313 virtual void OnConnectionEstablished() OVERRIDE { |
| 314 connection_.set_router(internal_state()->router()); | 314 connection_.set_router(internal_state()->router()); |
| 315 connection_.set_view_manager(client()); | 315 connection_.set_view_manager(client()); |
| 316 } | 316 } |
| 317 | 317 |
| 318 // ViewMangerClient: | 318 // ViewMangerClient: |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 375 |
| 376 private: | 376 private: |
| 377 TestChangeTracker tracker_; | 377 TestChangeTracker tracker_; |
| 378 ViewManagerProxy connection_; | 378 ViewManagerProxy connection_; |
| 379 | 379 |
| 380 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); | 380 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); |
| 381 }; | 381 }; |
| 382 | 382 |
| 383 // Used with ViewManagerService::Embed(). Creates a | 383 // Used with ViewManagerService::Embed(). Creates a |
| 384 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. | 384 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. |
| 385 class EmbedServiceLoader : public ServiceLoader, ApplicationDelegate { | 385 class EmbedServiceLoader |
| 386 : public ServiceLoader, |
| 387 ApplicationDelegate, |
| 388 public DefaultInterfaceProvider<TestViewManagerClientConnection> { |
| 386 public: | 389 public: |
| 387 EmbedServiceLoader() {} | 390 EmbedServiceLoader() {} |
| 388 virtual ~EmbedServiceLoader() {} | 391 virtual ~EmbedServiceLoader() {} |
| 389 | 392 |
| 390 // ServiceLoader: | 393 // ServiceLoader: |
| 391 virtual void LoadService(ServiceManager* manager, | 394 virtual void LoadService(ServiceManager* manager, |
| 392 const GURL& url, | 395 const GURL& url, |
| 393 ScopedMessagePipeHandle shell_handle) OVERRIDE { | 396 ScopedMessagePipeHandle shell_handle) OVERRIDE { |
| 394 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, | 397 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, |
| 395 shell_handle.Pass())); | 398 shell_handle.Pass())); |
| 396 apps_.push_back(app.release()); | 399 apps_.push_back(app.release()); |
| 397 } | 400 } |
| 398 virtual void OnServiceError(ServiceManager* manager, | 401 virtual void OnServiceError(ServiceManager* manager, |
| 399 const GURL& url) OVERRIDE { | 402 const GURL& url) OVERRIDE { |
| 400 } | 403 } |
| 401 | 404 |
| 402 // ApplicationDelegate | 405 // ApplicationDelegate |
| 403 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 406 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
| 404 OVERRIDE { | 407 OVERRIDE { |
| 405 connection->AddService<TestViewManagerClientConnection>(); | 408 connection->AddServiceProvider(this); |
| 406 return true; | 409 return true; |
| 407 } | 410 } |
| 408 | 411 |
| 409 private: | 412 private: |
| 410 ScopedVector<ApplicationImpl> apps_; | 413 ScopedVector<ApplicationImpl> apps_; |
| 411 | 414 |
| 412 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); | 415 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); |
| 413 }; | 416 }; |
| 414 | 417 |
| 415 // Creates an id used for transport from the specified parameters. | 418 // Creates an id used for transport from the specified parameters. |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 // originating connection. | 1400 // originating connection. |
| 1398 | 1401 |
| 1399 // TODO(beng): Add tests for focus: | 1402 // TODO(beng): Add tests for focus: |
| 1400 // - focus between two nodes known to a connection | 1403 // - focus between two nodes known to a connection |
| 1401 // - focus between nodes unknown to one of the connections. | 1404 // - focus between nodes unknown to one of the connections. |
| 1402 // - focus between nodes unknown to either connection. | 1405 // - focus between nodes unknown to either connection. |
| 1403 | 1406 |
| 1404 } // namespace service | 1407 } // namespace service |
| 1405 } // namespace view_manager | 1408 } // namespace view_manager |
| 1406 } // namespace mojo | 1409 } // namespace mojo |
| OLD | NEW |