| OLD | NEW |
| 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 "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 VLOG(2) << "Cannot launch not-ready app: " << app_id << "."; | 136 VLOG(2) << "Cannot launch not-ready app: " << app_id << "."; |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 | 139 |
| 140 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 140 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); |
| 141 if (!bridge_service) { | 141 if (!bridge_service) { |
| 142 VLOG(2) << "Request to launch app when bridge service is not ready: " | 142 VLOG(2) << "Request to launch app when bridge service is not ready: " |
| 143 << app_id << "."; | 143 << app_id << "."; |
| 144 return false; | 144 return false; |
| 145 } | 145 } |
| 146 arc::AppInstance* app_instance = bridge_service->app_instance(); | 146 arc::mojom::AppInstance* app_instance = bridge_service->app_instance(); |
| 147 if (!app_instance) { | 147 if (!app_instance) { |
| 148 VLOG(2) << "Request to launch app when bridge service is not ready: " | 148 VLOG(2) << "Request to launch app when bridge service is not ready: " |
| 149 << app_id << "."; | 149 << app_id << "."; |
| 150 return false; | 150 return false; |
| 151 } | 151 } |
| 152 | 152 |
| 153 arc::ScreenRectPtr rect = arc::ScreenRect::New(); | 153 arc::mojom::ScreenRectPtr rect = arc::mojom::ScreenRect::New(); |
| 154 rect->left = target_rect.x(); | 154 rect->left = target_rect.x(); |
| 155 rect->right = target_rect.right(); | 155 rect->right = target_rect.right(); |
| 156 rect->top = target_rect.y(); | 156 rect->top = target_rect.y(); |
| 157 rect->bottom = target_rect.bottom(); | 157 rect->bottom = target_rect.bottom(); |
| 158 | 158 |
| 159 app_instance->LaunchApp(app_info->package_name, app_info->activity, | 159 app_instance->LaunchApp(app_info->package_name, app_info->activity, |
| 160 std::move(rect)); | 160 std::move(rect)); |
| 161 prefs->SetLastLaunchTime(app_id, base::Time::Now()); | 161 prefs->SetLastLaunchTime(app_id, base::Time::Now()); |
| 162 | 162 |
| 163 return true; | 163 return true; |
| 164 } | 164 } |
| 165 | 165 |
| 166 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { | 166 bool LaunchApp(content::BrowserContext* context, const std::string& app_id) { |
| 167 return (new LaunchAppWithoutSize(context, app_id))->LaunchAndRelease(); | 167 return (new LaunchAppWithoutSize(context, app_id))->LaunchAndRelease(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 bool CanHandleResolution(content::BrowserContext* context, | 170 bool CanHandleResolution(content::BrowserContext* context, |
| 171 const std::string& app_id, | 171 const std::string& app_id, |
| 172 const gfx::Rect& rect, | 172 const gfx::Rect& rect, |
| 173 const CanHandleResolutionCallback& callback) { | 173 const CanHandleResolutionCallback& callback) { |
| 174 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); | 174 ArcAppListPrefs* prefs = ArcAppListPrefs::Get(context); |
| 175 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); | 175 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id); |
| 176 if (!app_info) { | 176 if (!app_info) { |
| 177 VLOG(2) << "Cannot test resolution capability of unavailable app:" << app_id | 177 VLOG(2) << "Cannot test resolution capability of unavailable app:" << app_id |
| 178 << "."; | 178 << "."; |
| 179 return false; | 179 return false; |
| 180 } | 180 } |
| 181 | 181 |
| 182 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 182 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); |
| 183 arc::AppInstance* app_instance = | 183 arc::mojom::AppInstance* app_instance = |
| 184 bridge_service ? bridge_service->app_instance() : nullptr; | 184 bridge_service ? bridge_service->app_instance() : nullptr; |
| 185 if (!app_instance) { | 185 if (!app_instance) { |
| 186 VLOG(2) << "Request to get resolution capability when bridge service is " | 186 VLOG(2) << "Request to get resolution capability when bridge service is " |
| 187 << "not ready: " << app_id << "."; | 187 << "not ready: " << app_id << "."; |
| 188 return false; | 188 return false; |
| 189 } | 189 } |
| 190 | 190 |
| 191 if (bridge_service->app_version() < 1) { | 191 if (bridge_service->app_version() < 1) { |
| 192 VLOG(2) | 192 VLOG(2) |
| 193 << "CanHandleResolution() not supported by ARC app instance version " | 193 << "CanHandleResolution() not supported by ARC app instance version " |
| 194 << bridge_service->app_version(); | 194 << bridge_service->app_version(); |
| 195 return false; | 195 return false; |
| 196 } | 196 } |
| 197 | 197 |
| 198 arc::ScreenRectPtr screen_rect = arc::ScreenRect::New(); | 198 arc::mojom::ScreenRectPtr screen_rect = arc::mojom::ScreenRect::New(); |
| 199 screen_rect->left = rect.x(); | 199 screen_rect->left = rect.x(); |
| 200 screen_rect->right = rect.right(); | 200 screen_rect->right = rect.right(); |
| 201 screen_rect->top = rect.y(); | 201 screen_rect->top = rect.y(); |
| 202 screen_rect->bottom = rect.bottom(); | 202 screen_rect->bottom = rect.bottom(); |
| 203 | 203 |
| 204 app_instance->CanHandleResolution(app_info->package_name, app_info->activity, | 204 app_instance->CanHandleResolution(app_info->package_name, app_info->activity, |
| 205 std::move(screen_rect), | 205 std::move(screen_rect), |
| 206 callback); | 206 callback); |
| 207 return true; | 207 return true; |
| 208 } | 208 } |
| 209 | 209 |
| 210 void UninstallPackage(const std::string& package_name) { | 210 void UninstallPackage(const std::string& package_name) { |
| 211 VLOG(2) << "Uninstalling " << package_name; | 211 VLOG(2) << "Uninstalling " << package_name; |
| 212 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); | 212 arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get(); |
| 213 if (!bridge_service) { | 213 if (!bridge_service) { |
| 214 VLOG(2) << "Request to uninstall package when bridge service is not ready: " | 214 VLOG(2) << "Request to uninstall package when bridge service is not ready: " |
| 215 << package_name << "."; | 215 << package_name << "."; |
| 216 return; | 216 return; |
| 217 } | 217 } |
| 218 arc::AppInstance* app_instance = bridge_service->app_instance(); | 218 arc::mojom::AppInstance* app_instance = bridge_service->app_instance(); |
| 219 if (!app_instance) { | 219 if (!app_instance) { |
| 220 VLOG(2) << "Request to uninstall package when bridge service is not ready: " | 220 VLOG(2) << "Request to uninstall package when bridge service is not ready: " |
| 221 << package_name << "."; | 221 << package_name << "."; |
| 222 return; | 222 return; |
| 223 } | 223 } |
| 224 | 224 |
| 225 if (bridge_service->app_version() < 2) { | 225 if (bridge_service->app_version() < 2) { |
| 226 LOG(ERROR) << "Request to uninstall package when version " | 226 LOG(ERROR) << "Request to uninstall package when version " |
| 227 << bridge_service->app_version() << " does not support it"; | 227 << bridge_service->app_version() << " does not support it"; |
| 228 return; | 228 return; |
| 229 } | 229 } |
| 230 app_instance->UninstallPackage(package_name); | 230 app_instance->UninstallPackage(package_name); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace arc | 233 } // namespace arc |
| OLD | NEW |