OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 SERVICES_NAVIGATION_VIEW_IMPL_H_ | |
6 #define SERVICES_NAVIGATION_VIEW_IMPL_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "content/public/browser/notification_observer.h" | |
12 #include "content/public/browser/notification_registrar.h" | |
13 #include "content/public/browser/web_contents_delegate.h" | |
14 #include "mojo/public/cpp/bindings/binding_set.h" | |
15 #include "services/navigation/public/interfaces/view.mojom.h" | |
16 #include "services/service_manager/public/cpp/connector.h" | |
17 #include "services/service_manager/public/cpp/service.h" | |
18 #include "services/service_manager/public/cpp/service_context_ref.h" | |
19 #include "ui/aura/mus/window_tree_client_delegate.h" | |
20 #include "ui/gfx/geometry/size.h" | |
21 #include "ui/views/widget/widget_delegate.h" | |
22 | |
23 namespace views { | |
24 class WebView; | |
25 class Widget; | |
26 } | |
27 | |
28 namespace navigation { | |
29 | |
30 class ViewImpl : public mojom::View, | |
31 public content::WebContentsDelegate, | |
32 public content::NotificationObserver, | |
33 public aura::WindowTreeClientDelegate, | |
34 public views::WidgetDelegate { | |
35 public: | |
36 ViewImpl(std::unique_ptr<service_manager::Connector> connector, | |
37 const std::string& client_user_id, | |
38 mojom::ViewClientPtr client, | |
39 std::unique_ptr<service_manager::ServiceContextRef> ref); | |
40 ~ViewImpl() override; | |
41 | |
42 private: | |
43 void DeleteTreeAndWidget(); | |
44 | |
45 // mojom::View: | |
46 void NavigateTo(const GURL& url) override; | |
47 void GoBack() override; | |
48 void GoForward() override; | |
49 void NavigateToOffset(int offset) override; | |
50 void Reload(bool bypass_cache) override; | |
51 void Stop() override; | |
52 void GetWindowTreeClient(ui::mojom::WindowTreeClientRequest request) override; | |
53 void ShowInterstitial(const std::string& html) override; | |
54 void HideInterstitial() override; | |
55 | |
56 // content::WebContentsDelegate: | |
57 void AddNewContents(content::WebContents* source, | |
58 content::WebContents* new_contents, | |
59 WindowOpenDisposition disposition, | |
60 const gfx::Rect& initial_rect, | |
61 bool user_gesture, | |
62 bool* was_blocked) override; | |
63 void CloseContents(content::WebContents* source) override; | |
64 content::WebContents* OpenURLFromTab( | |
65 content::WebContents* source, | |
66 const content::OpenURLParams& params) override; | |
67 void LoadingStateChanged(content::WebContents* source, | |
68 bool to_different_document) override; | |
69 void NavigationStateChanged(content::WebContents* source, | |
70 content::InvalidateTypes changed_flags) override; | |
71 void LoadProgressChanged(content::WebContents* source, | |
72 double progress) override; | |
73 void UpdateTargetURL(content::WebContents* source, const GURL& url) override; | |
74 | |
75 // content::NotificationObserver: | |
76 void Observe(int type, | |
77 const content::NotificationSource& source, | |
78 const content::NotificationDetails& details) override; | |
79 | |
80 // aura::WindowTreeClientDelegate: | |
81 void OnEmbed( | |
82 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override; | |
83 void OnEmbedRootDestroyed(aura::WindowTreeHostMus* window_tree_host) override; | |
84 void OnLostConnection(aura::WindowTreeClient* client) override; | |
85 void OnPointerEventObserved(const ui::PointerEvent& event, | |
86 aura::Window* target) override; | |
87 aura::PropertyConverter* GetPropertyConverter() override; | |
88 | |
89 // views::WidgetDelegate: | |
90 views::View* GetContentsView() override; | |
91 views::Widget* GetWidget() override; | |
92 const views::Widget* GetWidget() const override; | |
93 | |
94 std::unique_ptr<service_manager::Connector> connector_; | |
95 mojom::ViewClientPtr client_; | |
96 std::unique_ptr<service_manager::ServiceContextRef> ref_; | |
97 | |
98 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; | |
99 | |
100 views::WebView* web_view_; | |
101 | |
102 std::unique_ptr<content::WebContents> web_contents_; | |
103 | |
104 content::NotificationRegistrar registrar_; | |
105 | |
106 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_; | |
107 std::unique_ptr<views::Widget> widget_; | |
108 | |
109 DISALLOW_COPY_AND_ASSIGN(ViewImpl); | |
110 }; | |
111 | |
112 } // navigation | |
113 | |
114 #endif // SERVICES_NAVIGATION_VIEW_IMPL_H_ | |
OLD | NEW |