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