Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: mash/quick_launch/quick_launch.cc

Issue 2476063002: Service Manager: Rework Service and ServiceContext lifetime (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mash/quick_launch/quick_launch.h ('k') | mash/screenlock/screenlock.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "mash/quick_launch/quick_launch.h" 5 #include "mash/quick_launch/quick_launch.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "mash/public/interfaces/launchable.mojom.h" 13 #include "mash/public/interfaces/launchable.mojom.h"
14 #include "services/catalog/public/interfaces/catalog.mojom.h" 14 #include "services/catalog/public/interfaces/catalog.mojom.h"
15 #include "services/service_manager/public/c/main.h" 15 #include "services/service_manager/public/c/main.h"
16 #include "services/service_manager/public/cpp/connector.h" 16 #include "services/service_manager/public/cpp/connector.h"
17 #include "services/service_manager/public/cpp/interface_registry.h"
17 #include "services/service_manager/public/cpp/service.h" 18 #include "services/service_manager/public/cpp/service.h"
19 #include "services/service_manager/public/cpp/service_context.h"
18 #include "services/service_manager/public/cpp/service_runner.h" 20 #include "services/service_manager/public/cpp/service_runner.h"
19 #include "services/tracing/public/cpp/provider.h" 21 #include "services/tracing/public/cpp/provider.h"
20 #include "ui/views/background.h" 22 #include "ui/views/background.h"
21 #include "ui/views/controls/textfield/textfield.h" 23 #include "ui/views/controls/textfield/textfield.h"
22 #include "ui/views/controls/textfield/textfield_controller.h" 24 #include "ui/views/controls/textfield/textfield_controller.h"
23 #include "ui/views/mus/aura_init.h" 25 #include "ui/views/mus/aura_init.h"
24 #include "ui/views/mus/window_manager_connection.h" 26 #include "ui/views/mus/window_manager_connection.h"
25 #include "ui/views/widget/widget_delegate.h" 27 #include "ui/views/widget/widget_delegate.h"
26 #include "url/gurl.h" 28 #include "url/gurl.h"
27 29
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 QuickLaunch::~QuickLaunch() {} 159 QuickLaunch::~QuickLaunch() {}
158 160
159 void QuickLaunch::RemoveWindow(views::Widget* window) { 161 void QuickLaunch::RemoveWindow(views::Widget* window) {
160 auto it = std::find(windows_.begin(), windows_.end(), window); 162 auto it = std::find(windows_.begin(), windows_.end(), window);
161 DCHECK(it != windows_.end()); 163 DCHECK(it != windows_.end());
162 windows_.erase(it); 164 windows_.erase(it);
163 if (windows_.empty() && base::MessageLoop::current()->is_running()) 165 if (windows_.empty() && base::MessageLoop::current()->is_running())
164 base::MessageLoop::current()->QuitWhenIdle(); 166 base::MessageLoop::current()->QuitWhenIdle();
165 } 167 }
166 168
167 void QuickLaunch::OnStart(const service_manager::ServiceInfo& info) { 169 void QuickLaunch::OnStart(service_manager::ServiceContext* context) {
168 tracing_.Initialize(connector(), info.identity.name()); 170 context_ = context;
171 tracing_.Initialize(context->connector(), context->identity().name());
169 172
170 aura_init_ = base::MakeUnique<views::AuraInit>(connector(), info.identity, 173 aura_init_ = base::MakeUnique<views::AuraInit>(
171 "views_mus_resources.pak"); 174 context->connector(), context->identity(), "views_mus_resources.pak");
172 window_manager_connection_ = 175 window_manager_connection_ = views::WindowManagerConnection::Create(
173 views::WindowManagerConnection::Create(connector(), info.identity); 176 context->connector(), context->identity());
174 177
175 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW); 178 Launch(mojom::kWindow, mojom::LaunchMode::MAKE_NEW);
176 } 179 }
177 180
178 bool QuickLaunch::OnConnect(const service_manager::ServiceInfo& remote_info, 181 bool QuickLaunch::OnConnect(const service_manager::ServiceInfo& remote_info,
179 service_manager::InterfaceRegistry* registry) { 182 service_manager::InterfaceRegistry* registry) {
180 registry->AddInterface<mojom::Launchable>(this); 183 registry->AddInterface<mojom::Launchable>(this);
181 return true; 184 return true;
182 } 185 }
183 186
184 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) { 187 void QuickLaunch::Launch(uint32_t what, mojom::LaunchMode how) {
185 bool reuse = how == mojom::LaunchMode::REUSE || 188 bool reuse = how == mojom::LaunchMode::REUSE ||
186 how == mojom::LaunchMode::DEFAULT; 189 how == mojom::LaunchMode::DEFAULT;
187 if (reuse && !windows_.empty()) { 190 if (reuse && !windows_.empty()) {
188 windows_.back()->Activate(); 191 windows_.back()->Activate();
189 return; 192 return;
190 } 193 }
191 catalog::mojom::CatalogPtr catalog; 194 catalog::mojom::CatalogPtr catalog;
192 connector()->ConnectToInterface("service:catalog", &catalog); 195 context_->connector()->ConnectToInterface("service:catalog", &catalog);
193 196
194 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( 197 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds(
195 new QuickLaunchUI(this, connector(), std::move(catalog)), 198 new QuickLaunchUI(this, context_->connector(), std::move(catalog)),
196 nullptr, gfx::Rect(10, 640, 0, 0)); 199 nullptr, gfx::Rect(10, 640, 0, 0));
197 window->Show(); 200 window->Show();
198 windows_.push_back(window); 201 windows_.push_back(window);
199 } 202 }
200 203
201 void QuickLaunch::Create(const service_manager::Identity& remote_identity, 204 void QuickLaunch::Create(const service_manager::Identity& remote_identity,
202 mojom::LaunchableRequest request) { 205 mojom::LaunchableRequest request) {
203 bindings_.AddBinding(this, std::move(request)); 206 bindings_.AddBinding(this, std::move(request));
204 } 207 }
205 208
206 } // namespace quick_launch 209 } // namespace quick_launch
207 } // namespace mash 210 } // namespace mash
OLDNEW
« no previous file with comments | « mash/quick_launch/quick_launch.h ('k') | mash/screenlock/screenlock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698