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 "chrome/browser/task_manager/providers/arc/arc_process_task.h" | 5 #include "chrome/browser/task_manager/providers/arc/arc_process_task.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
12 #include "components/arc/arc_bridge_service.h" | 12 #include "components/arc/arc_bridge_service.h" |
13 #include "components/arc/arc_service_manager.h" | 13 #include "components/arc/arc_service_manager.h" |
14 #include "components/arc/common/process.mojom.h" | 14 #include "components/arc/common/process.mojom.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/common/child_process_host.h" | 16 #include "content/public/common/child_process_host.h" |
17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/gfx/image/image.h" | 18 #include "ui/gfx/image/image.h" |
19 | 19 |
20 namespace task_manager { | 20 namespace task_manager { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 constexpr uint32_t kKillProcessMinInstanceVersion = 1; | |
25 | |
26 base::string16 MakeTitle(const std::string& process_name, | 24 base::string16 MakeTitle(const std::string& process_name, |
27 arc::mojom::ProcessState process_state) { | 25 arc::mojom::ProcessState process_state) { |
28 int name_template = IDS_TASK_MANAGER_ARC_PREFIX; | 26 int name_template = IDS_TASK_MANAGER_ARC_PREFIX; |
29 switch (process_state) { | 27 switch (process_state) { |
30 case arc::mojom::ProcessState::PERSISTENT: | 28 case arc::mojom::ProcessState::PERSISTENT: |
31 case arc::mojom::ProcessState::PERSISTENT_UI: | 29 case arc::mojom::ProcessState::PERSISTENT_UI: |
32 case arc::mojom::ProcessState::TOP: | 30 case arc::mojom::ProcessState::TOP: |
33 name_template = IDS_TASK_MANAGER_ARC_SYSTEM; | 31 name_template = IDS_TASK_MANAGER_ARC_SYSTEM; |
34 break; | 32 break; |
35 case arc::mojom::ProcessState::BOUND_FOREGROUND_SERVICE: | 33 case arc::mojom::ProcessState::BOUND_FOREGROUND_SERVICE: |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // ARC process is not a child process of the browser. | 127 // ARC process is not a child process of the browser. |
130 return content::ChildProcessHost::kInvalidUniqueID; | 128 return content::ChildProcessHost::kInvalidUniqueID; |
131 } | 129 } |
132 | 130 |
133 bool ArcProcessTask::IsKillable() { | 131 bool ArcProcessTask::IsKillable() { |
134 // Do not kill persistent processes. | 132 // Do not kill persistent processes. |
135 return process_state_ > arc::mojom::ProcessState::PERSISTENT_UI; | 133 return process_state_ > arc::mojom::ProcessState::PERSISTENT_UI; |
136 } | 134 } |
137 | 135 |
138 void ArcProcessTask::Kill() { | 136 void ArcProcessTask::Kill() { |
139 auto* process_instance = | 137 auto* process_instance = ARC_GET_INSTANCE_FOR_METHOD( |
140 arc::ArcServiceManager::Get() | 138 arc::ArcServiceManager::Get()->arc_bridge_service()->process(), |
141 ->arc_bridge_service() | 139 KillProcess); |
142 ->process() | |
143 ->GetInstanceForMethod("KillProcess", kKillProcessMinInstanceVersion); | |
144 if (!process_instance) | 140 if (!process_instance) |
145 return; | 141 return; |
146 process_instance->KillProcess(nspid_, "Killed manually from Task Manager"); | 142 process_instance->KillProcess(nspid_, "Killed manually from Task Manager"); |
147 } | 143 } |
148 | 144 |
149 void ArcProcessTask::OnInstanceReady() { | 145 void ArcProcessTask::OnInstanceReady() { |
150 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
151 | 147 |
152 VLOG(2) << "intent_helper instance is ready. Fetching the icon for " | 148 VLOG(2) << "intent_helper instance is ready. Fetching the icon for " |
153 << package_name_; | 149 << package_name_; |
(...skipping 20 matching lines...) Expand all Loading... |
174 for (const auto& kv : *icons) { | 170 for (const auto& kv : *icons) { |
175 const gfx::Image& icon = kv.second.icon16; | 171 const gfx::Image& icon = kv.second.icon16; |
176 if (icon.IsEmpty()) | 172 if (icon.IsEmpty()) |
177 continue; | 173 continue; |
178 set_icon(*icon.ToImageSkia()); | 174 set_icon(*icon.ToImageSkia()); |
179 break; // Since the parent class can hold only one icon, break here. | 175 break; // Since the parent class can hold only one icon, break here. |
180 } | 176 } |
181 } | 177 } |
182 | 178 |
183 } // namespace task_manager | 179 } // namespace task_manager |
OLD | NEW |