summaryrefslogtreecommitdiff
path: root/chromium/services/navigation/view_impl.h
blob: bf34ffc39868c02ef367a094930e429710906693 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright 2016 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_NAVIGATION_VIEW_IMPL_H_
#define SERVICES_NAVIGATION_VIEW_IMPL_H_

#include <memory>

#include "base/macros.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_delegate.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "services/navigation/public/interfaces/view.mojom.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/interface_factory.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_context_ref.h"
#include "ui/aura/mus/window_tree_client_delegate.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/widget/widget_delegate.h"

namespace views {
class WebView;
class Widget;
}

namespace navigation {

class ViewImpl : public mojom::View,
                 public content::WebContentsDelegate,
                 public content::NotificationObserver,
                 public aura::WindowTreeClientDelegate,
                 public views::WidgetDelegate {
 public:
  ViewImpl(std::unique_ptr<service_manager::Connector> connector,
           const std::string& client_user_id,
           mojom::ViewClientPtr client,
           std::unique_ptr<service_manager::ServiceContextRef> ref);
  ~ViewImpl() override;

 private:
  void DeleteTreeAndWidget();

  // mojom::View:
  void NavigateTo(const GURL& url) override;
  void GoBack() override;
  void GoForward() override;
  void NavigateToOffset(int offset) override;
  void Reload(bool bypass_cache) override;
  void Stop() override;
  void GetWindowTreeClient(ui::mojom::WindowTreeClientRequest request) override;
  void ShowInterstitial(const std::string& html) override;
  void HideInterstitial() override;

  // content::WebContentsDelegate:
  void AddNewContents(content::WebContents* source,
                      content::WebContents* new_contents,
                      WindowOpenDisposition disposition,
                      const gfx::Rect& initial_rect,
                      bool user_gesture,
                      bool* was_blocked) override;
  void CloseContents(content::WebContents* source) override;
  content::WebContents* OpenURLFromTab(
      content::WebContents* source,
      const content::OpenURLParams& params) override;
  void LoadingStateChanged(content::WebContents* source,
                           bool to_different_document) override;
  void NavigationStateChanged(content::WebContents* source,
                              content::InvalidateTypes changed_flags) override;
  void LoadProgressChanged(content::WebContents* source,
                           double progress) override;
  void UpdateTargetURL(content::WebContents* source, const GURL& url) override;

  // content::NotificationObserver:
  void Observe(int type,
               const content::NotificationSource& source,
               const content::NotificationDetails& details) override;

  // aura::WindowTreeClientDelegate:
  void OnEmbed(
      std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override;
  void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) override;
  void OnLostConnection(aura::WindowTreeClient* client) override;
  void OnPointerEventObserved(const ui::PointerEvent& event,
                              aura::Window* target) override;
  aura::PropertyConverter* GetPropertyConverter() override;

  // views::WidgetDelegate:
  views::View* GetContentsView() override;
  views::Widget* GetWidget() override;
  const views::Widget* GetWidget() const override;

  std::unique_ptr<service_manager::Connector> connector_;
  mojom::ViewClientPtr client_;
  std::unique_ptr<service_manager::ServiceContextRef> ref_;

  std::unique_ptr<aura::WindowTreeClient> window_tree_client_;

  views::WebView* web_view_;

  std::unique_ptr<content::WebContents> web_contents_;

  content::NotificationRegistrar registrar_;

  std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_;
  std::unique_ptr<views::Widget> widget_;

  DISALLOW_COPY_AND_ASSIGN(ViewImpl);
};

}  // navigation

#endif  // SERVICES_NAVIGATION_VIEW_IMPL_H_