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_BROWSER_BROWSER_H_ | 5 #ifndef MANDOLINE_UI_BROWSER_BROWSER_H_ |
6 #define MANDOLINE_UI_BROWSER_BROWSER_H_ | 6 #define MANDOLINE_UI_BROWSER_BROWSER_H_ |
7 | 7 |
8 #include "components/view_manager/public/cpp/view_manager.h" | 8 #include "components/view_manager/public/cpp/view_manager.h" |
9 #include "components/view_manager/public/cpp/view_manager_delegate.h" | 9 #include "components/view_manager/public/cpp/view_manager_delegate.h" |
10 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h" | 10 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h" |
11 #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" | 11 #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" |
12 #include "mandoline/ui/browser/navigator_host_impl.h" | 12 #include "mandoline/ui/browser/navigator_host_impl.h" |
13 #include "mandoline/ui/browser/omnibox.mojom.h" | 13 #include "mandoline/ui/browser/omnibox.mojom.h" |
| 14 #include "mandoline/ui/browser/view_embedder.mojom.h" |
14 #include "mojo/application/public/cpp/application_delegate.h" | 15 #include "mojo/application/public/cpp/application_delegate.h" |
15 #include "mojo/application/public/cpp/application_impl.h" | 16 #include "mojo/application/public/cpp/application_impl.h" |
16 #include "mojo/application/public/cpp/connect.h" | 17 #include "mojo/application/public/cpp/connect.h" |
17 #include "mojo/application/public/cpp/service_provider_impl.h" | 18 #include "mojo/application/public/cpp/service_provider_impl.h" |
| 19 #include "mojo/common/weak_binding_set.h" |
18 #include "ui/mojo/events/input_events.mojom.h" | 20 #include "ui/mojo/events/input_events.mojom.h" |
19 #include "url/gurl.h" | 21 #include "url/gurl.h" |
20 | 22 |
21 namespace mojo { | 23 namespace mojo { |
22 class ViewManagerInit; | 24 class ViewManagerInit; |
23 } | 25 } |
24 | 26 |
25 namespace mandoline { | 27 namespace mandoline { |
26 | 28 |
27 class BrowserUI; | 29 class BrowserUI; |
28 class MergedServiceProvider; | 30 class MergedServiceProvider; |
29 | 31 |
30 class Browser : public mojo::ApplicationDelegate, | 32 class Browser : public mojo::ApplicationDelegate, |
31 public mojo::ViewManagerDelegate, | 33 public mojo::ViewManagerDelegate, |
32 public mojo::ViewManagerRootClient, | 34 public mojo::ViewManagerRootClient, |
33 public OmniboxClient, | 35 public OmniboxClient, |
34 public mojo::InterfaceFactory<mojo::NavigatorHost> { | 36 public ViewEmbedder, |
| 37 public mojo::InterfaceFactory<mojo::NavigatorHost>, |
| 38 public mojo::InterfaceFactory<ViewEmbedder> { |
35 public: | 39 public: |
36 Browser(); | 40 Browser(); |
37 ~Browser() override; | 41 ~Browser() override; |
38 | 42 |
39 void ReplaceContentWithURL(const mojo::String& url); | 43 void ReplaceContentWithURL(const mojo::String& url); |
40 | 44 |
41 mojo::View* content() { return content_; } | 45 mojo::View* content() { return content_; } |
42 mojo::View* omnibox() { return omnibox_; } | 46 mojo::View* omnibox() { return omnibox_; } |
43 | 47 |
44 const GURL& current_url() const { return current_url_; } | 48 const GURL& current_url() const { return current_url_; } |
(...skipping 11 matching lines...) Expand all Loading... |
56 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 60 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
57 mojo::ServiceProviderPtr exposed_services) override; | 61 mojo::ServiceProviderPtr exposed_services) override; |
58 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override; | 62 void OnViewManagerDisconnected(mojo::ViewManager* view_manager) override; |
59 | 63 |
60 // Overridden from ViewManagerRootClient: | 64 // Overridden from ViewManagerRootClient: |
61 void OnAccelerator(mojo::EventPtr event) override; | 65 void OnAccelerator(mojo::EventPtr event) override; |
62 | 66 |
63 // Overridden from OmniboxClient: | 67 // Overridden from OmniboxClient: |
64 void OpenURL(const mojo::String& url) override; | 68 void OpenURL(const mojo::String& url) override; |
65 | 69 |
| 70 // Overridden from ViewEmbedder: |
| 71 void Embed(const mojo::String& url, |
| 72 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 73 mojo::ServiceProviderPtr exposed_services) override; |
| 74 |
66 // Overridden from mojo::InterfaceFactory<mojo::NavigatorHost>: | 75 // Overridden from mojo::InterfaceFactory<mojo::NavigatorHost>: |
67 void Create(mojo::ApplicationConnection* connection, | 76 void Create(mojo::ApplicationConnection* connection, |
68 mojo::InterfaceRequest<mojo::NavigatorHost> request) override; | 77 mojo::InterfaceRequest<mojo::NavigatorHost> request) override; |
69 | 78 |
70 void Embed(const mojo::String& url, | 79 // Overridden from mojo::InterfaceFactory<ViewEmbedder>: |
71 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 80 void Create(mojo::ApplicationConnection* connection, |
72 mojo::ServiceProviderPtr exposed_services); | 81 mojo::InterfaceRequest<ViewEmbedder> request) override; |
73 | 82 |
74 void ShowOmnibox(const mojo::String& url, | 83 void ShowOmnibox(const mojo::String& url, |
75 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 84 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
76 mojo::ServiceProviderPtr exposed_services); | 85 mojo::ServiceProviderPtr exposed_services); |
77 | 86 |
78 scoped_ptr<mojo::ViewManagerInit> view_manager_init_; | 87 scoped_ptr<mojo::ViewManagerInit> view_manager_init_; |
79 | 88 |
80 // Only support being embedded once, so both application-level | 89 // Only support being embedded once, so both application-level |
81 // and embedding-level state are shared on the same object. | 90 // and embedding-level state are shared on the same object. |
82 mojo::View* root_; | 91 mojo::View* root_; |
83 mojo::View* content_; | 92 mojo::View* content_; |
84 mojo::View* omnibox_; | 93 mojo::View* omnibox_; |
85 std::string default_url_; | 94 std::string default_url_; |
86 std::string pending_url_; | 95 std::string pending_url_; |
87 | 96 |
88 mojo::ServiceProviderImpl exposed_services_impl_; | 97 mojo::ServiceProviderImpl exposed_services_impl_; |
89 scoped_ptr<MergedServiceProvider> merged_service_provider_; | 98 scoped_ptr<MergedServiceProvider> merged_service_provider_; |
90 | 99 |
| 100 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_; |
| 101 |
91 NavigatorHostImpl navigator_host_; | 102 NavigatorHostImpl navigator_host_; |
92 | 103 |
93 GURL current_url_; | 104 GURL current_url_; |
94 | 105 |
95 scoped_ptr<BrowserUI> ui_; | 106 scoped_ptr<BrowserUI> ui_; |
96 | 107 |
97 DISALLOW_COPY_AND_ASSIGN(Browser); | 108 DISALLOW_COPY_AND_ASSIGN(Browser); |
98 }; | 109 }; |
99 | 110 |
100 } // namespace mandoline | 111 } // namespace mandoline |
101 | 112 |
102 #endif // MANDOLINE_UI_BROWSER_BROWSER_H_ | 113 #endif // MANDOLINE_UI_BROWSER_BROWSER_H_ |
OLD | NEW |