Roll src/third_party/WebKit a452221:9ff6d11 (svn 202117:202119)
[chromium-blink-merge.git] / mandoline / ui / desktop_ui / browser_window.h
blobcbb61f54579c060555d749b9ee71afe0ff3b0b68
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/view_manager/public/cpp/view_tree_connection.h"
9 #include "components/view_manager/public/cpp/view_tree_delegate.h"
10 #include "components/view_manager/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/controls/button/button.h"
19 #include "ui/views/layout/layout_manager.h"
20 #include "url/gurl.h"
22 namespace mojo {
23 class ApplicationConnection;
24 class Shell;
25 class View;
28 namespace views {
29 class LabelButton;
32 namespace mandoline {
34 class BrowserManager;
35 class ProgressView;
37 class BrowserWindow : public mojo::ViewTreeDelegate,
38 public mojo::ViewTreeHostClient,
39 public web_view::mojom::WebViewClient,
40 public ViewEmbedder,
41 public mojo::InterfaceFactory<ViewEmbedder>,
42 public views::LayoutManager,
43 public views::ButtonListener {
44 public:
45 BrowserWindow(mojo::ApplicationImpl* app,
46 mojo::ViewTreeHostFactory* host_factory,
47 BrowserManager* manager);
49 void LoadURL(const GURL& url);
50 void Close();
52 private:
53 ~BrowserWindow() override;
55 float DIPSToPixels(float value) const;
57 // Overridden from mojo::ViewTreeDelegate:
58 void OnEmbed(mojo::View* root) override;
59 void OnConnectionLost(mojo::ViewTreeConnection* connection) override;
61 // Overridden from ViewTreeHostClient:
62 void OnAccelerator(uint32_t id, mojo::EventPtr event) override;
64 // Overridden from web_view::mojom::WebViewClient:
65 void TopLevelNavigate(mojo::URLRequestPtr request) override;
66 void LoadingStateChanged(bool is_loading) override;
67 void ProgressChanged(double progress) 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 // Overridden from views::ButtonListener:
83 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
85 void Init(mojo::View* root);
86 void ShowOmnibox();
87 void EmbedOmnibox();
89 mojo::ApplicationImpl* app_;
90 scoped_ptr<AuraInit> aura_init_;
91 mojo::ViewTreeHostPtr host_;
92 mojo::Binding<ViewTreeHostClient> host_client_binding_;
93 BrowserManager* manager_;
94 views::LabelButton* omnibox_launcher_;
95 ProgressView* progress_bar_;
96 mojo::View* root_;
97 mojo::View* content_;
98 mojo::View* omnibox_view_;
100 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_;
102 GURL default_url_;
103 GURL current_url_;
105 web_view::WebView web_view_;
107 OmniboxPtr omnibox_;
108 scoped_ptr<mojo::ApplicationConnection> omnibox_connection_;
110 DISALLOW_COPY_AND_ASSIGN(BrowserWindow);
113 } // namespace mandoline
115 #endif // MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_