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/mus/public/cpp/view_tree_connection.h" | 8 #include "components/mus/public/cpp/view_tree_connection.h" |
9 #include "components/mus/public/cpp/view_tree_delegate.h" | 9 #include "components/mus/public/cpp/view_tree_delegate.h" |
10 #include "components/mus/public/interfaces/view_tree_host.mojom.h" | 10 #include "components/mus/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/find_bar_delegate.h" |
14 #include "mandoline/ui/desktop_ui/public/interfaces/omnibox.mojom.h" | 15 #include "mandoline/ui/desktop_ui/public/interfaces/omnibox.mojom.h" |
15 #include "mandoline/ui/desktop_ui/public/interfaces/view_embedder.mojom.h" | 16 #include "mandoline/ui/desktop_ui/public/interfaces/view_embedder.mojom.h" |
16 #include "mojo/application/public/cpp/interface_factory.h" | 17 #include "mojo/application/public/cpp/interface_factory.h" |
17 #include "mojo/common/weak_binding_set.h" | 18 #include "mojo/common/weak_binding_set.h" |
18 #include "ui/views/layout/layout_manager.h" | 19 #include "ui/views/layout/layout_manager.h" |
19 #include "url/gurl.h" | 20 #include "url/gurl.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 class ApplicationConnection; | 23 class ApplicationConnection; |
23 class Shell; | 24 class Shell; |
24 class View; | 25 class View; |
25 } | 26 } |
26 | 27 |
27 namespace mandoline { | 28 namespace mandoline { |
28 | 29 |
29 class BrowserManager; | 30 class BrowserManager; |
| 31 class FindBarView; |
30 class ProgressView; | 32 class ProgressView; |
31 class ToolbarView; | 33 class ToolbarView; |
32 | 34 |
33 class BrowserWindow : public mus::ViewTreeDelegate, | 35 class BrowserWindow : public mus::ViewTreeDelegate, |
34 public mojo::ViewTreeHostClient, | 36 public mojo::ViewTreeHostClient, |
35 public web_view::mojom::WebViewClient, | 37 public web_view::mojom::WebViewClient, |
36 public ViewEmbedder, | 38 public ViewEmbedder, |
37 public mojo::InterfaceFactory<ViewEmbedder>, | 39 public mojo::InterfaceFactory<ViewEmbedder>, |
38 public views::LayoutManager { | 40 public views::LayoutManager, |
| 41 public FindBarDelegate { |
39 public: | 42 public: |
40 BrowserWindow(mojo::ApplicationImpl* app, | 43 BrowserWindow(mojo::ApplicationImpl* app, |
41 mojo::ViewTreeHostFactory* host_factory, | 44 mojo::ViewTreeHostFactory* host_factory, |
42 BrowserManager* manager); | 45 BrowserManager* manager); |
43 | 46 |
44 void LoadURL(const GURL& url); | 47 void LoadURL(const GURL& url); |
45 void Close(); | 48 void Close(); |
46 | 49 |
47 void ShowOmnibox(); | 50 void ShowOmnibox(); |
| 51 void ShowFind(); |
48 void GoBack(); | 52 void GoBack(); |
49 void GoForward(); | 53 void GoForward(); |
50 | 54 |
51 private: | 55 private: |
52 ~BrowserWindow() override; | 56 ~BrowserWindow() override; |
53 | 57 |
54 float DIPSToPixels(float value) const; | 58 float DIPSToPixels(float value) const; |
55 | 59 |
56 // Overridden from mus::ViewTreeDelegate: | 60 // Overridden from mus::ViewTreeDelegate: |
57 void OnEmbed(mus::View* root) override; | 61 void OnEmbed(mus::View* root) override; |
58 void OnConnectionLost(mus::ViewTreeConnection* connection) override; | 62 void OnConnectionLost(mus::ViewTreeConnection* connection) override; |
59 | 63 |
60 // Overridden from ViewTreeHostClient: | 64 // Overridden from ViewTreeHostClient: |
61 void OnAccelerator(uint32_t id, mojo::EventPtr event) override; | 65 void OnAccelerator(uint32_t id, mojo::EventPtr event) override; |
62 | 66 |
63 // Overridden from web_view::mojom::WebViewClient: | 67 // Overridden from web_view::mojom::WebViewClient: |
64 void TopLevelNavigateRequest(mojo::URLRequestPtr request) override; | 68 void TopLevelNavigateRequest(mojo::URLRequestPtr request) override; |
65 void TopLevelNavigationStarted(const mojo::String& url) override; | 69 void TopLevelNavigationStarted(const mojo::String& url) override; |
66 void LoadingStateChanged(bool is_loading, double progress) override; | 70 void LoadingStateChanged(bool is_loading, double progress) override; |
67 void BackForwardChanged(web_view::mojom::ButtonState back_button, | 71 void BackForwardChanged(web_view::mojom::ButtonState back_button, |
68 web_view::mojom::ButtonState forward_button) override; | 72 web_view::mojom::ButtonState forward_button) override; |
69 void TitleChanged(const mojo::String& title) override; | 73 void TitleChanged(const mojo::String& title) override; |
| 74 void FindInPageMatchCountUpdated(int32_t request_id, |
| 75 int32_t count, |
| 76 bool final_update) override; |
| 77 void FindInPageSelectionUpdated(int32_t request_id, |
| 78 int32_t active_match_ordinal) override; |
70 | 79 |
71 // Overridden from ViewEmbedder: | 80 // Overridden from ViewEmbedder: |
72 void Embed(mojo::URLRequestPtr request) override; | 81 void Embed(mojo::URLRequestPtr request) override; |
73 | 82 |
74 // Overridden from mojo::InterfaceFactory<ViewEmbedder>: | 83 // Overridden from mojo::InterfaceFactory<ViewEmbedder>: |
75 void Create(mojo::ApplicationConnection* connection, | 84 void Create(mojo::ApplicationConnection* connection, |
76 mojo::InterfaceRequest<ViewEmbedder> request) override; | 85 mojo::InterfaceRequest<ViewEmbedder> request) override; |
77 | 86 |
78 | 87 |
79 // Overridden from views::LayoutManager: | 88 // Overridden from views::LayoutManager: |
80 gfx::Size GetPreferredSize(const views::View* view) const override; | 89 gfx::Size GetPreferredSize(const views::View* view) const override; |
81 void Layout(views::View* host) override; | 90 void Layout(views::View* host) override; |
82 | 91 |
| 92 // Overridden from FindBarDelegate: |
| 93 void OnDoFind(const std::string& find) override; |
| 94 void OnHideFindBar() override; |
| 95 |
83 void Init(mus::View* root); | 96 void Init(mus::View* root); |
84 void EmbedOmnibox(); | 97 void EmbedOmnibox(); |
85 | 98 |
86 mojo::ApplicationImpl* app_; | 99 mojo::ApplicationImpl* app_; |
87 scoped_ptr<AuraInit> aura_init_; | 100 scoped_ptr<AuraInit> aura_init_; |
88 mojo::ViewTreeHostPtr host_; | 101 mojo::ViewTreeHostPtr host_; |
89 mojo::Binding<ViewTreeHostClient> host_client_binding_; | 102 mojo::Binding<ViewTreeHostClient> host_client_binding_; |
90 BrowserManager* manager_; | 103 BrowserManager* manager_; |
91 ToolbarView* toolbar_view_; | 104 ToolbarView* toolbar_view_; |
92 ProgressView* progress_bar_; | 105 ProgressView* progress_bar_; |
| 106 FindBarView* find_bar_view_; |
93 mus::View* root_; | 107 mus::View* root_; |
94 mus::View* content_; | 108 mus::View* content_; |
95 mus::View* omnibox_view_; | 109 mus::View* omnibox_view_; |
96 | 110 |
97 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_; | 111 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_; |
98 | 112 |
99 GURL default_url_; | 113 GURL default_url_; |
100 GURL current_url_; | 114 GURL current_url_; |
101 | 115 |
| 116 // The active find match. |
| 117 int32_t find_active_; |
| 118 |
| 119 // The total number of find matches. |
| 120 int32_t find_count_; |
| 121 |
102 web_view::WebView web_view_; | 122 web_view::WebView web_view_; |
103 | 123 |
104 OmniboxPtr omnibox_; | 124 OmniboxPtr omnibox_; |
105 scoped_ptr<mojo::ApplicationConnection> omnibox_connection_; | 125 scoped_ptr<mojo::ApplicationConnection> omnibox_connection_; |
106 | 126 |
107 DISALLOW_COPY_AND_ASSIGN(BrowserWindow); | 127 DISALLOW_COPY_AND_ASSIGN(BrowserWindow); |
108 }; | 128 }; |
109 | 129 |
110 } // namespace mandoline | 130 } // namespace mandoline |
111 | 131 |
112 #endif // MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ | 132 #endif // MANDOLINE_UI_DESKTOP_UI_BROWSER_WINDOW_H_ |
OLD | NEW |