OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ | 5 #ifndef MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ |
6 #define MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ | 6 #define MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ |
7 | 7 |
8 #include "components/view_manager/public/cpp/view_tree_connection.h" | 8 #include "components/view_manager/public/cpp/view_tree_connection.h" |
9 #include "components/view_manager/public/cpp/view_tree_delegate.h" | 9 #include "components/view_manager/public/cpp/view_tree_delegate.h" |
10 #include "components/view_manager/public/interfaces/view_tree_host.mojom.h" | 10 #include "components/view_manager/public/interfaces/view_tree_host.mojom.h" |
11 #include "components/web_view/public/cpp/web_view.h" | 11 #include "components/web_view/public/cpp/web_view.h" |
12 #include "components/web_view/public/interfaces/web_view.mojom.h" | 12 #include "components/web_view/public/interfaces/web_view.mojom.h" |
13 #include "mandoline/ui/aura/aura_init.h" | 13 #include "mandoline/ui/aura/aura_init.h" |
14 #include "mandoline/ui/desktop_ui/public/interfaces/omnibox.mojom.h" | 14 #include "mandoline/ui/desktop_ui/public/interfaces/omnibox.mojom.h" |
15 #include "mandoline/ui/desktop_ui/public/interfaces/view_embedder.mojom.h" | 15 #include "mandoline/ui/desktop_ui/public/interfaces/view_embedder.mojom.h" |
16 #include "mojo/application/public/cpp/interface_factory.h" | 16 #include "mojo/application/public/cpp/interface_factory.h" |
17 #include "mojo/common/weak_binding_set.h" | 17 #include "mojo/common/weak_binding_set.h" |
18 #include "ui/views/controls/button/button.h" | |
19 #include "ui/views/layout/layout_manager.h" | 18 #include "ui/views/layout/layout_manager.h" |
20 #include "url/gurl.h" | 19 #include "url/gurl.h" |
21 | 20 |
22 namespace mojo { | 21 namespace mojo { |
23 class ApplicationConnection; | 22 class ApplicationConnection; |
24 class Shell; | 23 class Shell; |
25 class View; | 24 class View; |
26 } | 25 } |
27 | 26 |
28 namespace views { | |
29 class LabelButton; | |
30 } | |
31 | |
32 namespace mandoline { | 27 namespace mandoline { |
33 | 28 |
34 class BrowserManager; | 29 class BrowserManager; |
35 class ProgressView; | 30 class ProgressView; |
| 31 class ToolbarView; |
36 | 32 |
37 class BrowserWindow : public mojo::ViewTreeDelegate, | 33 class BrowserWindow : public mojo::ViewTreeDelegate, |
38 public mojo::ViewTreeHostClient, | 34 public mojo::ViewTreeHostClient, |
39 public web_view::mojom::WebViewClient, | 35 public web_view::mojom::WebViewClient, |
40 public ViewEmbedder, | 36 public ViewEmbedder, |
41 public mojo::InterfaceFactory<ViewEmbedder>, | 37 public mojo::InterfaceFactory<ViewEmbedder>, |
42 public views::LayoutManager, | 38 public views::LayoutManager { |
43 public views::ButtonListener { | |
44 public: | 39 public: |
45 BrowserWindow(mojo::ApplicationImpl* app, | 40 BrowserWindow(mojo::ApplicationImpl* app, |
46 mojo::ViewTreeHostFactory* host_factory, | 41 mojo::ViewTreeHostFactory* host_factory, |
47 BrowserManager* manager); | 42 BrowserManager* manager); |
48 | 43 |
49 void LoadURL(const GURL& url); | 44 void LoadURL(const GURL& url); |
50 void Close(); | 45 void Close(); |
51 | 46 |
| 47 void ShowOmnibox(); |
| 48 void GoBack(); |
| 49 void GoForward(); |
| 50 |
52 private: | 51 private: |
53 ~BrowserWindow() override; | 52 ~BrowserWindow() override; |
54 | 53 |
55 float DIPSToPixels(float value) const; | 54 float DIPSToPixels(float value) const; |
56 | 55 |
57 // Overridden from mojo::ViewTreeDelegate: | 56 // Overridden from mojo::ViewTreeDelegate: |
58 void OnEmbed(mojo::View* root) override; | 57 void OnEmbed(mojo::View* root) override; |
59 void OnConnectionLost(mojo::ViewTreeConnection* connection) override; | 58 void OnConnectionLost(mojo::ViewTreeConnection* connection) override; |
60 | 59 |
61 // Overridden from ViewTreeHostClient: | 60 // Overridden from ViewTreeHostClient: |
62 void OnAccelerator(uint32_t id, mojo::EventPtr event) override; | 61 void OnAccelerator(uint32_t id, mojo::EventPtr event) override; |
63 | 62 |
64 // Overridden from web_view::mojom::WebViewClient: | 63 // Overridden from web_view::mojom::WebViewClient: |
65 void TopLevelNavigate(mojo::URLRequestPtr request) override; | 64 void TopLevelNavigate(mojo::URLRequestPtr request) override; |
66 void LoadingStateChanged(bool is_loading) override; | 65 void LoadingStateChanged(bool is_loading) override; |
67 void ProgressChanged(double progress) override; | 66 void ProgressChanged(double progress) override; |
| 67 void BackForwardChanged(web_view::mojom::ButtonState back_button, |
| 68 web_view::mojom::ButtonState forward_button) override; |
68 void TitleChanged(const mojo::String& title) override; | 69 void TitleChanged(const mojo::String& title) override; |
69 | 70 |
70 // Overridden from ViewEmbedder: | 71 // Overridden from ViewEmbedder: |
71 void Embed(mojo::URLRequestPtr request) override; | 72 void Embed(mojo::URLRequestPtr request) override; |
72 | 73 |
73 // Overridden from mojo::InterfaceFactory<ViewEmbedder>: | 74 // Overridden from mojo::InterfaceFactory<ViewEmbedder>: |
74 void Create(mojo::ApplicationConnection* connection, | 75 void Create(mojo::ApplicationConnection* connection, |
75 mojo::InterfaceRequest<ViewEmbedder> request) override; | 76 mojo::InterfaceRequest<ViewEmbedder> request) override; |
76 | 77 |
77 | 78 |
78 // Overridden from views::LayoutManager: | 79 // Overridden from views::LayoutManager: |
79 gfx::Size GetPreferredSize(const views::View* view) const override; | 80 gfx::Size GetPreferredSize(const views::View* view) const override; |
80 void Layout(views::View* host) override; | 81 void Layout(views::View* host) override; |
81 | 82 |
82 // Overridden from views::ButtonListener: | |
83 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
84 | |
85 void Init(mojo::View* root); | 83 void Init(mojo::View* root); |
86 void ShowOmnibox(); | |
87 void EmbedOmnibox(); | 84 void EmbedOmnibox(); |
88 | 85 |
89 mojo::ApplicationImpl* app_; | 86 mojo::ApplicationImpl* app_; |
90 scoped_ptr<AuraInit> aura_init_; | 87 scoped_ptr<AuraInit> aura_init_; |
91 mojo::ViewTreeHostPtr host_; | 88 mojo::ViewTreeHostPtr host_; |
92 mojo::Binding<ViewTreeHostClient> host_client_binding_; | 89 mojo::Binding<ViewTreeHostClient> host_client_binding_; |
93 BrowserManager* manager_; | 90 BrowserManager* manager_; |
94 views::LabelButton* omnibox_launcher_; | 91 ToolbarView* toolbar_view_; |
95 ProgressView* progress_bar_; | 92 ProgressView* progress_bar_; |
96 mojo::View* root_; | 93 mojo::View* root_; |
97 mojo::View* content_; | 94 mojo::View* content_; |
98 mojo::View* omnibox_view_; | 95 mojo::View* omnibox_view_; |
99 | 96 |
100 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_; | 97 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_; |
101 | 98 |
102 GURL default_url_; | 99 GURL default_url_; |
103 GURL current_url_; | 100 GURL current_url_; |
104 | 101 |
105 web_view::WebView web_view_; | 102 web_view::WebView web_view_; |
106 | 103 |
107 OmniboxPtr omnibox_; | 104 OmniboxPtr omnibox_; |
108 scoped_ptr<mojo::ApplicationConnection> omnibox_connection_; | 105 scoped_ptr<mojo::ApplicationConnection> omnibox_connection_; |
109 | 106 |
110 DISALLOW_COPY_AND_ASSIGN(BrowserWindow); | 107 DISALLOW_COPY_AND_ASSIGN(BrowserWindow); |
111 }; | 108 }; |
112 | 109 |
113 } // namespace mandoline | 110 } // namespace mandoline |
114 | 111 |
115 #endif // MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ | 112 #endif // MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ |
OLD | NEW |