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_application_delegate.h" | 5 #include "mash/task_viewer/task_viewer_application_delegate.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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 using ListenerRequest = | 32 using ListenerRequest = |
33 mojo::InterfaceRequest<mojo::shell::mojom::ApplicationManagerListener>; | 33 mojo::InterfaceRequest<mojo::shell::mojom::ApplicationManagerListener>; |
34 using mojo::shell::mojom::ApplicationInfoPtr; | 34 using mojo::shell::mojom::ApplicationInfoPtr; |
35 | 35 |
36 class TaskViewer : public views::WidgetDelegateView, | 36 class TaskViewer : public views::WidgetDelegateView, |
37 public ui::TableModel, | 37 public ui::TableModel, |
38 public views::ButtonListener, | 38 public views::ButtonListener, |
39 public mojo::shell::mojom::ApplicationManagerListener { | 39 public mojo::shell::mojom::ApplicationManagerListener { |
40 public: | 40 public: |
41 explicit TaskViewer(ListenerRequest request) | 41 TaskViewer(ListenerRequest request, scoped_ptr<mojo::AppRefCount> app) |
42 : binding_(this, std::move(request)), | 42 : binding_(this, std::move(request)), |
| 43 app_(std::move(app)), |
43 table_view_(nullptr), | 44 table_view_(nullptr), |
44 table_view_parent_(nullptr), | 45 table_view_parent_(nullptr), |
45 kill_button_( | 46 kill_button_( |
46 new views::LabelButton(this, base::ASCIIToUTF16("Kill Process"))), | 47 new views::LabelButton(this, base::ASCIIToUTF16("Kill Process"))), |
47 observer_(nullptr) { | 48 observer_(nullptr) { |
48 // We don't want to show an empty UI on startup, so just block until we | 49 // We don't want to show an empty UI on startup, so just block until we |
49 // receive the initial set of applications. | 50 // receive the initial set of applications. |
50 binding_.WaitForIncomingMethodCall(); | 51 binding_.WaitForIncomingMethodCall(); |
51 | 52 |
52 table_view_ = new views::TableView(this, GetColumns(), views::TEXT_ONLY, | 53 table_view_ = new views::TableView(this, GetColumns(), views::TEXT_ONLY, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // TODO(beng): use resources. | 193 // TODO(beng): use resources. |
193 pid_column.title = base::ASCIIToUTF16("PID"); | 194 pid_column.title = base::ASCIIToUTF16("PID"); |
194 pid_column.width = 50; | 195 pid_column.width = 50; |
195 pid_column.sortable = true; | 196 pid_column.sortable = true; |
196 columns.push_back(pid_column); | 197 columns.push_back(pid_column); |
197 | 198 |
198 return columns; | 199 return columns; |
199 } | 200 } |
200 | 201 |
201 mojo::Binding<mojo::shell::mojom::ApplicationManagerListener> binding_; | 202 mojo::Binding<mojo::shell::mojom::ApplicationManagerListener> binding_; |
| 203 scoped_ptr<mojo::AppRefCount> app_; |
202 | 204 |
203 views::TableView* table_view_; | 205 views::TableView* table_view_; |
204 views::View* table_view_parent_; | 206 views::View* table_view_parent_; |
205 views::LabelButton* kill_button_; | 207 views::LabelButton* kill_button_; |
206 ui::TableModelObserver* observer_; | 208 ui::TableModelObserver* observer_; |
207 | 209 |
208 std::vector<scoped_ptr<ApplicationInfo>> applications_; | 210 std::vector<scoped_ptr<ApplicationInfo>> applications_; |
209 | 211 |
210 DISALLOW_COPY_AND_ASSIGN(TaskViewer); | 212 DISALLOW_COPY_AND_ASSIGN(TaskViewer); |
211 }; | 213 }; |
(...skipping 10 matching lines...) Expand all Loading... |
222 aura_init_.reset(new views::AuraInit(app, "views_mus_resources.pak")); | 224 aura_init_.reset(new views::AuraInit(app, "views_mus_resources.pak")); |
223 views::WindowManagerConnection::Create(app); | 225 views::WindowManagerConnection::Create(app); |
224 | 226 |
225 mojo::shell::mojom::ApplicationManagerPtr application_manager; | 227 mojo::shell::mojom::ApplicationManagerPtr application_manager; |
226 app->ConnectToService("mojo:shell", &application_manager); | 228 app->ConnectToService("mojo:shell", &application_manager); |
227 | 229 |
228 mojo::shell::mojom::ApplicationManagerListenerPtr listener; | 230 mojo::shell::mojom::ApplicationManagerListenerPtr listener; |
229 ListenerRequest request = GetProxy(&listener); | 231 ListenerRequest request = GetProxy(&listener); |
230 application_manager->AddListener(std::move(listener)); | 232 application_manager->AddListener(std::move(listener)); |
231 | 233 |
232 TaskViewer* task_viewer = new TaskViewer(std::move(request)); | 234 TaskViewer* task_viewer = new TaskViewer( |
| 235 std::move(request), app->app_lifetime_helper()->CreateAppRefCount()); |
233 views::Widget* window = views::Widget::CreateWindowWithBounds( | 236 views::Widget* window = views::Widget::CreateWindowWithBounds( |
234 task_viewer, gfx::Rect(10, 10, 500, 500)); | 237 task_viewer, gfx::Rect(10, 10, 500, 500)); |
235 window->Show(); | 238 window->Show(); |
236 } | 239 } |
237 | 240 |
238 } // namespace task_viewer | 241 } // namespace task_viewer |
239 } // namespace main | 242 } // namespace main |
OLD | NEW |