| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ | |
| 6 #define MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "components/mus/public/cpp/window_manager_delegate.h" | |
| 12 #include "components/mus/public/cpp/window_tree_connection.h" | |
| 13 #include "components/mus/public/cpp/window_tree_delegate.h" | |
| 14 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | |
| 15 #include "components/web_view/public/cpp/web_view.h" | |
| 16 #include "components/web_view/public/interfaces/web_view.mojom.h" | |
| 17 #include "mandoline/ui/desktop_ui/find_bar_delegate.h" | |
| 18 #include "mandoline/ui/desktop_ui/public/interfaces/omnibox.mojom.h" | |
| 19 #include "mandoline/ui/desktop_ui/public/interfaces/view_embedder.mojom.h" | |
| 20 #include "mojo/common/weak_binding_set.h" | |
| 21 #include "mojo/shell/public/cpp/interface_factory.h" | |
| 22 #include "url/gurl.h" | |
| 23 | |
| 24 namespace mojo { | |
| 25 class Connection; | |
| 26 class Shell; | |
| 27 } | |
| 28 | |
| 29 namespace ui { | |
| 30 namespace mojo { | |
| 31 class UIInit; | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 namespace views { | |
| 36 class AuraInit; | |
| 37 class View; | |
| 38 } | |
| 39 | |
| 40 namespace mandoline { | |
| 41 | |
| 42 class BrowserManager; | |
| 43 class FindBarView; | |
| 44 class ProgressView; | |
| 45 class ToolbarView; | |
| 46 | |
| 47 class BrowserWindow : public mus::WindowTreeDelegate, | |
| 48 public web_view::mojom::WebViewClient, | |
| 49 public ViewEmbedder, | |
| 50 public mojo::InterfaceFactory<ViewEmbedder>, | |
| 51 public FindBarDelegate, | |
| 52 public mus::WindowManagerDelegate { | |
| 53 public: | |
| 54 BrowserWindow(mojo::Shell* shell, | |
| 55 mus::mojom::WindowTreeHostFactory* host_factory, | |
| 56 BrowserManager* manager); | |
| 57 | |
| 58 void LoadURL(const GURL& url); | |
| 59 void Close(); | |
| 60 | |
| 61 void ShowOmnibox(); | |
| 62 void ShowFind(); | |
| 63 void GoBack(); | |
| 64 void GoForward(); | |
| 65 | |
| 66 private: | |
| 67 class LayoutManagerImpl; | |
| 68 | |
| 69 ~BrowserWindow() override; | |
| 70 | |
| 71 float DIPSToPixels(float value) const; | |
| 72 | |
| 73 // Overridden from mus::WindowTreeDelegate: | |
| 74 void OnEmbed(mus::Window* root) override; | |
| 75 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | |
| 76 | |
| 77 // Overridden from WindowManagerDelegate: | |
| 78 void SetWindowManagerClient(mus::WindowManagerClient* client) override; | |
| 79 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override; | |
| 80 bool OnWmSetProperty(mus::Window* window, | |
| 81 const std::string& name, | |
| 82 scoped_ptr<std::vector<uint8_t>>* new_data) override; | |
| 83 mus::Window* OnWmCreateTopLevelWindow( | |
| 84 std::map<std::string, std::vector<uint8_t>>* properties) override; | |
| 85 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override; | |
| 86 | |
| 87 // Overridden from web_view::mojom::WebViewClient: | |
| 88 void TopLevelNavigateRequest(mojo::URLRequestPtr request) override; | |
| 89 void TopLevelNavigationStarted(const mojo::String& url) override; | |
| 90 void LoadingStateChanged(bool is_loading, double progress) override; | |
| 91 void BackForwardChanged(web_view::mojom::ButtonState back_button, | |
| 92 web_view::mojom::ButtonState forward_button) override; | |
| 93 void TitleChanged(const mojo::String& title) override; | |
| 94 void FindInPageMatchCountUpdated(int32_t request_id, | |
| 95 int32_t count, | |
| 96 bool final_update) override; | |
| 97 void FindInPageSelectionUpdated(int32_t request_id, | |
| 98 int32_t active_match_ordinal) override; | |
| 99 | |
| 100 // Overridden from ViewEmbedder: | |
| 101 void Embed(mojo::URLRequestPtr request) override; | |
| 102 | |
| 103 // Overridden from mojo::InterfaceFactory<ViewEmbedder>: | |
| 104 void Create(mojo::Connection* connection, | |
| 105 mojo::InterfaceRequest<ViewEmbedder> request) override; | |
| 106 | |
| 107 | |
| 108 // Overridden from FindBarDelegate: | |
| 109 void OnDoFind(const std::string& find, bool forward) override; | |
| 110 void OnHideFindBar() override; | |
| 111 | |
| 112 void Init(mus::Window* root); | |
| 113 void EmbedOmnibox(); | |
| 114 | |
| 115 void Layout(views::View* host); | |
| 116 | |
| 117 mojo::Shell* shell_; | |
| 118 mus::WindowManagerClient* window_manager_client_; | |
| 119 scoped_ptr<ui::mojo::UIInit> ui_init_; | |
| 120 scoped_ptr<views::AuraInit> aura_init_; | |
| 121 mus::mojom::WindowTreeHostPtr host_; | |
| 122 BrowserManager* manager_; | |
| 123 ToolbarView* toolbar_view_; | |
| 124 ProgressView* progress_bar_; | |
| 125 FindBarView* find_bar_view_; | |
| 126 mus::Window* root_; | |
| 127 mus::Window* content_; | |
| 128 mus::Window* omnibox_view_; | |
| 129 | |
| 130 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_; | |
| 131 | |
| 132 GURL default_url_; | |
| 133 GURL current_url_; | |
| 134 | |
| 135 // The active find match. | |
| 136 int32_t find_active_; | |
| 137 | |
| 138 // The total number of find matches. | |
| 139 int32_t find_count_; | |
| 140 | |
| 141 web_view::WebView web_view_; | |
| 142 | |
| 143 OmniboxPtr omnibox_; | |
| 144 scoped_ptr<mojo::Connection> omnibox_connection_; | |
| 145 | |
| 146 DISALLOW_COPY_AND_ASSIGN(BrowserWindow); | |
| 147 }; | |
| 148 | |
| 149 } // namespace mandoline | |
| 150 | |
| 151 #endif // MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ | |
| OLD | NEW |