OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SERVICES_NAVIGATION_VIEW_IMPL_H_ | 5 #ifndef SERVICES_NAVIGATION_VIEW_IMPL_H_ |
6 #define SERVICES_NAVIGATION_VIEW_IMPL_H_ | 6 #define SERVICES_NAVIGATION_VIEW_IMPL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "components/mus/public/cpp/window_tree_delegate.h" | |
10 #include "content/public/browser/web_contents_delegate.h" | 9 #include "content/public/browser/web_contents_delegate.h" |
11 #include "mojo/public/cpp/bindings/binding_set.h" | 10 #include "mojo/public/cpp/bindings/binding_set.h" |
12 #include "mojo/public/cpp/bindings/strong_binding.h" | 11 #include "mojo/public/cpp/bindings/strong_binding.h" |
13 #include "services/navigation/public/interfaces/view.mojom.h" | 12 #include "services/navigation/public/interfaces/view.mojom.h" |
14 #include "services/shell/public/cpp/interface_factory.h" | 13 #include "services/shell/public/cpp/interface_factory.h" |
15 #include "services/shell/public/cpp/shell_client.h" | 14 #include "services/shell/public/cpp/shell_client.h" |
16 #include "services/shell/public/cpp/shell_connection_ref.h" | 15 #include "services/shell/public/cpp/shell_connection_ref.h" |
17 #include "ui/views/widget/widget_delegate.h" | |
18 | |
19 namespace views { | |
20 class WebView; | |
21 class Widget; | |
22 } | |
23 | 16 |
24 namespace navigation { | 17 namespace navigation { |
25 | 18 |
26 class ViewImpl : public mojom::View, | 19 class ViewImpl : public mojom::View, |
27 public content::WebContentsDelegate, | 20 public content::WebContentsDelegate { |
28 public mus::WindowTreeDelegate, | |
29 public views::WidgetDelegate { | |
30 public: | 21 public: |
31 ViewImpl(shell::Connector* connector, | 22 ViewImpl(content::BrowserContext* browser_context, |
32 content::BrowserContext* browser_context, | |
33 mojom::ViewClientPtr client, | 23 mojom::ViewClientPtr client, |
34 mojom::ViewRequest request, | 24 mojom::ViewRequest request, |
35 std::unique_ptr<shell::ShellConnectionRef> ref); | 25 std::unique_ptr<shell::ShellConnectionRef> ref); |
36 ~ViewImpl() override; | 26 ~ViewImpl() override; |
37 | 27 |
38 private: | 28 private: |
39 // mojom::View: | 29 // mojom::View: |
40 void NavigateTo(const GURL& url) override; | 30 void LoadUrl(const GURL& url) override; |
41 void GoBack() override; | |
42 void GoForward() override; | |
43 void Reload(bool skip_cache) override; | |
44 void Stop() override; | |
45 void GetWindowTreeClient( | |
46 mus::mojom::WindowTreeClientRequest request) override; | |
47 | 31 |
48 // content::WebContentsDelegate: | 32 // content::WebContentsDelegate: |
49 void AddNewContents(content::WebContents* source, | |
50 content::WebContents* new_contents, | |
51 WindowOpenDisposition disposition, | |
52 const gfx::Rect& initial_rect, | |
53 bool user_gesture, | |
54 bool* was_blocked) override; | |
55 void CloseContents(content::WebContents* source) override; | |
56 void LoadingStateChanged(content::WebContents* source, | 33 void LoadingStateChanged(content::WebContents* source, |
57 bool to_different_document) override; | 34 bool to_different_document) override; |
58 void NavigationStateChanged(content::WebContents* source, | |
59 content::InvalidateTypes changed_flags) override; | |
60 void LoadProgressChanged(content::WebContents* source, | |
61 double progress) override; | |
62 | 35 |
63 // mus::WindowTreeDelegate: | |
64 void OnEmbed(mus::Window* root) override; | |
65 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | |
66 void OnEventObserved(const ui::Event& event, mus::Window* target) override; | |
67 | |
68 // views::WidgetDelegate: | |
69 views::View* GetContentsView() override; | |
70 views::Widget* GetWidget() override; | |
71 const views::Widget* GetWidget() const override; | |
72 | |
73 shell::Connector* connector_; | |
74 mojo::StrongBinding<mojom::View> binding_; | 36 mojo::StrongBinding<mojom::View> binding_; |
75 mojom::ViewClientPtr client_; | 37 mojom::ViewClientPtr client_; |
76 std::unique_ptr<shell::ShellConnectionRef> ref_; | 38 std::unique_ptr<shell::ShellConnectionRef> ref_; |
77 | 39 |
78 views::WebView* web_view_; | |
79 | |
80 std::unique_ptr<content::WebContents> web_contents_; | 40 std::unique_ptr<content::WebContents> web_contents_; |
81 | 41 |
82 std::unique_ptr<views::Widget> widget_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(ViewImpl); | 42 DISALLOW_COPY_AND_ASSIGN(ViewImpl); |
85 }; | 43 }; |
86 | 44 |
87 } // navigation | 45 } // navigation |
88 | 46 |
89 #endif // SERVICES_NAVIGATION_VIEW_IMPL_H_ | 47 #endif // SERVICES_NAVIGATION_VIEW_IMPL_H_ |
OLD | NEW |