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 #include "mandoline/ui/omnibox/omnibox_application.h" | 5 #include "mandoline/ui/omnibox/omnibox_application.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
32 // OmniboxImpl | 32 // OmniboxImpl |
33 | 33 |
34 class OmniboxImpl : public mus::WindowTreeDelegate, | 34 class OmniboxImpl : public mus::WindowTreeDelegate, |
35 public views::LayoutManager, | 35 public views::LayoutManager, |
36 public views::TextfieldController, | 36 public views::TextfieldController, |
37 public Omnibox { | 37 public Omnibox { |
38 public: | 38 public: |
39 OmniboxImpl(mojo::Shell* shell, | 39 OmniboxImpl(mojo::Shell* shell, |
40 mojo::ApplicationConnection* connection, | 40 mojo::Connection* connection, |
41 mojo::InterfaceRequest<Omnibox> request); | 41 mojo::InterfaceRequest<Omnibox> request); |
42 ~OmniboxImpl() override; | 42 ~OmniboxImpl() override; |
43 | 43 |
44 private: | 44 private: |
45 // Overridden from mus::WindowTreeDelegate: | 45 // Overridden from mus::WindowTreeDelegate: |
46 void OnEmbed(mus::Window* root) override; | 46 void OnEmbed(mus::Window* root) override; |
47 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 47 void OnConnectionLost(mus::WindowTreeConnection* connection) override; |
48 | 48 |
49 // Overridden from views::LayoutManager: | 49 // Overridden from views::LayoutManager: |
50 gfx::Size GetPreferredSize(const views::View* view) const override; | 50 gfx::Size GetPreferredSize(const views::View* view) const override; |
(...skipping 23 matching lines...) Expand all Loading... |
74 DISALLOW_COPY_AND_ASSIGN(OmniboxImpl); | 74 DISALLOW_COPY_AND_ASSIGN(OmniboxImpl); |
75 }; | 75 }; |
76 | 76 |
77 //////////////////////////////////////////////////////////////////////////////// | 77 //////////////////////////////////////////////////////////////////////////////// |
78 // OmniboxApplication, public: | 78 // OmniboxApplication, public: |
79 | 79 |
80 OmniboxApplication::OmniboxApplication() : shell_(nullptr) {} | 80 OmniboxApplication::OmniboxApplication() : shell_(nullptr) {} |
81 OmniboxApplication::~OmniboxApplication() {} | 81 OmniboxApplication::~OmniboxApplication() {} |
82 | 82 |
83 //////////////////////////////////////////////////////////////////////////////// | 83 //////////////////////////////////////////////////////////////////////////////// |
84 // OmniboxApplication, mojo::ApplicationDelegate implementation: | 84 // OmniboxApplication, mojo::ShellClient implementation: |
85 | 85 |
86 void OmniboxApplication::Initialize(mojo::Shell* shell, const std::string& url, | 86 void OmniboxApplication::Initialize(mojo::Shell* shell, const std::string& url, |
87 uint32_t id) { | 87 uint32_t id) { |
88 shell_ = shell; | 88 shell_ = shell; |
89 tracing_.Initialize(shell, url); | 89 tracing_.Initialize(shell, url); |
90 } | 90 } |
91 | 91 |
92 bool OmniboxApplication::AcceptConnection( | 92 bool OmniboxApplication::AcceptConnection(mojo::Connection* connection) { |
93 mojo::ApplicationConnection* connection) { | |
94 connection->AddService<Omnibox>(this); | 93 connection->AddService<Omnibox>(this); |
95 return true; | 94 return true; |
96 } | 95 } |
97 | 96 |
98 //////////////////////////////////////////////////////////////////////////////// | 97 //////////////////////////////////////////////////////////////////////////////// |
99 // OmniboxApplication, mojo::InterfaceFactory<Omnibox> implementation: | 98 // OmniboxApplication, mojo::InterfaceFactory<Omnibox> implementation: |
100 | 99 |
101 void OmniboxApplication::Create(mojo::ApplicationConnection* connection, | 100 void OmniboxApplication::Create(mojo::Connection* connection, |
102 mojo::InterfaceRequest<Omnibox> request) { | 101 mojo::InterfaceRequest<Omnibox> request) { |
103 new OmniboxImpl(shell_, connection, std::move(request)); | 102 new OmniboxImpl(shell_, connection, std::move(request)); |
104 } | 103 } |
105 | 104 |
106 //////////////////////////////////////////////////////////////////////////////// | 105 //////////////////////////////////////////////////////////////////////////////// |
107 // OmniboxImpl, public: | 106 // OmniboxImpl, public: |
108 | 107 |
109 OmniboxImpl::OmniboxImpl(mojo::Shell* shell, | 108 OmniboxImpl::OmniboxImpl(mojo::Shell* shell, |
110 mojo::ApplicationConnection* connection, | 109 mojo::Connection* connection, |
111 mojo::InterfaceRequest<Omnibox> request) | 110 mojo::InterfaceRequest<Omnibox> request) |
112 : shell_(shell), | 111 : shell_(shell), |
113 root_(nullptr), | 112 root_(nullptr), |
114 edit_(nullptr), | 113 edit_(nullptr), |
115 binding_(this, std::move(request)) { | 114 binding_(this, std::move(request)) { |
116 connection->ConnectToService(&view_embedder_); | 115 connection->ConnectToService(&view_embedder_); |
117 } | 116 } |
118 OmniboxImpl::~OmniboxImpl() {} | 117 OmniboxImpl::~OmniboxImpl() {} |
119 | 118 |
120 //////////////////////////////////////////////////////////////////////////////// | 119 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 edit_->SelectAll(false); | 226 edit_->SelectAll(false); |
228 edit_->RequestFocus(); | 227 edit_->RequestFocus(); |
229 } | 228 } |
230 | 229 |
231 void OmniboxImpl::HideWindow() { | 230 void OmniboxImpl::HideWindow() { |
232 DCHECK(root_); | 231 DCHECK(root_); |
233 root_->SetVisible(false); | 232 root_->SetVisible(false); |
234 } | 233 } |
235 | 234 |
236 } // namespace mandoline | 235 } // namespace mandoline |
OLD | NEW |