Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / mandoline / ui / omnibox / omnibox_impl.h
blob06bec66883dbd7823f9a1f5cbbd131f46a55eae0
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_OMNIBOX_OMNIBOX_IMPL_H_
6 #define MANDOLINE_UI_OMNIBOX_OMNIBOX_IMPL_H_
8 #include "components/view_manager/public/cpp/view_manager_delegate.h"
9 #include "mandoline/ui/browser/public/interfaces/omnibox.mojom.h"
10 #include "mandoline/ui/browser/public/interfaces/view_embedder.mojom.h"
11 #include "mojo/application/public/cpp/application_delegate.h"
12 #include "mojo/application/public/cpp/interface_factory.h"
13 #include "mojo/common/weak_binding_set.h"
14 #include "ui/views/controls/textfield/textfield_controller.h"
15 #include "ui/views/layout/layout_manager.h"
17 namespace mojo {
18 class ViewManagerClientFactory;
21 namespace mandoline {
23 class AuraInit;
25 class OmniboxImpl : public mojo::ApplicationDelegate,
26 public mojo::ViewManagerDelegate,
27 public views::LayoutManager,
28 public views::TextfieldController,
29 public mojo::InterfaceFactory<Omnibox>,
30 public Omnibox {
31 public:
32 OmniboxImpl();
33 ~OmniboxImpl() override;
35 private:
36 // Overridden from mojo::ApplicationDelegate:
37 void Initialize(mojo::ApplicationImpl* app) override;
38 bool ConfigureIncomingConnection(
39 mojo::ApplicationConnection* connection) override;
40 bool ConfigureOutgoingConnection(
41 mojo::ApplicationConnection* connection) override;
43 // Overridden from mojo::ViewManagerDelegate:
44 void OnEmbed(mojo::View* root) override;
45 void OnViewManagerDestroyed(mojo::ViewManager* view_manager) override;
47 // Overridden from views::LayoutManager:
48 gfx::Size GetPreferredSize(const views::View* view) const override;
49 void Layout(views::View* host) override;
51 // Overridden from views::TextfieldController:
52 bool HandleKeyEvent(views::Textfield* sender,
53 const ui::KeyEvent& key_event) override;
55 // InterfaceFactory<WindowManager>:
56 void Create(mojo::ApplicationConnection* connection,
57 mojo::InterfaceRequest<Omnibox> request) override;
59 // Overridden from Omnibox:
60 void SetClient(OmniboxClientPtr client) override;
61 void ShowForURL(const mojo::String& url) override;
63 OmniboxClientPtr client_;
64 scoped_ptr<AuraInit> aura_init_;
65 mojo::ApplicationImpl* app_impl_;
66 mojo::String url_;
67 views::Textfield* edit_;
68 mojo::WeakBindingSet<Omnibox> bindings_;
69 scoped_ptr<mojo::ViewManagerClientFactory> view_manager_client_factory_;
70 ViewEmbedderPtr view_embedder_;
72 DISALLOW_COPY_AND_ASSIGN(OmniboxImpl);
75 } // namespace mandoline
77 #endif // MANDOLINE_UI_OMNIBOX_OMNIBOX_IMPL_H_