Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / mandoline / ui / desktop_ui / browser_window.h
blobc420a639297e2f80daf6d2be7d40fb354958914b
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"
19 #include "url/gurl.h"
21 namespace mojo {
22 class ApplicationConnection;
23 class Shell;
24 class View;
27 namespace mandoline {
29 class BrowserManager;
30 class ProgressView;
31 class ToolbarView;
33 class BrowserWindow : public mus::ViewTreeDelegate,
34 public mojo::ViewTreeHostClient,
35 public web_view::mojom::WebViewClient,
36 public ViewEmbedder,
37 public mojo::InterfaceFactory<ViewEmbedder>,
38 public views::LayoutManager {
39 public:
40 BrowserWindow(mojo::ApplicationImpl* app,
41 mojo::ViewTreeHostFactory* host_factory,
42 BrowserManager* manager);
44 void LoadURL(const GURL& url);
45 void Close();
47 void ShowOmnibox();
48 void GoBack();
49 void GoForward();
51 private:
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);
83 void EmbedOmnibox();
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_;
92 mus::View* root_;
93 mus::View* content_;
94 mus::View* omnibox_view_;
96 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_;
98 GURL default_url_;
99 GURL current_url_;
101 web_view::WebView web_view_;
103 OmniboxPtr omnibox_;
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_