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.
5 #ifndef MANDOLINE_UI_BROWSER_BROWSER_H_
6 #define MANDOLINE_UI_BROWSER_BROWSER_H_
8 #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/interfaces/view_manager_root.mojom.h"
11 #include "mandoline/services/navigation/public/interfaces/navigation.mojom.h"
12 #include "mandoline/ui/browser/navigator_host_impl.h"
13 #include "mandoline/ui/browser/public/interfaces/launch_handler.mojom.h"
14 #include "mandoline/ui/browser/public/interfaces/omnibox.mojom.h"
15 #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_impl.h"
18 #include "mojo/application/public/cpp/connect.h"
19 #include "mojo/common/weak_binding_set.h"
20 #include "ui/mojo/events/input_events.mojom.h"
24 class ViewManagerInit
;
32 class Browser
: public mojo::ApplicationDelegate
,
33 public mojo::ViewManagerDelegate
,
34 public mojo::ViewManagerRootClient
,
38 public mojo::InterfaceFactory
<mojo::NavigatorHost
>,
39 public mojo::InterfaceFactory
<ViewEmbedder
>,
40 public mojo::InterfaceFactory
<LaunchHandler
> {
45 void ReplaceContentWithRequest(mojo::URLRequestPtr request
);
47 mojo::View
* content() { return content_
; }
48 mojo::View
* omnibox() { return omnibox_
; }
50 const GURL
& current_url() const { return current_url_
; }
53 // Overridden from mojo::ApplicationDelegate:
54 void Initialize(mojo::ApplicationImpl
* app
) override
;
55 bool ConfigureIncomingConnection(
56 mojo::ApplicationConnection
* connection
) override
;
57 bool ConfigureOutgoingConnection(
58 mojo::ApplicationConnection
* connection
) override
;
60 // Overridden from mojo::ViewManagerDelegate:
61 void OnEmbed(mojo::View
* root
) override
;
62 void OnEmbedForDescendant(mojo::View
* view
,
63 mojo::URLRequestPtr request
,
64 mojo::ViewManagerClientPtr
* client
) override
;
65 void OnViewManagerDestroyed(mojo::ViewManager
* view_manager
) override
;
67 // Overridden from ViewManagerRootClient:
68 void OnAccelerator(mojo::EventPtr event
) override
;
70 // Overridden from OmniboxClient:
71 void OpenURL(const mojo::String
& url
) override
;
73 // Overridden from ViewEmbedder:
74 void Embed(mojo::URLRequestPtr request
) override
;
76 // Overridden from LaunchHandler:
77 void LaunchURL(const mojo::String
& url
) override
;
79 // Overridden from mojo::InterfaceFactory<mojo::NavigatorHost>:
80 void Create(mojo::ApplicationConnection
* connection
,
81 mojo::InterfaceRequest
<mojo::NavigatorHost
> request
) override
;
83 // Overridden from mojo::InterfaceFactory<ViewEmbedder>:
84 void Create(mojo::ApplicationConnection
* connection
,
85 mojo::InterfaceRequest
<ViewEmbedder
> request
) override
;
87 // Overridden from mojo::InterfaceFactory<LaunchHandler>:
88 void Create(mojo::ApplicationConnection
* connection
,
89 mojo::InterfaceRequest
<LaunchHandler
> request
) override
;
91 void ShowOmnibox(mojo::URLRequestPtr request
);
93 scoped_ptr
<mojo::ViewManagerInit
> view_manager_init_
;
95 // Only support being embedded once, so both application-level
96 // and embedding-level state are shared on the same object.
100 std::string default_url_
;
101 mojo::URLRequestPtr pending_request_
;
103 mojo::WeakBindingSet
<ViewEmbedder
> view_embedder_bindings_
;
104 mojo::WeakBindingSet
<LaunchHandler
> launch_handler_bindings_
;
106 NavigatorHostImpl navigator_host_
;
110 scoped_ptr
<BrowserUI
> ui_
;
111 mojo::ApplicationImpl
* app_
;
113 scoped_ptr
<FrameTree
> frame_tree_
;
115 DISALLOW_COPY_AND_ASSIGN(Browser
);
118 } // namespace mandoline
120 #endif // MANDOLINE_UI_BROWSER_BROWSER_H_