tree: e5a8d88e506a532ca322820054430627ae792cd0 [path history] [tgz]
  1. BUILD.gn
  2. README.md
  3. remote_view_host.cc
  4. remote_view_host.h
  5. remote_view_host_unittest.cc
  6. remote_view_provider.cc
  7. remote_view_provider.h
  8. remote_view_provider_test_api.cc
  9. remote_view_provider_test_api.h
  10. remote_view_provider_unittest.cc
ui/views/mus/remote_view/README.md

This directory contains helper classes to embed a Window.

RemoteViewProvider

RemoteViewProvider wraps the work needed to provide a Window to another (remote) client. Typical usage is to create an instance of it with the window to provide to the remote client.

e.g.

  ...

  // Step 1: Prepares for embedding after |window_for_remote_client_| is ready.
  void StartEmbed() {
    remote_view_provider_ =
        std::make_unique<views::RemoteViewProvider>(window_for_remote_client_);
    remote_view_client->GetEmbedToken(base::BindOnce(
        &EmbeddedClient::OnGotEmbedToken, base::Unretained(this)));
  }

  void OnGotEmbedToken(const base::UnguessableToken& token) {
    // Step 2: Pass |token| to the embedder.
  }

  // A Window to to provide to the remote client.
  aura::Window* window_for_remote_client_;

  // Helper to prepare |window_for_remote_client_| for embedding.
  std::unique_ptr<views::RemoteViewProvider> remote_view_provider_;

  ...

RemoteViewHost

RemoteViewHost wraps the work on the embedder side and is a NativeViewHost that embeds the window from the RemoteViewProvider. RemoveViewHost is a View that you add to your existing View hierarchy.

e.g.

  class EmbedderView : public views::View {
   public:
    ...
    // Creates a RemoteViewHost using |token| from the embedded client.
    void AddEmbeddedView(const base::UnguessableToken& token) {
      // Ownership will be passed to the view hierarchy in AddChildView.
      views::RemoteViewHost* remote_view_host = new RemoteViewHost();
      remote_view_host->EmbedUsingToken(token, base::DoNothing());
      AddChildView(remote_view_host);
    }
    ...
  };