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