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 "base/gtest_prod_util.h" |
8 #include "components/view_manager/public/cpp/view_manager.h" | 9 #include "components/view_manager/public/cpp/view_manager.h" |
9 #include "components/view_manager/public/cpp/view_manager_delegate.h" | 10 #include "components/view_manager/public/cpp/view_manager_delegate.h" |
10 #include "components/view_manager/public/cpp/view_manager_init.h" | 11 #include "components/view_manager/public/cpp/view_manager_init.h" |
11 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h" | 12 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h" |
12 #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" | 13 #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h" |
13 #include "mandoline/ui/browser/navigator_host_impl.h" | 14 #include "mandoline/ui/browser/navigator_host_impl.h" |
14 #include "mandoline/ui/browser/public/interfaces/omnibox.mojom.h" | 15 #include "mandoline/ui/browser/public/interfaces/omnibox.mojom.h" |
15 #include "mandoline/ui/browser/public/interfaces/view_embedder.mojom.h" | 16 #include "mandoline/ui/browser/public/interfaces/view_embedder.mojom.h" |
16 #include "mojo/application/public/cpp/application_delegate.h" | 17 #include "mojo/application/public/cpp/application_delegate.h" |
17 #include "mojo/application/public/cpp/application_impl.h" | 18 #include "mojo/application/public/cpp/application_impl.h" |
18 #include "mojo/application/public/cpp/connect.h" | 19 #include "mojo/application/public/cpp/connect.h" |
19 #include "mojo/common/weak_binding_set.h" | 20 #include "mojo/common/weak_binding_set.h" |
20 #include "ui/mojo/events/input_events.mojom.h" | 21 #include "ui/mojo/events/input_events.mojom.h" |
21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
22 | 23 |
23 namespace mojo { | 24 namespace mojo { |
24 class ViewManagerInit; | 25 class ViewManagerInit; |
25 } | 26 } |
26 | 27 |
27 namespace mandoline { | 28 namespace mandoline { |
28 | 29 |
29 class BrowserManager; | 30 FORWARD_DECLARE_TEST(BrowserTest, ClosingBrowserClosesAppConnection); |
| 31 |
| 32 class BrowserDelegate; |
30 class BrowserUI; | 33 class BrowserUI; |
31 class FrameTree; | 34 class FrameTree; |
32 | 35 |
33 class Browser : public mojo::ViewManagerDelegate, | 36 class Browser : public mojo::ViewManagerDelegate, |
34 public mojo::ViewManagerRootClient, | 37 public mojo::ViewManagerRootClient, |
35 public OmniboxClient, | 38 public OmniboxClient, |
36 public ViewEmbedder, | 39 public ViewEmbedder, |
37 public mojo::InterfaceFactory<mojo::NavigatorHost>, | 40 public mojo::InterfaceFactory<mojo::NavigatorHost>, |
38 public mojo::InterfaceFactory<ViewEmbedder> { | 41 public mojo::InterfaceFactory<ViewEmbedder> { |
39 public: | 42 public: |
40 Browser(mojo::ApplicationImpl* app, BrowserManager* browser_manager); | 43 Browser(mojo::ApplicationImpl* app, BrowserDelegate* delegate); |
41 ~Browser() override; | 44 ~Browser() override; |
42 | 45 |
43 void ReplaceContentWithRequest(mojo::URLRequestPtr request); | 46 void ReplaceContentWithRequest(mojo::URLRequestPtr request); |
44 | 47 |
45 mojo::View* content() { return content_; } | 48 mojo::View* content() { return content_; } |
46 mojo::View* omnibox() { return omnibox_; } | 49 mojo::View* omnibox() { return omnibox_; } |
47 | 50 |
48 const GURL& current_url() const { return current_url_; } | 51 const GURL& current_url() const { return current_url_; } |
49 | 52 |
50 // Called once a valid device_pixel_ratio is determined. We gate construction | 53 // Called once a valid device_pixel_ratio is determined. We gate construction |
51 // of the UI until the device_pixel_ratio is available as it's necessary to | 54 // of the UI until the device_pixel_ratio is available as it's necessary to |
52 // properly setup the ui. | 55 // properly setup the ui. |
53 // TODO(sky): remove this. Only here until we move to viewmanager. | 56 // TODO(sky): remove this. Only here until we move to viewmanager. |
54 void OnDevicePixelRatioAvailable(); | 57 void OnDevicePixelRatioAvailable(); |
55 | 58 |
56 private: | 59 private: |
| 60 FRIEND_TEST_ALL_PREFIXES(BrowserTest, ClosingBrowserClosesAppConnection); |
| 61 |
| 62 mojo::ApplicationConnection* GetViewManagerConnectionForTesting(); |
| 63 |
57 // Overridden from mojo::ViewManagerDelegate: | 64 // Overridden from mojo::ViewManagerDelegate: |
58 void OnEmbed(mojo::View* root) override; | 65 void OnEmbed(mojo::View* root) override; |
59 void OnEmbedForDescendant(mojo::View* view, | 66 void OnEmbedForDescendant(mojo::View* view, |
60 mojo::URLRequestPtr request, | 67 mojo::URLRequestPtr request, |
61 mojo::ViewManagerClientPtr* client) override; | 68 mojo::ViewManagerClientPtr* client) override; |
62 void OnViewManagerDestroyed(mojo::ViewManager* view_manager) override; | 69 void OnViewManagerDestroyed(mojo::ViewManager* view_manager) override; |
63 | 70 |
64 // Overridden from ViewManagerRootClient: | 71 // Overridden from ViewManagerRootClient: |
65 void OnAccelerator(mojo::EventPtr event) override; | 72 void OnAccelerator(mojo::EventPtr event) override; |
66 | 73 |
(...skipping 24 matching lines...) Expand all Loading... |
91 mojo::URLRequestPtr pending_request_; | 98 mojo::URLRequestPtr pending_request_; |
92 | 99 |
93 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_; | 100 mojo::WeakBindingSet<ViewEmbedder> view_embedder_bindings_; |
94 | 101 |
95 NavigatorHostImpl navigator_host_; | 102 NavigatorHostImpl navigator_host_; |
96 | 103 |
97 GURL current_url_; | 104 GURL current_url_; |
98 | 105 |
99 scoped_ptr<BrowserUI> ui_; | 106 scoped_ptr<BrowserUI> ui_; |
100 mojo::ApplicationImpl* app_; | 107 mojo::ApplicationImpl* app_; |
101 BrowserManager* browser_manager_; | 108 BrowserDelegate* delegate_; |
102 | 109 |
103 scoped_ptr<FrameTree> frame_tree_; | 110 scoped_ptr<FrameTree> frame_tree_; |
104 | 111 |
105 DISALLOW_COPY_AND_ASSIGN(Browser); | 112 DISALLOW_COPY_AND_ASSIGN(Browser); |
106 }; | 113 }; |
107 | 114 |
108 } // namespace mandoline | 115 } // namespace mandoline |
109 | 116 |
110 #endif // MANDOLINE_UI_BROWSER_BROWSER_H_ | 117 #endif // MANDOLINE_UI_BROWSER_BROWSER_H_ |
OLD | NEW |