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 "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 "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/process/process.h" | 14 #include "base/process/process.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "mojo/public/cpp/bindings/binding.h" | 17 #include "mojo/public/cpp/bindings/binding.h" |
18 #include "services/catalog/public/interfaces/catalog.mojom.h" | 18 #include "services/catalog/public/interfaces/catalog.mojom.h" |
19 #include "services/shell/public/cpp/connection.h" | 19 #include "services/shell/public/cpp/connection.h" |
20 #include "services/shell/public/cpp/connector.h" | 20 #include "services/shell/public/cpp/connector.h" |
21 #include "services/shell/public/interfaces/service_manager.mojom.h" | 21 #include "services/shell/public/interfaces/service_manager.mojom.h" |
22 #include "ui/base/models/table_model.h" | 22 #include "ui/base/models/table_model.h" |
23 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
24 #include "ui/resources/grit/ui_resources.h" | 24 #include "ui/resources/grit/ui_resources.h" |
25 #include "ui/views/background.h" | 25 #include "ui/views/background.h" |
26 #include "ui/views/controls/button/label_button.h" | 26 #include "ui/views/controls/button/md_text_button.h" |
27 #include "ui/views/controls/table/table_view.h" | 27 #include "ui/views/controls/table/table_view.h" |
28 #include "ui/views/controls/table/table_view_observer.h" | 28 #include "ui/views/controls/table/table_view_observer.h" |
29 #include "ui/views/mus/aura_init.h" | 29 #include "ui/views/mus/aura_init.h" |
30 #include "ui/views/mus/window_manager_connection.h" | 30 #include "ui/views/mus/window_manager_connection.h" |
31 #include "ui/views/widget/widget_delegate.h" | 31 #include "ui/views/widget/widget_delegate.h" |
32 | 32 |
33 namespace mash { | 33 namespace mash { |
34 namespace task_viewer { | 34 namespace task_viewer { |
35 namespace { | 35 namespace { |
36 | 36 |
37 using shell::mojom::ServiceInfoPtr; | 37 using shell::mojom::ServiceInfoPtr; |
38 | 38 |
39 class TaskViewerContents : public views::WidgetDelegateView, | 39 class TaskViewerContents : public views::WidgetDelegateView, |
40 public ui::TableModel, | 40 public ui::TableModel, |
41 public views::ButtonListener, | 41 public views::ButtonListener, |
42 public shell::mojom::ServiceManagerListener { | 42 public shell::mojom::ServiceManagerListener { |
43 public: | 43 public: |
44 TaskViewerContents(TaskViewer* task_viewer, | 44 TaskViewerContents(TaskViewer* task_viewer, |
45 shell::mojom::ServiceManagerListenerRequest request, | 45 shell::mojom::ServiceManagerListenerRequest request, |
46 catalog::mojom::CatalogPtr catalog) | 46 catalog::mojom::CatalogPtr catalog) |
47 : task_viewer_(task_viewer), | 47 : task_viewer_(task_viewer), |
48 binding_(this, std::move(request)), | 48 binding_(this, std::move(request)), |
49 catalog_(std::move(catalog)), | 49 catalog_(std::move(catalog)), |
50 table_view_(nullptr), | 50 table_view_(nullptr), |
51 table_view_parent_(nullptr), | 51 table_view_parent_(nullptr), |
52 kill_button_( | 52 kill_button_( |
53 new views::LabelButton(this, base::ASCIIToUTF16("Kill Process"))), | 53 views::MdTextButton::Create(this, |
| 54 base::ASCIIToUTF16("Kill Process"))), |
54 observer_(nullptr), | 55 observer_(nullptr), |
55 weak_ptr_factory_(this) { | 56 weak_ptr_factory_(this) { |
56 // We don't want to show an empty UI on startup, so just block until we | 57 // We don't want to show an empty UI on startup, so just block until we |
57 // receive the initial set of applications. | 58 // receive the initial set of applications. |
58 binding_.WaitForIncomingMethodCall(); | 59 binding_.WaitForIncomingMethodCall(); |
59 | 60 |
60 table_view_ = new views::TableView(this, GetColumns(), views::TEXT_ONLY, | 61 table_view_ = new views::TableView(this, GetColumns(), views::TEXT_ONLY, |
61 false); | 62 false); |
62 set_background(views::Background::CreateStandardPanelBackground()); | 63 set_background(views::Background::CreateStandardPanelBackground()); |
63 | 64 |
64 table_view_parent_ = table_view_->CreateParentIfNecessary(); | 65 table_view_parent_ = table_view_->CreateParentIfNecessary(); |
65 AddChildView(table_view_parent_); | 66 AddChildView(table_view_parent_); |
66 | 67 |
67 kill_button_->SetStyle(views::Button::STYLE_BUTTON); | |
68 AddChildView(kill_button_); | 68 AddChildView(kill_button_); |
69 } | 69 } |
70 ~TaskViewerContents() override { | 70 ~TaskViewerContents() override { |
71 table_view_->SetModel(nullptr); | 71 table_view_->SetModel(nullptr); |
72 task_viewer_->RemoveWindow(GetWidget()); | 72 task_viewer_->RemoveWindow(GetWidget()); |
73 } | 73 } |
74 | 74 |
75 private: | 75 private: |
76 struct InstanceInfo { | 76 struct InstanceInfo { |
77 InstanceInfo(const shell::Identity& identity, base::ProcessId pid) | 77 InstanceInfo(const shell::Identity& identity, base::ProcessId pid) |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 253 |
254 return columns; | 254 return columns; |
255 } | 255 } |
256 | 256 |
257 TaskViewer* task_viewer_; | 257 TaskViewer* task_viewer_; |
258 mojo::Binding<shell::mojom::ServiceManagerListener> binding_; | 258 mojo::Binding<shell::mojom::ServiceManagerListener> binding_; |
259 catalog::mojom::CatalogPtr catalog_; | 259 catalog::mojom::CatalogPtr catalog_; |
260 | 260 |
261 views::TableView* table_view_; | 261 views::TableView* table_view_; |
262 views::View* table_view_parent_; | 262 views::View* table_view_parent_; |
263 views::LabelButton* kill_button_; | 263 views::MdTextButton* kill_button_; |
264 ui::TableModelObserver* observer_; | 264 ui::TableModelObserver* observer_; |
265 | 265 |
266 std::vector<std::unique_ptr<InstanceInfo>> instances_; | 266 std::vector<std::unique_ptr<InstanceInfo>> instances_; |
267 | 267 |
268 base::WeakPtrFactory<TaskViewerContents> weak_ptr_factory_; | 268 base::WeakPtrFactory<TaskViewerContents> weak_ptr_factory_; |
269 | 269 |
270 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); | 270 DISALLOW_COPY_AND_ASSIGN(TaskViewerContents); |
271 }; | 271 }; |
272 | 272 |
273 } // namespace | 273 } // namespace |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 windows_.push_back(window); | 324 windows_.push_back(window); |
325 } | 325 } |
326 | 326 |
327 void TaskViewer::Create(const shell::Identity& remote_identity, | 327 void TaskViewer::Create(const shell::Identity& remote_identity, |
328 mojom::LaunchableRequest request) { | 328 mojom::LaunchableRequest request) { |
329 bindings_.AddBinding(this, std::move(request)); | 329 bindings_.AddBinding(this, std::move(request)); |
330 } | 330 } |
331 | 331 |
332 } // namespace task_viewer | 332 } // namespace task_viewer |
333 } // namespace main | 333 } // namespace main |
OLD | NEW |