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
3 // found in the LICENSE file.
5 #ifndef MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_
6 #define MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_
8 #include "components/mus/public/cpp/view_tree_connection.h"
9 #include "components/mus/public/cpp/view_tree_delegate.h"
10 #include "components/mus/public/interfaces/view_tree_host.mojom.h"
11 #include "components/web_view/public/cpp/web_view.h"
12 #include "components/web_view/public/interfaces/web_view.mojom.h"
13 #include "mandoline/ui/aura/aura_init.h"
14 #include "mandoline/ui/desktop_ui/public/interfaces/omnibox.mojom.h"
15 #include "mandoline/ui/desktop_ui/public/interfaces/view_embedder.mojom.h"
16 #include "mojo/application/public/cpp/interface_factory.h"
17 #include "mojo/common/weak_binding_set.h"
18 #include "ui/views/layout/layout_manager.h"
22 class ApplicationConnection
;
33 class BrowserWindow
: public mus::ViewTreeDelegate
,
34 public mojo::ViewTreeHostClient
,
35 public web_view::mojom::WebViewClient
,
37 public mojo::InterfaceFactory
<ViewEmbedder
>,
38 public views::LayoutManager
{
40 BrowserWindow(mojo::ApplicationImpl
* app
,
41 mojo::ViewTreeHostFactory
* host_factory
,
42 BrowserManager
* manager
);
44 void LoadURL(const GURL
& url
);
52 ~BrowserWindow() override
;
54 float DIPSToPixels(float value
) const;
56 // Overridden from mus::ViewTreeDelegate:
57 void OnEmbed(mus::View
* root
) override
;
58 void OnConnectionLost(mus::ViewTreeConnection
* connection
) override
;
60 // Overridden from ViewTreeHostClient:
61 void OnAccelerator(uint32_t id
, mojo::EventPtr event
) override
;
63 // Overridden from web_view::mojom::WebViewClient:
64 void TopLevelNavigate(mojo::URLRequestPtr request
) override
;
65 void LoadingStateChanged(bool is_loading
, double progress
) override
;
66 void BackForwardChanged(web_view::mojom::ButtonState back_button
,
67 web_view::mojom::ButtonState forward_button
) override
;
68 void TitleChanged(const mojo::String
& title
) override
;
70 // Overridden from ViewEmbedder:
71 void Embed(mojo::URLRequestPtr request
) override
;
73 // Overridden from mojo::InterfaceFactory<ViewEmbedder>:
74 void Create(mojo::ApplicationConnection
* connection
,
75 mojo::InterfaceRequest
<ViewEmbedder
> request
) override
;
78 // Overridden from views::LayoutManager:
79 gfx::Size
GetPreferredSize(const views::View
* view
) const override
;
80 void Layout(views::View
* host
) override
;
82 void Init(mus::View
* root
);
85 mojo::ApplicationImpl
* app_
;
86 scoped_ptr
<AuraInit
> aura_init_
;
87 mojo::ViewTreeHostPtr host_
;
88 mojo::Binding
<ViewTreeHostClient
> host_client_binding_
;
89 BrowserManager
* manager_
;
90 ToolbarView
* toolbar_view_
;
91 ProgressView
* progress_bar_
;
94 mus::View
* omnibox_view_
;
96 mojo::WeakBindingSet
<ViewEmbedder
> view_embedder_bindings_
;
101 web_view::WebView web_view_
;
104 scoped_ptr
<mojo::ApplicationConnection
> omnibox_connection_
;
106 DISALLOW_COPY_AND_ASSIGN(BrowserWindow
);
109 } // namespace mandoline
111 #endif // MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_