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

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

Issue 2915223002: mash: Fix mash app shelf items; encapsulate ash property setup. (Closed)
Patch Set: Similar changes for other mash apps. Created 3 years, 6 months 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
OLDNEW
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 "mash/task_viewer/task_viewer.h" 5 #include "mash/task_viewer/task_viewer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "ash/public/cpp/shelf_types.h"
11 #include "ash/public/cpp/window_properties.h"
10 #include "base/bind.h" 12 #include "base/bind.h"
11 #include "base/macros.h" 13 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
13 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
15 #include "base/process/process.h" 17 #include "base/process/process.h"
16 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
18 #include "mojo/public/cpp/bindings/binding.h" 20 #include "mojo/public/cpp/bindings/binding.h"
19 #include "services/catalog/public/interfaces/catalog.mojom.h" 21 #include "services/catalog/public/interfaces/catalog.mojom.h"
20 #include "services/catalog/public/interfaces/constants.mojom.h" 22 #include "services/catalog/public/interfaces/constants.mojom.h"
21 #include "services/service_manager/public/cpp/connector.h" 23 #include "services/service_manager/public/cpp/connector.h"
22 #include "services/service_manager/public/cpp/service_context.h" 24 #include "services/service_manager/public/cpp/service_context.h"
23 #include "services/service_manager/public/interfaces/constants.mojom.h" 25 #include "services/service_manager/public/interfaces/constants.mojom.h"
24 #include "services/service_manager/public/interfaces/service_manager.mojom.h" 26 #include "services/service_manager/public/interfaces/service_manager.mojom.h"
27 #include "ui/aura/window.h"
25 #include "ui/base/models/table_model.h" 28 #include "ui/base/models/table_model.h"
26 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
27 #include "ui/resources/grit/ui_resources.h" 30 #include "ui/resources/grit/ui_resources.h"
28 #include "ui/views/background.h" 31 #include "ui/views/background.h"
29 #include "ui/views/controls/button/md_text_button.h" 32 #include "ui/views/controls/button/md_text_button.h"
30 #include "ui/views/controls/table/table_view.h" 33 #include "ui/views/controls/table/table_view.h"
31 #include "ui/views/controls/table/table_view_observer.h" 34 #include "ui/views/controls/table/table_view_observer.h"
32 #include "ui/views/mus/aura_init.h" 35 #include "ui/views/mus/aura_init.h"
33 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
34 #include "ui/views/widget/widget_delegate.h" 37 #include "ui/views/widget/widget_delegate.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 DCHECK(it != windows_.end()); 293 DCHECK(it != windows_.end());
291 windows_.erase(it); 294 windows_.erase(it);
292 if (windows_.empty()) 295 if (windows_.empty())
293 base::MessageLoop::current()->QuitWhenIdle(); 296 base::MessageLoop::current()->QuitWhenIdle();
294 } 297 }
295 298
296 void TaskViewer::OnStart() { 299 void TaskViewer::OnStart() {
297 aura_init_ = base::MakeUnique<views::AuraInit>( 300 aura_init_ = base::MakeUnique<views::AuraInit>(
298 context()->connector(), context()->identity(), "views_mus_resources.pak", 301 context()->connector(), context()->identity(), "views_mus_resources.pak",
299 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS); 302 std::string(), nullptr, views::AuraInit::Mode::AURA_MUS);
303 ash::RegisterWindowPropertiesForTransportAndMirroring();
300 } 304 }
301 305
302 void TaskViewer::OnBindInterface( 306 void TaskViewer::OnBindInterface(
303 const service_manager::BindSourceInfo& source_info, 307 const service_manager::BindSourceInfo& source_info,
304 const std::string& interface_name, 308 const std::string& interface_name,
305 mojo::ScopedMessagePipeHandle interface_pipe) { 309 mojo::ScopedMessagePipeHandle interface_pipe) {
306 registry_.BindInterface(source_info, interface_name, 310 registry_.BindInterface(source_info, interface_name,
307 std::move(interface_pipe)); 311 std::move(interface_pipe));
308 } 312 }
309 313
310 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) { 314 void TaskViewer::Launch(uint32_t what, mojom::LaunchMode how) {
311 bool reuse = how == mojom::LaunchMode::REUSE || 315 bool reuse = how == mojom::LaunchMode::REUSE ||
312 how == mojom::LaunchMode::DEFAULT; 316 how == mojom::LaunchMode::DEFAULT;
313 if (reuse && !windows_.empty()) { 317 if (reuse && !windows_.empty()) {
314 windows_.back()->Activate(); 318 windows_.back()->Activate();
315 return; 319 return;
316 } 320 }
317 321
318 service_manager::mojom::ServiceManagerPtr service_manager; 322 service_manager::mojom::ServiceManagerPtr service_manager;
319 context()->connector()->BindInterface(service_manager::mojom::kServiceName, 323 context()->connector()->BindInterface(service_manager::mojom::kServiceName,
320 &service_manager); 324 &service_manager);
321 325
322 catalog::mojom::CatalogPtr catalog; 326 catalog::mojom::CatalogPtr catalog;
323 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog); 327 context()->connector()->BindInterface(catalog::mojom::kServiceName, &catalog);
324 328
325 service_manager::mojom::ServiceManagerListenerPtr listener; 329 service_manager::mojom::ServiceManagerListenerPtr listener;
326 TaskViewerContents* task_viewer = new TaskViewerContents( 330 TaskViewerContents* task_viewer = new TaskViewerContents(
327 this, mojo::MakeRequest(&listener), std::move(catalog)); 331 this, mojo::MakeRequest(&listener), std::move(catalog));
328 views::Widget* window = views::Widget::CreateWindowWithContextAndBounds( 332 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
329 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500)); 333 task_viewer, nullptr, gfx::Rect(10, 10, 500, 500));
330 window->Show(); 334 aura::Window* window = widget->GetNativeWindow();
331 windows_.push_back(window); 335 const ash::ShelfID shelf_id("org.chromium.mash.task_viewer");
msw 2017/06/01 23:35:41 q: I can't actually launch this from chrome --mash
336 window->SetProperty(ash::kShelfIDKey, new std::string(shelf_id.Serialize()));
337 window->SetProperty<int>(ash::kShelfItemTypeKey, ash::TYPE_DIALOG);
338
339 widget->Show();
340 windows_.push_back(widget);
332 service_manager->AddListener(std::move(listener)); 341 service_manager->AddListener(std::move(listener));
333 } 342 }
334 343
335 void TaskViewer::Create(const service_manager::BindSourceInfo& source_info, 344 void TaskViewer::Create(const service_manager::BindSourceInfo& source_info,
336 ::mash::mojom::LaunchableRequest request) { 345 ::mash::mojom::LaunchableRequest request) {
337 bindings_.AddBinding(this, std::move(request)); 346 bindings_.AddBinding(this, std::move(request));
338 } 347 }
339 348
340 } // namespace task_viewer 349 } // namespace task_viewer
341 } // namespace main 350 } // namespace main
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698