| 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 "mojo/services/public/cpp/view_manager/view_manager.h" | 5 #include "mojo/services/public/cpp/view_manager/view_manager.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/application/application_connection.h" |
| 11 #include "mojo/public/cpp/application/application_delegate.h" | 11 #include "mojo/public/cpp/application/application_delegate.h" |
| 12 #include "mojo/public/cpp/application/application_impl.h" | 12 #include "mojo/public/cpp/application/application_impl.h" |
| 13 #include "mojo/service_manager/service_manager.h" | 13 #include "mojo/service_manager/service_manager.h" |
| 14 #include "mojo/services/public/cpp/view_manager/lib/node_private.h" | 14 #include "mojo/services/public/cpp/view_manager/lib/node_private.h" |
| 15 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" | 15 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" |
| 16 #include "mojo/services/public/cpp/view_manager/node_observer.h" | 16 #include "mojo/services/public/cpp/view_manager/node_observer.h" |
| 17 #include "mojo/services/public/cpp/view_manager/util.h" | 17 #include "mojo/services/public/cpp/view_manager/util.h" |
| 18 #include "mojo/services/public/cpp/view_manager/view.h" | 18 #include "mojo/services/public/cpp/view_manager/view.h" |
| 19 #include "mojo/services/public/cpp/view_manager/view_manager_client_factory.h" |
| 19 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | 20 #include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" |
| 20 #include "mojo/services/public/cpp/view_manager/view_observer.h" | 21 #include "mojo/services/public/cpp/view_manager/view_observer.h" |
| 21 #include "mojo/shell/shell_test_helper.h" | 22 #include "mojo/shell/shell_test_helper.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 24 |
| 24 namespace mojo { | 25 namespace mojo { |
| 25 namespace view_manager { | 26 namespace view_manager { |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 const char kWindowManagerURL[] = "mojo:window_manager"; | 29 const char kWindowManagerURL[] = "mojo:window_manager"; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 client->ClearChangesAckedCallback(); | 48 client->ClearChangesAckedCallback(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 class ConnectServiceLoader : public ServiceLoader, | 51 class ConnectServiceLoader : public ServiceLoader, |
| 51 public ApplicationDelegate, | 52 public ApplicationDelegate, |
| 52 public ViewManagerDelegate { | 53 public ViewManagerDelegate { |
| 53 public: | 54 public: |
| 54 typedef base::Callback<void(ViewManager*, Node*)> LoadedCallback; | 55 typedef base::Callback<void(ViewManager*, Node*)> LoadedCallback; |
| 55 | 56 |
| 56 explicit ConnectServiceLoader(const LoadedCallback& callback) | 57 explicit ConnectServiceLoader(const LoadedCallback& callback) |
| 57 : callback_(callback) { | 58 : callback_(callback), view_manager_client_factory_(this) {} |
| 58 } | |
| 59 virtual ~ConnectServiceLoader() {} | 59 virtual ~ConnectServiceLoader() {} |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 // Overridden from ServiceLoader: | 62 // Overridden from ServiceLoader: |
| 63 virtual void LoadService(ServiceManager* manager, | 63 virtual void LoadService(ServiceManager* manager, |
| 64 const GURL& url, | 64 const GURL& url, |
| 65 ScopedMessagePipeHandle shell_handle) OVERRIDE { | 65 ScopedMessagePipeHandle shell_handle) OVERRIDE { |
| 66 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, | 66 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, |
| 67 shell_handle.Pass())); | 67 shell_handle.Pass())); |
| 68 apps_.push_back(app.release()); | 68 apps_.push_back(app.release()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual void OnServiceError(ServiceManager* manager, | 71 virtual void OnServiceError(ServiceManager* manager, |
| 72 const GURL& url) OVERRIDE { | 72 const GURL& url) OVERRIDE { |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) | 75 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) |
| 76 OVERRIDE { | 76 OVERRIDE { |
| 77 ViewManager::ConfigureIncomingConnection(connection, this); | 77 connection->AddServiceFactory(&view_manager_client_factory_); |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Overridden from ViewManagerDelegate: | 81 // Overridden from ViewManagerDelegate: |
| 82 virtual void OnRootAdded(ViewManager* view_manager, | 82 virtual void OnRootAdded(ViewManager* view_manager, |
| 83 Node* root) OVERRIDE { | 83 Node* root) OVERRIDE { |
| 84 callback_.Run(view_manager, root); | 84 callback_.Run(view_manager, root); |
| 85 } | 85 } |
| 86 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE {} | 86 virtual void OnViewManagerDisconnected(ViewManager* view_manager) OVERRIDE {} |
| 87 | 87 |
| 88 ScopedVector<ApplicationImpl> apps_; | 88 ScopedVector<ApplicationImpl> apps_; |
| 89 LoadedCallback callback_; | 89 LoadedCallback callback_; |
| 90 ViewManagerClientFactory view_manager_client_factory_; |
| 90 | 91 |
| 91 DISALLOW_COPY_AND_ASSIGN(ConnectServiceLoader); | 92 DISALLOW_COPY_AND_ASSIGN(ConnectServiceLoader); |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 class ActiveViewChangedObserver : public NodeObserver { | 95 class ActiveViewChangedObserver : public NodeObserver { |
| 95 public: | 96 public: |
| 96 explicit ActiveViewChangedObserver(Node* node) | 97 explicit ActiveViewChangedObserver(Node* node) |
| 97 : node_(node) {} | 98 : node_(node) {} |
| 98 virtual ~ActiveViewChangedObserver() {} | 99 virtual ~ActiveViewChangedObserver() {} |
| 99 | 100 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 // TODO(beng): tests for view event dispatcher. | 769 // TODO(beng): tests for view event dispatcher. |
| 769 // - verify that we see events for all views. | 770 // - verify that we see events for all views. |
| 770 | 771 |
| 771 // TODO(beng): tests for focus: | 772 // TODO(beng): tests for focus: |
| 772 // - focus between two nodes known to a connection | 773 // - focus between two nodes known to a connection |
| 773 // - focus between nodes unknown to one of the connections. | 774 // - focus between nodes unknown to one of the connections. |
| 774 // - focus between nodes unknown to either connection. | 775 // - focus between nodes unknown to either connection. |
| 775 | 776 |
| 776 } // namespace view_manager | 777 } // namespace view_manager |
| 777 } // namespace mojo | 778 } // namespace mojo |
| OLD | NEW |