| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef EXAMPLES_UI_TILE_TILE_VIEW_H_ |
| 6 #define EXAMPLES_UI_TILE_TILE_VIEW_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 |
| 11 #include "base/bind.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "mojo/public/cpp/application/application_impl.h" |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 15 #include "mojo/public/cpp/environment/environment.h" |
| 16 #include "mojo/public/cpp/system/core.h" |
| 17 #include "mojo/public/cpp/system/macros.h" |
| 18 #include "mojo/services/geometry/interfaces/geometry.mojom.h" |
| 19 #include "mojo/services/surfaces/interfaces/surfaces.mojom.h" |
| 20 #include "mojo/services/ui/views/interfaces/view_manager.mojom.h" |
| 21 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h" |
| 22 #include "mojo/services/ui/views/interfaces/views.mojom.h" |
| 23 |
| 24 namespace examples { |
| 25 |
| 26 class TileView : public mojo::ui::View { |
| 27 public: |
| 28 TileView(mojo::ApplicationImpl* app_impl_, |
| 29 const std::vector<std::string>& view_urls, |
| 30 const mojo::ui::ViewProvider::CreateViewCallback& callback); |
| 31 |
| 32 ~TileView() override; |
| 33 |
| 34 private: |
| 35 class ViewData { |
| 36 public: |
| 37 ViewData(const std::string& url); |
| 38 ~ViewData(); |
| 39 |
| 40 const std::string& url() const { return url_; } |
| 41 |
| 42 bool layout_pending; |
| 43 mojo::ui::ViewLayoutParamsPtr layout_params; |
| 44 mojo::ui::ViewLayoutInfoPtr layout_info; |
| 45 mojo::Rect layout_bounds; |
| 46 |
| 47 private: |
| 48 std::string url_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(ViewData); |
| 51 }; |
| 52 |
| 53 // |View|: |
| 54 void OnLayout(mojo::ui::ViewLayoutParamsPtr layout_params, |
| 55 mojo::Array<uint32_t> children_needing_layout, |
| 56 const OnLayoutCallback& callback) override; |
| 57 void OnChildUnavailable(uint32_t child_key, |
| 58 const OnChildUnavailableCallback& callback) override; |
| 59 |
| 60 void OnSurfaceIdNamespaceAvailable(uint32_t id_namespace); |
| 61 |
| 62 void InitView(); |
| 63 void OnChildConnectionError(uint32_t child_key, const std::string& url); |
| 64 void OnChildCreated(uint32_t child_key, |
| 65 const std::string& url, |
| 66 mojo::ui::ViewProviderPtr provider, |
| 67 mojo::ui::ViewTokenPtr token); |
| 68 void OnChildLayoutFinished(uint32_t child_key, |
| 69 mojo::ui::ViewLayoutInfoPtr child_layout_info); |
| 70 void FinishLayout(); |
| 71 |
| 72 void OnFrameSubmitted(); |
| 73 |
| 74 mojo::ApplicationImpl* app_impl_; |
| 75 std::vector<std::string> view_urls_; |
| 76 mojo::ui::ViewProvider::CreateViewCallback callback_; |
| 77 mojo::StrongBinding<mojo::ui::View> binding_; |
| 78 |
| 79 mojo::SurfacePtr surfaces_; |
| 80 mojo::SurfaceIdPtr surface_id_; |
| 81 uint32_t surface_id_namespace_; |
| 82 |
| 83 mojo::ui::ViewManagerPtr view_manager_; |
| 84 mojo::ui::ViewHostPtr view_host_; |
| 85 |
| 86 std::map<uint32_t, std::unique_ptr<ViewData>> views_; |
| 87 |
| 88 mojo::Size size_; |
| 89 OnLayoutCallback pending_layout_callback_; |
| 90 bool frame_pending_; |
| 91 |
| 92 base::WeakPtrFactory<TileView> weak_ptr_factory_; |
| 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(TileView); |
| 95 }; |
| 96 |
| 97 } // namespace examples |
| 98 |
| 99 #endif // EXAMPLES_UI_TILE_TILE_VIEW_H_ |
| OLD | NEW |