summaryrefslogtreecommitdiff
path: root/chromium/services/content/navigable_contents_impl.h
blob: 9ae581bcfaff3bff38a7458b8ba0177bd9b356d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2018 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.

#ifndef SERVICES_CONTENT_NAVIGABLE_CONTENTS_IMPL_H_
#define SERVICES_CONTENT_NAVIGABLE_CONTENTS_IMPL_H_

#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/unguessable_token.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/content/public/mojom/navigable_contents.mojom.h"
#include "services/content/public/mojom/navigable_contents_factory.mojom.h"
#include "ui/gfx/native_widget_types.h"

namespace content {

class Service;
class NavigableContentsDelegate;
class NavigableContentsView;

// This is the state which backs an individual NavigableContents owned by some
// client of the Content Service. In terms of the classical Content API, this is
// roughly analogous to a WebContentsImpl.
class NavigableContentsImpl : public mojom::NavigableContents {
 public:
  NavigableContentsImpl(
      Service* service,
      mojom::NavigableContentsParamsPtr params,
      mojo::PendingReceiver<mojom::NavigableContents> receiver,
      mojo::PendingRemote<mojom::NavigableContentsClient> client);
  ~NavigableContentsImpl() override;

 private:
  // mojom::NavigableContents:
  void Navigate(const GURL& url, mojom::NavigateParamsPtr params) override;
  void GoBack(mojom::NavigableContents::GoBackCallback callback) override;
  void CreateView(CreateViewCallback callback) override;
  void Focus() override;
  void FocusThroughTabTraversal(bool reverse) override;

  // Used (indirectly) by the client library when run in the same process as the
  // service. See the |CreateView()| implementation for details.
  void EmbedInProcessClientView(NavigableContentsView* view);

  Service* const service_;

  mojo::Receiver<mojom::NavigableContents> receiver_;
  mojo::Remote<mojom::NavigableContentsClient> client_;
  std::unique_ptr<NavigableContentsDelegate> delegate_;
  gfx::NativeView native_content_view_;

  base::WeakPtrFactory<NavigableContentsImpl> weak_ptr_factory_{this};

  DISALLOW_COPY_AND_ASSIGN(NavigableContentsImpl);
};

}  // namespace content

#endif  // SERVICES_CONTENT_NAVIGABLE_CONTENTS_IMPL_H_